Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php

namespace Rector\PHPUnit\Tests\CodeQuality\Rector\MethodCall\FlipAssertRector\Fixture;

final class ArrayLiteral extends \PHPUnit\Framework\TestCase
{
public function test($result, $model, $response, $transformations)
{
$this->assertSame($response->json(), ['id' => 1, 'status' => SomeEnum::Active]);
}
}

?>
-----
<?php

namespace Rector\PHPUnit\Tests\CodeQuality\Rector\MethodCall\FlipAssertRector\Fixture;

final class ArrayLiteral extends \PHPUnit\Framework\TestCase
{
public function test($result, $model, $response, $transformations)
{
$this->assertSame(['id' => 1, 'status' => SomeEnum::Active], $response->json());
}
}

?>
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php

namespace Rector\PHPUnit\Tests\CodeQuality\Rector\MethodCall\FlipAssertRector\Fixture;

final class ArrayLiteralWithVariable extends \PHPUnit\Framework\TestCase
{
public function test($result, $model, $response, $transformations)
{
$this->assertEquals($model->value, ['transformations' => $transformations]);
}
}

?>
-----
<?php

namespace Rector\PHPUnit\Tests\CodeQuality\Rector\MethodCall\FlipAssertRector\Fixture;

final class ArrayLiteralWithVariable extends \PHPUnit\Framework\TestCase
{
public function test($result, $model, $response, $transformations)
{
$this->assertEquals(['transformations' => $transformations], $model->value);
}
}

?>
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?php

namespace Rector\PHPUnit\Tests\CodeQuality\Rector\MethodCall\FlipAssertRector\Fixture;

final class CanonicalizingAndDelta extends \PHPUnit\Framework\TestCase
{
public function test($result, $model, $response, $transformations)
{
$this->assertEqualsCanonicalizing($result, [1, 2]);
$this->assertNotEqualsCanonicalizing($result, [3, 4]);
$this->assertEqualsIgnoringCase($result, 'expected');
$this->assertNotEqualsIgnoringCase($result, 'other');
$this->assertEqualsWithDelta($result, 1.5, 0.01);
$this->assertNotEqualsWithDelta($result, 2.5, 0.01);
}
}

?>
-----
<?php

namespace Rector\PHPUnit\Tests\CodeQuality\Rector\MethodCall\FlipAssertRector\Fixture;

final class CanonicalizingAndDelta extends \PHPUnit\Framework\TestCase
{
public function test($result, $model, $response, $transformations)
{
$this->assertEqualsCanonicalizing([1, 2], $result);
$this->assertNotEqualsCanonicalizing([3, 4], $result);
$this->assertEqualsIgnoringCase('expected', $result);
$this->assertNotEqualsIgnoringCase('other', $result);
$this->assertEqualsWithDelta(1.5, $result, 0.01);
$this->assertNotEqualsWithDelta(2.5, $result, 0.01);
}
}

?>
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?php

namespace Rector\PHPUnit\Tests\CodeQuality\Rector\MethodCall\FlipAssertRector\Fixture;

final class ConcatLiteral extends \PHPUnit\Framework\TestCase
{
private const PREFIX = 'item';

public function test($result)
{
$this->assertSame($result->getName(), 'foo' . 'bar');
$this->assertSame($result->getPath(), __DIR__ . '/fixture.json');
$this->assertSame($result->getId(), self::PREFIX . '-1');
}
}

?>
-----
<?php

namespace Rector\PHPUnit\Tests\CodeQuality\Rector\MethodCall\FlipAssertRector\Fixture;

final class ConcatLiteral extends \PHPUnit\Framework\TestCase
{
private const PREFIX = 'item';

public function test($result)
{
$this->assertSame('foo' . 'bar', $result->getName());
$this->assertSame(__DIR__ . '/fixture.json', $result->getPath());
$this->assertSame(self::PREFIX . '-1', $result->getId());
}
}

?>
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php

namespace Rector\PHPUnit\Tests\CodeQuality\Rector\MethodCall\FlipAssertRector\Fixture;

final class EnumValue extends \PHPUnit\Framework\TestCase
{
public function test($result)
{
$this->assertSame($result->status, Status::Active->value);
$this->assertSame($result->getStatusName(), Status::Active->name);
}
}

?>
-----
<?php

namespace Rector\PHPUnit\Tests\CodeQuality\Rector\MethodCall\FlipAssertRector\Fixture;

final class EnumValue extends \PHPUnit\Framework\TestCase
{
public function test($result)
{
$this->assertSame(Status::Active->value, $result->status);
$this->assertSame(Status::Active->name, $result->getStatusName());
}
}

?>
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?php

namespace Rector\PHPUnit\Tests\CodeQuality\Rector\MethodCall\FlipAssertRector\Fixture;

