Skip to content

Commit 510ccab

Browse files
authored
[fix] Improve AssertComparisonToSpecificMethodRector for assert false (#594)
* fix test namespace * [fix] Improve AssertComparisonToSpecificMethodRector for assert false
1 parent 52e6944 commit 510ccab

File tree

10 files changed

+85
-21
lines changed

10 files changed

+85
-21
lines changed
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<?php
2+
3+
namespace Rector\PHPUnit\Tests\CodeQuality\Rector\MethodCall\AssertComparisonToSpecificMethodRector\Fixture;
4+
5+
use PHPUnit\Framework\TestCase;
6+
7+
final class AssertFalseGreater extends TestCase
8+
{
9+
public function some(int $param)
10+
{
11+
self::assertFalse($param > 0);
12+
13+
self::assertFalse($param >= 10);
14+
}
15+
}
16+
17+
?>
18+
-----
19+
<?php
20+
21+
namespace Rector\PHPUnit\Tests\CodeQuality\Rector\MethodCall\AssertComparisonToSpecificMethodRector\Fixture;
22+
23+
use PHPUnit\Framework\TestCase;
24+
25+
final class AssertFalseGreater extends TestCase
26+
{
27+
public function some(int $param)
28+
{
29+
self::assertLessThanOrEqual(0, $param);
30+
31+
self::assertLessThan(10, $param);
32+
}
33+
}
34+
35+
?>
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<?php
2+
3+
namespace Rector\PHPUnit\Tests\CodeQuality\Rector\MethodCall\AssertComparisonToSpecificMethodRector\Fixture;
4+
5+
use PHPUnit\Framework\TestCase;
6+
7+
final class AssertFalseSmaller extends TestCase
8+
{
9+
public function some(int $param)
10+
{
11+
self::assertFalse(0 < $param);
12+
13+
self::assertFalse(10 <= $param);
14+
}
15+
}
16+
17+
?>
18+
-----
19+
<?php
20+
21+
namespace Rector\PHPUnit\Tests\CodeQuality\Rector\MethodCall\AssertComparisonToSpecificMethodRector\Fixture;
22+
23+
use PHPUnit\Framework\TestCase;
24+
25+
final class AssertFalseSmaller extends TestCase
26+
{
27+
public function some(int $param)
28+
{
29+
self::assertGreaterThanOrEqual($param, 0);
30+
31+
self::assertGreaterThan($param, 10);
32+
}
33+
}
34+
35+
?>

rules-tests/CodeQuality/Rector/MethodCall/AssertComparisonToSpecificMethodRector/Fixture/assert_true_to_greater_than.php.inc

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

3-
namespace Rector\Tests\PHPUnit\CodeQuality\Rector\MethodCall\AssertComparisonToSpecificMethodRector\Fixture;
3+
namespace Rector\PHPUnit\Tests\CodeQuality\Rector\MethodCall\AssertComparisonToSpecificMethodRector\Fixture;
44

55
use PHPUnit\Framework\TestCase;
66

@@ -17,7 +17,7 @@ final class AssertTrueToGreaterThan extends TestCase
1717
-----
1818
<?php
1919

20-
namespace Rector\Tests\PHPUnit\CodeQuality\Rector\MethodCall\AssertComparisonToSpecificMethodRector\Fixture;
20+
namespace Rector\PHPUnit\Tests\CodeQuality\Rector\MethodCall\AssertComparisonToSpecificMethodRector\Fixture;
2121

2222
use PHPUnit\Framework\TestCase;
2323

rules-tests/CodeQuality/Rector/MethodCall/AssertComparisonToSpecificMethodRector/Fixture/assert_true_to_less_than.php.inc

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

3-
namespace Rector\Tests\PHPUnit\CodeQuality\Rector\MethodCall\AssertComparisonToSpecificMethodRector\Fixture;
3+
namespace Rector\PHPUnit\Tests\CodeQuality\Rector\MethodCall\AssertComparisonToSpecificMethodRector\Fixture;
44

55
use PHPUnit\Framework\TestCase;
66

@@ -17,7 +17,7 @@ final class AssertTrueToLessThan extends TestCase
1717
-----
1818
<?php
1919

20-
namespace Rector\Tests\PHPUnit\CodeQuality\Rector\MethodCall\AssertComparisonToSpecificMethodRector\Fixture;
20+
namespace Rector\PHPUnit\Tests\CodeQuality\Rector\MethodCall\AssertComparisonToSpecificMethodRector\Fixture;
2121

2222
use PHPUnit\Framework\TestCase;
2323

rules-tests/CodeQuality/Rector/MethodCall/AssertEqualsToSameRector/Fixture/skip_if_an_object_is_in_any_level_of_an_array.php.inc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
namespace Rector\PHPUnit\Tests\CodeQuality\Rector\MethodCall\AssertEqualsToSameRector\Fixture;
44

55
use PHPUnit\Framework\TestCase;
6-
use Rector\Tests\PHPUnit\Rector\MethodCall\AssertEqualsToSameRector\Fixture\DateTimeImmutable;
6+
use Rector\PHPUnit\Tests\Rector\MethodCall\AssertEqualsToSameRector\Fixture\DateTimeImmutable;
77

88
final class Test extends TestCase
99
{

rules-tests/PHPUnit60/Rector/ClassMethod/AddDoesNotPerformAssertionToNonAssertingTestRector/Fixture/skip_abstract_method.php.inc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
namespace Rector\Tests\PHPUnit\Rector\ClassMethod\AddDoesNotPerformAssertionToNonAssertingTestRector\Fixture;
3+
namespace Rector\PHPUnit\Tests\Rector\ClassMethod\AddDoesNotPerformAssertionToNonAssertingTestRector\Fixture;
44

55
use PHPUnit\Framework\TestCase;
66

rules-tests/PHPUnit60/Rector/ClassMethod/AddDoesNotPerformAssertionToNonAssertingTestRector/Fixture/skip_call_expect_not_to_perform_assertions_method_call.php.inc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
namespace Rector\Tests\PHPUnit\Rector\ClassMethod\AddDoesNotPerformAssertionToNonAssertingTestRector\Fixture;
3+
namespace Rector\PHPUnit\Tests\Rector\ClassMethod\AddDoesNotPerformAssertionToNonAssertingTestRector\Fixture;
44

55
use Rector\PHPUnit\Tests\PHPUnit60\Rector\ClassMethod\AddDoesNotPerformAssertionToNonAssertingTestRector\Source\Factory;
66

rules-tests/PHPUnit60/Rector/ClassMethod/AddDoesNotPerformAssertionToNonAssertingTestRector/Fixture/skip_mock_expectations.php.inc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
declare(strict_types=1);
44

5-
namespace Rector\Tests\PHPUnit\Rector\ClassMethod\AddDoesNotPerformAssertionToNonAssertingTestRector\Fixture;
5+
namespace Rector\PHPUnit\Tests\Rector\ClassMethod\AddDoesNotPerformAssertionToNonAssertingTestRector\Fixture;
66

77
use PHPUnit\Framework\MockObject\MockObject;
88
use PHPUnit\Framework\TestCase;

rules-tests/PHPUnit60/Rector/MethodCall/GetMockBuilderGetMockToCreateMockRector/Fixture/skip_no_instanceof_testcase.php.inc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
namespace Rector\Tests\PHPUnit\PHPUnit60\Rector\MethodCall\GetMockBuilderGetMockToCreateMockRector\Fixture;
3+
namespace Rector\PHPUnit\Tests\PHPUnit60\Rector\MethodCall\GetMockBuilderGetMockToCreateMockRector\Fixture;
44

55
class MockFactory
66
{

rules/CodeQuality/Rector/MethodCall/AssertComparisonToSpecificMethodRector.php

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -46,18 +46,12 @@ public function __construct(
4646
new BinaryOpWithAssertMethod(NotIdentical::class, 'assertNotSame', 'assertSame'),
4747
new BinaryOpWithAssertMethod(Equal::class, 'assertEquals', 'assertNotEquals'),
4848
new BinaryOpWithAssertMethod(NotEqual::class, 'assertNotEquals', 'assertEquals'),
49-
new BinaryOpWithAssertMethod(Greater::class, 'assertGreaterThan', 'assertLessThan'),
50-
new BinaryOpWithAssertMethod(Smaller::class, 'assertLessThan', 'assertGreaterThan'),
51-
new BinaryOpWithAssertMethod(
52-
GreaterOrEqual::class,
53-
'assertGreaterThanOrEqual',
54-
'assertLessThanOrEqual'
55-
),
56-
new BinaryOpWithAssertMethod(
57-
SmallerOrEqual::class,
58-
'assertLessThanOrEqual',
59-
'assertGreaterThanOrEqual'
60-
),
49+
50+
new BinaryOpWithAssertMethod(Greater::class, 'assertGreaterThan', 'assertLessThanOrEqual'),
51+
new BinaryOpWithAssertMethod(Smaller::class, 'assertLessThan', 'assertGreaterThanOrEqual'),
52+
new BinaryOpWithAssertMethod(GreaterOrEqual::class, 'assertGreaterThanOrEqual', 'assertLessThan'),
53+
54+
new BinaryOpWithAssertMethod(SmallerOrEqual::class, 'assertLessThanOrEqual', 'assertGreaterThan'),
6155
];
6256
}
6357

0 commit comments

Comments
 (0)