Skip to content

Commit 1c65958

Browse files
committed
Refactored custom fixer tests
1 parent 32312bd commit 1c65958

13 files changed

Lines changed: 48 additions & 41 deletions

tests/Fixer/AlignedArrayValuesFixerTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public function test_NonAssociativeArrays_AreNotChanged()
3030

3131
CODE;
3232

33-
$this->assertSame($code, $this->runner->fix($code));
33+
$this->assertUnchanged($code);
3434
}
3535

3636
public function test_SingleLineArrays_AreNotChanged()
@@ -42,7 +42,7 @@ public function test_SingleLineArrays_AreNotChanged()
4242

4343
CODE;
4444

45-
$this->assertSame($code, $this->runner->fix($code));
45+
$this->assertUnchanged($code);
4646
}
4747

4848
public function test_MultilineArrays_AreAligned()
@@ -71,7 +71,7 @@ public function test_MultilineArrays_AreAligned()
7171

7272
CODE;
7373

74-
$this->assertSame($expected, $this->runner->fix($code));
74+
$this->assertFixed($code, $expected);
7575
}
7676

7777
public function test_NotExclusivelyMultilineArrays_AreNotChanged()
@@ -88,7 +88,7 @@ public function test_NotExclusivelyMultilineArrays_AreNotChanged()
8888

8989
CODE;
9090

91-
$this->assertSame($code, $this->runner->fix($code));
91+
$this->assertUnchanged($code);
9292
}
9393

9494
protected function fixer(): FixerInterface

tests/Fixer/AlignedAssignmentsFixerTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public function test_VariableAssignments_AreAligned()
3838

3939
CODE;
4040

41-
$this->assertSame($expected, $this->runner->fix($code));
41+
$this->assertFixed($code, $expected);
4242
}
4343

4444
public function test_MixedKindVariableAssignments_AreAlignedSeparately()
@@ -73,7 +73,7 @@ public function test_MixedKindVariableAssignments_AreAlignedSeparately()
7373

7474
CODE;
7575

76-
$this->assertSame($expected, $this->runner->fix($code));
76+
$this->assertFixed($code, $expected);
7777
}
7878

7979
public function test_MultilineAssignment_IsNotAligned()
@@ -89,7 +89,7 @@ public function test_MultilineAssignment_IsNotAligned()
8989

9090
CODE;
9191

92-
$this->assertSame($code, $this->runner->fix($code));
92+
$this->assertUnchanged($code);
9393
}
9494

9595
protected function fixer(): FixerInterface

tests/Fixer/AlignedMethodChainFixerTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public function test_SingleLineChainCalls_AreNotChanged()
2727

2828
CODE;
2929

30-
$this->assertSame($code, $this->runner->fix($code));
30+
$this->assertUnchanged($code);
3131
}
3232

3333
public function test_LineBreakChainCalls_AreExpandedAndAligned()
@@ -53,7 +53,7 @@ public function test_LineBreakChainCalls_AreExpandedAndAligned()
5353

5454
CODE;
5555

56-
$this->assertSame($expected, $this->runner->fix($code));
56+
$this->assertFixed($code, $expected);
5757
}
5858

5959
public function test_NestedMultilineChains_AreAligned()
@@ -80,7 +80,7 @@ public function test_NestedMultilineChains_AreAligned()
8080

8181
CODE;
8282

83-
$this->assertSame($expected, $this->runner->fix($code));
83+
$this->assertFixed($code, $expected);
8484
}
8585

8686
public function test_CodeWithoutObjectOperator_IsSkipped()
@@ -92,7 +92,7 @@ public function test_CodeWithoutObjectOperator_IsSkipped()
9292

9393
CODE;
9494

95-
$this->assertSame($code, $this->runner->fix($code));
95+
$this->assertUnchanged($code);
9696
}
9797

9898
protected function fixer(): AlignedMethodChainFixer

tests/Fixer/AlignedTypedPropertiesFixerTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ public function __construct(ExampleClass $self)
8888

8989
CODE;
9090

91-
$this->assertSame($expected, $this->runner->fix($code));
91+
$this->assertFixed($code, $expected);
9292
}
9393

9494
protected function fixer(): FixerInterface

tests/Fixer/BraceAfterFunctionFixerTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ function withSomething(Test $value) {
3838

3939
CODE;
4040

41-
$this->assertSame($expected, $this->runner->fix($code));
41+
$this->assertFixed($code, $expected);
4242
}
4343

4444
public function test_MethodBracesFromNextLine_AreMoved()
@@ -66,7 +66,7 @@ public function withSomething(string $value): Type {
6666

6767
CODE;
6868

69-
$this->assertSame($expected, $this->runner->fix($code));
69+
$this->assertFixed($code, $expected);
7070
}
7171

7272
public function test_UnusualMethodFormatting_IsFixed()
@@ -102,7 +102,7 @@ public function GetType(string $value):Type {
102102

103103
CODE;
104104

105-
$this->assertSame($expected, $this->runner->fix($code));
105+
$this->assertFixed($code, $expected);
106106
}
107107

108108
protected function fixer(): BraceAfterFunctionFixer