final class NegativeNumber extends \PHPUnit\Framework\TestCase
{
private const LIMIT = 10;

public function test($result, $model, $response, $transformations)
{
$this->assertSame($result->getOffset(), -1);
$this->assertSame($result->getMin(), -PHP_INT_MAX);
$this->assertSame($result->getLimit(), -self::LIMIT);
}
}

?>
-----
<?php

namespace Rector\PHPUnit\Tests\CodeQuality\Rector\MethodCall\FlipAssertRector\Fixture;

final class NegativeNumber extends \PHPUnit\Framework\TestCase
{
private const LIMIT = 10;

public function test($result, $model, $response, $transformations)
{
$this->assertSame(-1, $result->getOffset());
$this->assertSame(-PHP_INT_MAX, $result->getMin());
$this->assertSame(-self::LIMIT, $result->getLimit());
}
}

?>
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php

namespace Rector\PHPUnit\Tests\CodeQuality\Rector\MethodCall\FlipAssertRector\Fixture;

final class NewWithLiteralArgs extends \PHPUnit\Framework\TestCase
{
public function test($result)
{
$this->assertEquals($result, new Money(100, Currency::EUR));
$this->assertEquals($result->getPeriod(), new Period(['from' => 1, 'to' => -1]));
}
}

?>
-----
<?php

namespace Rector\PHPUnit\Tests\CodeQuality\Rector\MethodCall\FlipAssertRector\Fixture;

final class NewWithLiteralArgs extends \PHPUnit\Framework\TestCase
{
public function test($result)
{
$this->assertEquals(new Money(100, Currency::EUR), $result);
$this->assertEquals(new Period(['from' => 1, 'to' => -1]), $result->getPeriod());
}
}

?>
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php

namespace Rector\PHPUnit\Tests\CodeQuality\Rector\MethodCall\FlipAssertRector\Fixture;

final class SkipActualArrayLiteral extends \PHPUnit\Framework\TestCase
{
public function test($result, $model, $response, $transformations)
{
$this->assertSame($result, [$model->x, $model->y]);
$this->assertSame($result, [$model->getX()]);
}
}

?>
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

namespace Rector\PHPUnit\Tests\CodeQuality\Rector\MethodCall\FlipAssertRector\Fixture;

final class SkipBothArrayLiteral extends \PHPUnit\Framework\TestCase
{
public function test($result, $model, $response, $transformations)
{
$this->assertSame(['id' => 1], [1, 2]);
}
}

?>
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php

namespace Rector\PHPUnit\Tests\CodeQuality\Rector\MethodCall\FlipAssertRector\Fixture;

final class SkipComputedExpectedAgainstBuiltArray extends \PHPUnit\Framework\TestCase
{
private array $expectedIds = [];

private static array $fixtures = [];

public function test($first, $second, array $expected, $user, $team, $result)
{
$this->assertSame($this->expectedIds, [$first->id, $second->id]);
$this->assertSame($expected['ids'], [$user->id, $team->id]);
$this->assertSame(static::$fixtures, [$result->name]);
}
}

?>
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

namespace Rector\PHPUnit\Tests\CodeQuality\Rector\MethodCall\FlipAssertRector\Fixture;

final class SkipConcatWithVariable extends \PHPUnit\Framework\TestCase
{
public function test($result, $id)
{
$this->assertSame($result->getId(), 'id-' . $id);
}
}

?>
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php

namespace Rector\PHPUnit\Tests\CodeQuality\Rector\MethodCall\FlipAssertRector\Fixture;

final class SkipCorrectCanonicalizing extends \PHPUnit\Framework\TestCase
{
public function test($result, $model, $response, $transformations)
{
$this->assertEqualsCanonicalizing([1, 2], $result);
$this->assertEqualsWithDelta(1.5, $result, 0.01);
}
}

?>
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php

namespace Rector\PHPUnit\Tests\CodeQuality\Rector\MethodCall\FlipAssertRector\Fixture;

final class SkipEnumValueFirst extends \PHPUnit\Framework\TestCase
{
public function test($result, $status, $x)
{
$this->assertSame(Status::Active->value, [$x]);
$this->assertSame($result->status, $status->value);
}
}

?>
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

namespace Rector\PHPUnit\Tests\CodeQuality\Rector\MethodCall\FlipAssertRector\Fixture;

final class SkipNamedArgs extends \PHPUnit\Framework\TestCase
{
public function test($result)
{
$this->assertSame(expected: $result->ids(), actual: [1, 2]);
}
}

?>
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php

namespace Rector\PHPUnit\Tests\CodeQuality\Rector\MethodCall\FlipAssertRector\Fixture;

final class SkipNewWithVariableArg extends \PHPUnit\Framework\TestCase
{
public function test($result, $amount, $className, array $args)
{
$this->assertEquals($result, new Money($amount));
$this->assertEquals($result, new $className(100));
$this->assertEquals($result, new Money(...$args));
$this->assertEquals($result, new Money(amount: 100));
$this->assertEquals($result, new class(100) {
public function __construct(public int $amount)
{
}
});
}
}

?>
Loading
Loading