Skip to content

Commit 73b729a

Browse files
Fixed test case
1 parent b5bcd0d commit 73b729a

File tree

3 files changed

+24
-16
lines changed

3 files changed

+24
-16
lines changed

src/com/magento/idea/magento2plugin/actions/generation/generator/code/util/ConvertPluginParamsToString.java

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -92,12 +92,10 @@ public static String execute(
9292

9393
if (type.equals(Plugin.PluginType.after) && iterator == 0) {
9494
if (returnType != null
95-
&& returnType.getText().equals(MagentoPhpClass.VOID_RETURN_TYPE)) {
96-
buf.append(", $result");
95+
&& !returnType.getText().equals(MagentoPhpClass.VOID_RETURN_TYPE)) {
96+
buf.append(", ").append(returnType.getText()).append(" $result");
9797
} else {
98-
if (returnType != null) {
99-
buf.append(", ").append(returnType.getText()).append(" $result");
100-
}
98+
buf.append(", $result");
10199
}
102100
}
103101
if (type.equals(Plugin.PluginType.around) && iterator == 0) {

testData/actions/generation/generator/PluginClassGenerator/generatePluginClassFile/TestPlugin.php

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,38 +8,37 @@
88

99
class TestPlugin
1010
{
11-
1211
/**
13-
* @param \Foo\Bar\Service\SimpleService $subject
12+
* @param SimpleService $subject
1413
* @param int $param1
1514
* @param string $param2
1615
* @return array
1716
*/
18-
public function beforeExecute(\Foo\Bar\Service\SimpleService $subject, int $param1, string $param2)
17+
public function beforeExecute(SimpleService $subject, int $param1, string $param2)
1918
{
2019
// TODO: Implement plugin method.
2120
return [$param1, $param2];
2221
}
2322

2423
/**
25-
* @param \Foo\Bar\Service\SimpleService $subject
24+
* @param SimpleService $subject
2625
* @param callable $proceed
2726
* @param int $param1
2827
* @param string $param2
2928
*/
30-
public function aroundExecute(\Foo\Bar\Service\SimpleService $subject, callable $proceed, int $param1, string $param2)
29+
public function aroundExecute(SimpleService $subject, callable $proceed, int $param1, string $param2)
3130
{
3231
// TODO: Implement plugin method.
3332
return $proceed($param1, $param2);
3433
}
3534

3635
/**
37-
* @param \Foo\Bar\Service\SimpleService $subject
36+
* @param SimpleService $subject
3837
* @param $result
3938
* @param int $param1
4039
* @param string $param2
4140
*/
42-
public function afterExecute(\Foo\Bar\Service\SimpleService $subject, $result, int $param1, string $param2)
41+
public function afterExecute(SimpleService $subject, $result, int $param1, string $param2)
4342
{
4443
// TODO: Implement plugin method.
4544
return $result;

tests/com/magento/idea/magento2plugin/actions/generation/generator/PluginClassGeneratorTest.java

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
* Copyright © Magento, Inc. All rights reserved.
33
* See COPYING.txt for license details.
44
*/
5+
56
package com.magento.idea.magento2plugin.actions.generation.generator;
67

78
import com.intellij.openapi.project.Project;
@@ -11,8 +12,10 @@
1112
import com.magento.idea.magento2plugin.actions.generation.data.PluginFileData;
1213
import com.magento.idea.magento2plugin.magento.files.Plugin;
1314
import com.magento.idea.magento2plugin.util.GetPhpClassByFQN;
15+
import org.jetbrains.annotations.NotNull;
1416

1517
public class PluginClassGeneratorTest extends BaseGeneratorTestCase {
18+
1619
private static final String targetClassFnq = "Foo\\Bar\\Service\\SimpleService";
1720
private static final String targetMethodName = "execute";
1821
private static final String module = "Foo_Bar";
@@ -21,8 +24,10 @@ public class PluginClassGeneratorTest extends BaseGeneratorTestCase {
2124
private static final String pluginClassName = "TestPlugin";
2225
private static final String pluginDir = "Plugin";
2326

24-
public void testGeneratePluginClassFile()
25-
{
27+
/**
28+
* Test of plugin generation.
29+
*/
30+
public void testGeneratePluginClassFile() {
2631
PsiFile pluginClassFile;
2732
addPluginToTargetClass(Plugin.PluginType.before.toString());
2833
addPluginToTargetClass(Plugin.PluginType.around.toString());
@@ -38,8 +43,14 @@ public void testGeneratePluginClassFile()
3843
);
3944
}
4045

41-
private PsiFile addPluginToTargetClass(String pluginType)
42-
{
46+
/**
47+
* Add plugins for the target class.
48+
*
49+
* @param pluginType String
50+
*
51+
* @return PsiFile
52+
*/
53+
private PsiFile addPluginToTargetClass(final @NotNull String pluginType) {
4354
Project project = myFixture.getProject();
4455
PhpClass targetClass = GetPhpClassByFQN.getInstance(project).execute(targetClassFnq);
4556
Method targetMethod = targetClass.findMethodByName(targetMethodName);

0 commit comments

Comments
 (0)