tests/Fixer/BraceAfterMultilineParamMethodFixerTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public function withSomething(string $value, array $another): Type
2828

2929
CODE);
3030

31-
$this->assertSame($code, $this->runner->fix($code));
31+
$this->assertUnchanged($code);
3232
}
3333

3434
public function test_MultilineDefinition_BraceFromNextLine_IsFixed()
@@ -56,7 +56,7 @@ public function withSomething(
5656

5757
CODE, 'trait');
5858

59-
$this->assertSame($expected, $this->runner->fix($code));
59+
$this->assertFixed($code, $expected);
6060
}
6161

6262
public function test_MultilineDefinition_MissingWhitespace_IsFixed()
@@ -83,7 +83,7 @@ public function withSomething(
8383

8484
CODE);
8585

86-
$this->assertSame($expected, $this->runner->fix($code));
86+
$this->assertFixed($code, $expected);
8787
}
8888

8989
public function test_AbstractMultilineDefinition_DoesNotAffectNextMethod()
@@ -102,7 +102,7 @@ public function withSomething(string $value): Type
102102

103103
CODE);
104104

105-
$this->assertSame($code, $this->runner->fix($code));
105+
$this->assertUnchanged($code);
106106
}
107107

108108
protected function fixer(): BraceAfterMultilineParamMethodFixer

tests/Fixer/DeclareStrictFirstLineFixerTest.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public function test_FileWithoutDeclare_IsUnchanged()
2727

2828
CODE;
2929

30-
$this->assertSame($code, $this->runner->fix($code));
30+
$this->assertUnchanged($code);
3131
}
3232

3333
public function test_FileWithDeclareInFirstLine_IsUnchanged()
@@ -39,7 +39,7 @@ public function test_FileWithDeclareInFirstLine_IsUnchanged()
3939

4040
CODE;
4141

42-
$this->assertSame($code, $this->runner->fix($code));
42+
$this->assertUnchanged($code);
4343
}
4444

4545
public function test_FileWithDifferentDeclare_IsUnchanged()
@@ -52,7 +52,7 @@ public function test_FileWithDifferentDeclare_IsUnchanged()
5252

5353
CODE;
5454

55-
$this->assertSame($code, $this->runner->fix($code));
55+
$this->assertUnchanged($code);
5656
}
5757

5858
public function test_DeclareNotInFirstLine_IsMoved()
@@ -72,7 +72,7 @@ public function test_DeclareNotInFirstLine_IsMoved()
7272

7373
CODE;
7474

75-
$this->assertSame($expected, $this->runner->fix($code));
75+
$this->assertFixed($code, $expected);
7676
}
7777

7878
public function test_DeclareNotInFirstLine_IsMovedWIthFollowingWhitespace()
@@ -95,7 +95,7 @@ public function test_DeclareNotInFirstLine_IsMovedWIthFollowingWhitespace()
9595

9696
CODE;
9797

98-
$this->assertSame($expected, $this->runner->fix($code));
98+
$this->assertFixed($code, $expected);
9999
}
100100

101101
protected function fixer(): FixerInterface

tests/Fixer/DoubleLineBeforeClassDefinitionFixerTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public function __construct(ExampleClass $self)
6060

6161
CODE;
6262

63-
$this->assertSame($expected, $this->runner->fix($code));
63+
$this->assertFixed($code, $expected);
6464
}
6565

6666
public function test_TwoEmptyLinesBeforeClassDefinition_AreInserted()
@@ -89,7 +89,7 @@ private function doSomething(): void;
8989

9090
CODE;
9191

92-
$this->assertSame($expected, $this->runner->fix($code));
92+
$this->assertFixed($code, $expected);
9393
}
9494

9595
protected function fixer(): DoubleLineBeforeClassDefinitionFixer

tests/Fixer/MultiOrderedClassElementsFixerTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ public function someMethod() {}
8484

8585
CODE;
8686

87-
$this->assertSame($expected, $this->runner->fix($code));
87+
$this->assertFixed($code, $expected);
8888
}
8989

9090
public function test_ClassWithTestName_IsOrderedWithTestConfig()
@@ -161,7 +161,7 @@ private static function assertSomething(): void {}
161161

162162
CODE;
163163

164-
$this->assertSame($expected, $this->runner->fix($code));
164+
$this->assertFixed($code, $expected);
165165
}
166166

167167
protected function fixer(): FixerInterface

tests/Fixer/NamedConstructorsFirstStaticFixerTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ public static function notConstructor(): SomeType
9797

9898
CODE;
9999

100-
$this->assertSame($expected, $this->runner->fix($code));
100+
$this->assertFixed($code, $expected);
101101
}
102102

103103
public function test_OnlyConstructorMethods_AreMoved()
@@ -170,7 +170,7 @@ public static function notConstructor(): SomeType
170170

171171
CODE;
172172

173-
$this->assertSame($expected, $this->runner->fix($code));
173+
$this->assertFixed($code, $expected);
174174
}
175175

176176
protected function fixer(): NamedConstructorsFirstStaticFixer

0 commit comments

Comments
 (0)