Split object casted to array to assert public properties to standalone assert calls
use PHPUnit\Framework\TestCase;
final class SomeTest extends TestClass
{
public function test()
{
$someObject = new SomeObject();
- $this->assertSame([
- 'name' => 'John',
- 'surname' => 'Doe',
- ], (array) $someObject));
+ $this->assertSame('John', $someObject->name);
+ $this->assertSame('Doe', $someObject->surname);
}
}
Configure your rector.php:
<?php
use Rector\Config\RectorConfig;
use Rector\PHPUnit\CodeQuality\Rector\Expression\AssertArrayCastedObjectToAssertSameRector;
return RectorConfig::configure()
->withRules([
AssertArrayCastedObjectToAssertSameRector::class,
]);