Skip to content

Commit 503d801

Browse files
committed
fix: inverse argument order for assertThat rule
1 parent cd506d2 commit 503d801

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

src/Rules/Assertions/AbstractAssertionToExpectation.php

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,15 @@ protected function buildExpect(MethodCall $methodCall): Expr
6262
);
6363
}
6464

65+
private function getActualPosition(): int
66+
{
67+
if ($this->oldName === 'assertThat') {
68+
return 0;
69+
}
70+
71+
return $this->argumentCount >= 3 ? 1 : 0;
72+
}
73+
6574
/**
6675
* Extract the expected arguments.
6776
*
@@ -70,7 +79,7 @@ protected function buildExpect(MethodCall $methodCall): Expr
7079
*/
7180
private function expected(array $args): array
7281
{
73-
$actualPosition = $this->argumentCount >= 3 ? 1 : 0;
82+
$actualPosition = $this->getActualPosition();
7483

7584
unset($args[$actualPosition]);
7685

@@ -84,7 +93,7 @@ private function expected(array $args): array
8493
*/
8594
private function actual(array $args): Arg|VariadicPlaceholder
8695
{
87-
$actualPosition = $this->argumentCount >= 3 ? 1 : 0;
96+
$actualPosition = $this->getActualPosition();
8897

8998
$actualArgument = $args[$actualPosition];
9099

tests/Converters/CodeConverterTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1213,7 +1213,7 @@ public function test_assert_matches_regular_expression()
12131213
class MyTest {
12141214
public function test_assert_that()
12151215
{
1216-
$this->assertThat(new IsTrue(), true);
1216+
$this->assertThat(true, new IsTrue());
12171217
}
12181218
}
12191219
';

0 commit comments

Comments
 (0)