Skip to content

Commit 74aa694

Browse files
Adjusted default code style settings for the unit tests scope
1 parent a62459b commit 74aa694

File tree

3 files changed

+41
-2
lines changed

3 files changed

+41
-2
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
/*
2+
* Copyright © Magento, Inc. All rights reserved.
3+
* See COPYING.txt for license details.
4+
*/
5+
6+
package com.magento.idea.magento2plugin.actions.generation.generator.util;
7+
8+
import com.intellij.openapi.project.Project;
9+
import com.intellij.psi.codeStyle.CodeStyleSettings;
10+
import com.intellij.psi.codeStyle.CodeStyleSettingsManager;
11+
import com.intellij.psi.codeStyle.CommonCodeStyleSettings;
12+
import org.jetbrains.annotations.NotNull;
13+
14+
public final class DefaultCodeStyleSettingsAdjustmentsUtil {
15+
16+
private DefaultCodeStyleSettingsAdjustmentsUtil() {
17+
}
18+
19+
/**
20+
* Adjust default code style settings for project.
21+
*
22+
* @param project Project
23+
*/
24+
public static void execute(final @NotNull Project project) {
25+
final CodeStyleSettings codeStyleSettings = CodeStyleSettingsManager
26+
.getInstance(project)
27+
.getTemporarySettings();
28+
29+
if (codeStyleSettings == null) {
30+
return;
31+
}
32+
final CommonCodeStyleSettings commonPhpSettings = codeStyleSettings
33+
.getCommonSettings("PHP");
34+
// This value has changed to TRUE by default in the latest releases.
35+
// This is necessary to return the value by default to the previous one.
36+
commonPhpSettings.ALIGN_MULTILINE_PARAMETERS = false;
37+
}
38+
}

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
<?php
22

3-
43
namespace Foo\Bar\Plugin;
54

6-
75
use Foo\Bar\Service\SimpleService;
86

97
class TestPlugin

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import com.intellij.psi.PsiFile;
1010
import com.intellij.testFramework.LightPlatformTestCase;
1111
import com.magento.idea.magento2plugin.BaseProjectTestCase;
12+
import com.magento.idea.magento2plugin.actions.generation.generator.util.DefaultCodeStyleSettingsAdjustmentsUtil;
1213
import com.magento.idea.magento2plugin.magento.packages.File;
1314
import com.magento.idea.magento2plugin.project.util.GetProjectBasePath;
1415
import org.junit.After;
@@ -25,6 +26,8 @@ public abstract class BaseGeneratorTestCase extends BaseProjectTestCase {
2526
protected void setUp() throws Exception {
2627
super.setUp();
2728
myFixture.setTestDataPath(TEST_DATA_FOLDER_PATH);
29+
// Reset changed default code style settings to the previous default settings.
30+
DefaultCodeStyleSettingsAdjustmentsUtil.execute(myFixture.getProject());
2831
}
2932

3033
@Override

0 commit comments

Comments
 (0)