diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 383c31f4..1560c418 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -22,7 +22,7 @@ jobs: uses: "shivammathur/setup-php@v2" with: coverage: "none" - php-version: "8.0" + php-version: "8.4" extensions: pdo, pdo_sqlite - name: "Validate composer.json" @@ -37,6 +37,9 @@ jobs: composer-options: "--prefer-stable" dependency-versions: 'highest' + - name: "Trigger install for PHPUnit dependencies" + run: "vendor/bin/simple-phpunit --version" + - name: "PHPStan" run: "vendor/bin/phpstan analyze" diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon new file mode 100644 index 00000000..2d9f8421 --- /dev/null +++ b/phpstan-baseline.neon @@ -0,0 +1,31 @@ +parameters: + ignoreErrors: + - + message: "#^Class Doctrine\\\\ORM\\\\Mapping\\\\ClassMetadataInfo not found\\.$#" + count: 1 + path: src/Command/AbstractCommand.php + + - + message: "#^Class Doctrine\\\\ORM\\\\Mapping\\\\ClassMetadataInfo not found\\.$#" + count: 1 + path: src/Command/DoctrineDecryptDatabaseCommand.php + + - + message: "#^Class Doctrine\\\\ORM\\\\Mapping\\\\ClassMetadataInfo not found\\.$#" + count: 1 + path: src/Command/DoctrineEncryptStatusCommand.php + + - + message: "#^Call to an undefined static method Doctrine\\\\ORM\\\\EntityManager\\:\\:create\\(\\)\\.$#" + count: 1 + path: tests/Functional/AbstractFunctionalTestCase.php + + - + message: "#^Call to static method createAnnotationMetadataConfiguration\\(\\) on an unknown class Doctrine\\\\ORM\\\\Tools\\\\Setup\\.$#" + count: 1 + path: tests/Functional/AbstractFunctionalTestCase.php + + - + message: "#^Instantiated class Doctrine\\\\DBAL\\\\Logging\\\\DebugStack not found\\.$#" + count: 1 + path: tests/Functional/AbstractFunctionalTestCase.php diff --git a/phpstan.neon.dist b/phpstan.neon.dist index a034052c..a1281fa4 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -1,6 +1,9 @@ +includes: + - phpstan-baseline.neon + parameters: level: 0 paths: - src - #- tests + - tests tmpDir: .phpstan-cache diff --git a/src/Command/AbstractCommand.php b/src/Command/AbstractCommand.php index a5ceb6e7..ba796f69 100644 --- a/src/Command/AbstractCommand.php +++ b/src/Command/AbstractCommand.php @@ -7,6 +7,7 @@ use Doctrine\Common\Annotations\Reader; use Doctrine\ORM\EntityManager; use Doctrine\ORM\EntityManagerInterface; +use Doctrine\ORM\Mapping\ClassMetadata; use Doctrine\ORM\Mapping\ClassMetadataInfo; use Symfony\Component\Console\Command\Command; @@ -81,7 +82,7 @@ protected function getEncryptionableEntityMetaData(): array $metaDataArray = $this->entityManager->getMetadataFactory()->getAllMetadata(); foreach ($metaDataArray as $entityMetaData) { - if ($entityMetaData instanceof ClassMetadataInfo and $entityMetaData->isMappedSuperclass) { + if (($entityMetaData instanceof ClassMetadataInfo || $entityMetaData instanceof ClassMetadata) && $entityMetaData->isMappedSuperclass) { continue; } diff --git a/src/Command/DoctrineDecryptDatabaseCommand.php b/src/Command/DoctrineDecryptDatabaseCommand.php index 975aeb56..77bacc5e 100644 --- a/src/Command/DoctrineDecryptDatabaseCommand.php +++ b/src/Command/DoctrineDecryptDatabaseCommand.php @@ -3,6 +3,7 @@ namespace Ambta\DoctrineEncryptBundle\Command; use Ambta\DoctrineEncryptBundle\DependencyInjection\DoctrineEncryptExtension; +use Doctrine\ORM\Mapping\ClassMetadata; use Doctrine\ORM\Mapping\ClassMetadataInfo; use Symfony\Component\Console\Helper\ProgressBar; use Symfony\Component\Console\Input\InputArgument; @@ -63,7 +64,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int // Set counter and loop through entity manager meta data $propertyCount = 0; foreach ($metaDataArray as $metaData) { - if ($metaData instanceof ClassMetadataInfo and $metaData->isMappedSuperclass) { + if (($metaData instanceof ClassMetadataInfo || $metaData instanceof ClassMetadata) && $metaData->isMappedSuperclass) { continue; } diff --git a/src/Command/DoctrineEncryptStatusCommand.php b/src/Command/DoctrineEncryptStatusCommand.php index 1eeb412d..4fd6e613 100644 --- a/src/Command/DoctrineEncryptStatusCommand.php +++ b/src/Command/DoctrineEncryptStatusCommand.php @@ -2,6 +2,7 @@ namespace Ambta\DoctrineEncryptBundle\Command; +use Doctrine\ORM\Mapping\ClassMetadata; use Doctrine\ORM\Mapping\ClassMetadataInfo; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; @@ -27,7 +28,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int $totalCount = 0; foreach ($metaDataArray as $metaData) { - if ($metaData instanceof ClassMetadataInfo && $metaData->isMappedSuperclass) { + if (($metaData instanceof ClassMetadataInfo || $metaData instanceof ClassMetadata) && $metaData->isMappedSuperclass) { continue; } diff --git a/tests/Functional/AbstractFunctionalTestCase.php b/tests/Functional/AbstractFunctionalTestCase.php index 0d95d6b9..a482f7aa 100644 --- a/tests/Functional/AbstractFunctionalTestCase.php +++ b/tests/Functional/AbstractFunctionalTestCase.php @@ -237,9 +237,9 @@ protected function resetQueryStack(): void */ public function assertStringDoesNotContain($needle, $string, $ignoreCase = false, $message = ''): void { - $this->assertIsString($needle, $message); - $this->assertIsString($string, $message); - $this->assertIsBool($ignoreCase, $message); + static::assertIsString($needle, $message); + static::assertIsString($string, $message); + static::assertIsBool($ignoreCase, $message); $constraint = new LogicalNot(new StringContains( $needle, diff --git a/tests/Functional/BasicQueryTest/AbstractBasicQueryTestCase.php b/tests/Functional/BasicQueryTest/AbstractBasicQueryTestCase.php index e7024c6b..ead30241 100644 --- a/tests/Functional/BasicQueryTest/AbstractBasicQueryTestCase.php +++ b/tests/Functional/BasicQueryTest/AbstractBasicQueryTestCase.php @@ -18,44 +18,44 @@ public function testPersistEntity(): void $this->entityManager->flush(); // Start transaction; insert; commit - $this->assertEquals('top secret information', $user->getSecret()); - $this->assertEquals(3, $this->getCurrentQueryCount()); + static::assertEquals('top secret information', $user->getSecret()); + static::assertEquals(3, $this->getCurrentQueryCount()); } public function testNoUpdateOnReadEncrypted(): void { $this->entityManager->beginTransaction(); - $this->assertEquals(1, $this->getCurrentQueryCount()); + static::assertEquals(1, $this->getCurrentQueryCount()); $user = new CascadeTarget(); $user->setNotSecret('My public information'); $user->setSecret('top secret information'); $this->entityManager->persist($user); $this->entityManager->flush(); - $this->assertEquals(2, $this->getCurrentQueryCount()); + static::assertEquals(2, $this->getCurrentQueryCount()); // Test if no query is executed when doing nothing $this->entityManager->flush(); - $this->assertEquals(2, $this->getCurrentQueryCount()); + static::assertEquals(2, $this->getCurrentQueryCount()); // Test if no query is executed when reading unrelated field $user->getNotSecret(); $this->entityManager->flush(); - $this->assertEquals(2, $this->getCurrentQueryCount()); + static::assertEquals(2, $this->getCurrentQueryCount()); // Test if no query is executed when reading related field and if field is valid - $this->assertEquals('top secret information', $user->getSecret()); + static::assertEquals('top secret information', $user->getSecret()); $this->entityManager->flush(); - $this->assertEquals(2, $this->getCurrentQueryCount()); + static::assertEquals(2, $this->getCurrentQueryCount()); // Test if 1 query is executed when updating entity $user->setSecret('top secret information change'); $this->entityManager->flush(); - $this->assertEquals(3, $this->getCurrentQueryCount()); - $this->assertEquals('top secret information change', $user->getSecret()); + static::assertEquals(3, $this->getCurrentQueryCount()); + static::assertEquals('top secret information change', $user->getSecret()); $this->entityManager->rollback(); - $this->assertEquals(4, $this->getCurrentQueryCount()); + static::assertEquals(4, $this->getCurrentQueryCount()); } public function testStoredDataIsEncrypted(): void @@ -92,7 +92,7 @@ public function testNoUpdateForUnalteredChildrenOfAbstractEntities() $this->entityManager->flush(); // start transaction, insert, commit - $this->assertEquals(3, $this->getCurrentQueryCount()); + static::assertEquals(3, $this->getCurrentQueryCount()); // Remove all logged queries $this->resetQueryStack(); @@ -103,6 +103,6 @@ public function testNoUpdateForUnalteredChildrenOfAbstractEntities() // Verify there are no queries executed $this->assertNull($this->getLatestUpdateQuery()); - $this->assertEquals(0, $this->getCurrentQueryCount()); + static::assertEquals(0, $this->getCurrentQueryCount()); } } diff --git a/tests/Functional/BasicQueryTest/BasicQueryHaliteTest.php b/tests/Functional/BasicQueryTest/BasicQueryHaliteTest.php index 97c79c5b..9ade995d 100644 --- a/tests/Functional/BasicQueryTest/BasicQueryHaliteTest.php +++ b/tests/Functional/BasicQueryTest/BasicQueryHaliteTest.php @@ -15,7 +15,7 @@ protected function getEncryptor(): EncryptorInterface public function setUp(): void { if (!extension_loaded('sodium') && !class_exists('ParagonIE_Sodium_Compat')) { - $this->markTestSkipped('This test only runs when the sodium extension is enabled.'); + static::markTestSkipped('This test only runs when the sodium extension is enabled.'); return; } diff --git a/tests/Functional/DoctrineEncryptSubscriber/AbstractDoctrineEncryptSubscriberTestCase.php b/tests/Functional/DoctrineEncryptSubscriber/AbstractDoctrineEncryptSubscriberTestCase.php index a124b403..d21c3719 100644 --- a/tests/Functional/DoctrineEncryptSubscriber/AbstractDoctrineEncryptSubscriberTestCase.php +++ b/tests/Functional/DoctrineEncryptSubscriber/AbstractDoctrineEncryptSubscriberTestCase.php @@ -33,20 +33,20 @@ public function testEncryptionHappensOnOnlyAnnotatedFields(): void $connection = $em->getConnection(); $stmt = $connection->prepare('SELECT * from owner WHERE id = ?'); $owners = $em->getRepository(Owner::class)->findAll(); - $this->assertCount(1, $owners); + static::assertCount(1, $owners); /** @var Owner $owner */ $owner = $owners[0]; - $this->assertEquals($secret, $owner->getSecret()); - $this->assertEquals($notSecret, $owner->getNotSecret()); + static::assertEquals($secret, $owner->getSecret()); + static::assertEquals($notSecret, $owner->getNotSecret()); $stmt->bindValue(1, $owner->getId()); $results = $this->executeStatementFetchAll($stmt); $this->assertCount(1, $results); $result = $results[0]; - $this->assertEquals($notSecret, $result['notSecret']); + static::assertEquals($notSecret, $result['notSecret']); $this->assertNotEquals($secret, $result['secret']); $this->assertStringEndsWith('', $result['secret']); $decrypted = $this->encryptor->decrypt(str_replace('', '', $result['secret'])); - $this->assertEquals($secret, $decrypted); + static::assertEquals($secret, $decrypted); } public function testEncryptionCascades(): void @@ -73,17 +73,17 @@ public function testEncryptionCascades(): void $this->assertCount(1, $cascadeTargets); /** @var CascadeTarget $cascadeTarget */ $cascadeTarget = $cascadeTargets[0]; - $this->assertEquals($secret, $cascadeTarget->getSecret()); - $this->assertEquals($notSecret, $cascadeTarget->getNotSecret()); + static::assertEquals($secret, $cascadeTarget->getSecret()); + static::assertEquals($notSecret, $cascadeTarget->getNotSecret()); $stmt->bindValue(1, $cascadeTarget->getId()); $results = $this->executeStatementFetchAll($stmt); $this->assertCount(1, $results); $result = $results[0]; - $this->assertEquals($notSecret, $result['notSecret']); + static::assertEquals($notSecret, $result['notSecret']); $this->assertNotEquals($secret, $result['secret']); $this->assertStringEndsWith('', $result['secret']); $decrypted = $this->encryptor->decrypt(str_replace('', '', $result['secret'])); - $this->assertEquals($secret, $decrypted); + static::assertEquals($secret, $decrypted); } public function testEncryptionClassTableInheritance(): void @@ -171,8 +171,8 @@ public function testEncryptionDoesNotHappenWhenThereIsNoChange(): void $owners = $em->getRepository(Owner::class)->findAll(); /** @var Owner $owner */ foreach ($owners as $owner) { - $this->assertEquals($secret, $owner->getSecret()); - $this->assertEquals($notSecret, $owner->getNotSecret()); + static::assertEquals($secret, $owner->getSecret()); + static::assertEquals($notSecret, $owner->getNotSecret()); } $this->resetQueryStack(); $this->assertCount(0, $this->getDebugQueries()); @@ -180,7 +180,7 @@ public function testEncryptionDoesNotHappenWhenThereIsNoChange(): void $em->flush(); $afterFlush = $this->subscriber->encryptCounter; // No encryption should have happened because we didn't change anything. - $this->assertEquals($beforeFlush, $afterFlush); + static::assertEquals($beforeFlush, $afterFlush); // No queries happened because we didn't change anything. $this->assertCount(0, $this->getDebugQueries(), "Unexpected queries:\n".var_export($this->getDebugQueries(), true)); @@ -189,7 +189,7 @@ public function testEncryptionDoesNotHappenWhenThereIsNoChange(): void $em->flush(); $afterFlush = $this->subscriber->encryptCounter; // No encryption should have happened because we didn't change anything. - $this->assertEquals($beforeFlush, $afterFlush); + static::assertEquals($beforeFlush, $afterFlush); // No queries happened because we didn't change anything. $this->assertCount(0, $this->getDebugQueries(), "Unexpected queries:\n".var_export($this->getDebugQueries(), true)); @@ -199,7 +199,7 @@ public function testEncryptionDoesNotHappenWhenThereIsNoChange(): void $result = $results[0]; $shouldBeTheSameAsBefore = $result['secret']; $this->assertStringEndsWith('', $shouldBeTheSameAsBefore); // is encrypted - $this->assertEquals($originalEncryption, $shouldBeTheSameAsBefore); + static::assertEquals($originalEncryption, $shouldBeTheSameAsBefore); } public function testEncryptionDoesNotHappenWhenThereIsNoChangeClassInheritance(): void @@ -332,7 +332,7 @@ public function testEntitySetterUseStrtoupper() $this->assertStringEndsWith(DoctrineEncryptSubscriber::ENCRYPTION_MARKER, $passwordData); $this->assertStringDoesNotContain('my secret', $passwordData); - $this->assertEquals('MY SECRET', $secret); + static::assertEquals('MY SECRET', $secret); } public function testEntityWithDateTimeJsonAndArrayProperties() @@ -361,7 +361,7 @@ public function testEntityWithDateTimeJsonAndArrayProperties() // Doctrine datetime type is only for date and time. milliseconds and timezone is not stored. // We only test the date and time accordingly // https://www.doctrine-project.org/projects/doctrine-dbal/en/3.7/reference/types.html#datetime - $this->assertEquals($datetime->format('Y-m-d\\TH:i:s'), $entityDate->format('Y-m-d\\TH:i:s')); - $this->assertEquals($jsonArray, $entityJson); + static::assertEquals($datetime->format('Y-m-d\\TH:i:s'), $entityDate->format('Y-m-d\\TH:i:s')); + static::assertEquals($jsonArray, $entityJson); } } diff --git a/tests/Functional/DoctrineEncryptSubscriber/DoctrineEncryptSubscriberHaliteTest.php b/tests/Functional/DoctrineEncryptSubscriber/DoctrineEncryptSubscriberHaliteTest.php index dd29d8b7..2a94ff71 100644 --- a/tests/Functional/DoctrineEncryptSubscriber/DoctrineEncryptSubscriberHaliteTest.php +++ b/tests/Functional/DoctrineEncryptSubscriber/DoctrineEncryptSubscriberHaliteTest.php @@ -15,7 +15,7 @@ protected function getEncryptor(): EncryptorInterface public function setUp(): void { if (!extension_loaded('sodium') && !class_exists('ParagonIE_Sodium_Compat')) { - $this->markTestSkipped('This test only runs when the sodium extension is enabled.'); + static::markTestSkipped('This test only runs when the sodium extension is enabled.'); return; } diff --git a/tests/Unit/DependencyInjection/DoctrineEncryptExtensionTest.php b/tests/Unit/DependencyInjection/DoctrineEncryptExtensionTest.php index 5447d6f9..27d1f05f 100644 --- a/tests/Unit/DependencyInjection/DoctrineEncryptExtensionTest.php +++ b/tests/Unit/DependencyInjection/DoctrineEncryptExtensionTest.php @@ -41,7 +41,7 @@ public function testConfigLoadHaliteByDefault(): void $container = $this->createContainer(); $this->extension->load([[]], $container); - $this->assertSame(HaliteEncryptor::class, $container->getParameter('ambta_doctrine_encrypt.encryptor_class_name')); + static::assertSame(HaliteEncryptor::class, $container->getParameter('ambta_doctrine_encrypt.encryptor_class_name')); } public function testConfigLoadHalite(): void @@ -52,7 +52,7 @@ public function testConfigLoadHalite(): void ]; $this->extension->load([$config], $container); - $this->assertSame(HaliteEncryptor::class, $container->getParameter('ambta_doctrine_encrypt.encryptor_class_name')); + static::assertSame(HaliteEncryptor::class, $container->getParameter('ambta_doctrine_encrypt.encryptor_class_name')); } public function testConfigLoadDefuse(): void @@ -64,7 +64,7 @@ public function testConfigLoadDefuse(): void ]; $this->extension->load([$config], $container); - $this->assertSame(DefuseEncryptor::class, $container->getParameter('ambta_doctrine_encrypt.encryptor_class_name')); + static::assertSame(DefuseEncryptor::class, $container->getParameter('ambta_doctrine_encrypt.encryptor_class_name')); } public function testConfigLoadCustomEncryptor(): void @@ -75,7 +75,7 @@ public function testConfigLoadCustomEncryptor(): void ]; $this->extension->load([$config], $container); - $this->assertSame(self::class, $container->getParameter('ambta_doctrine_encrypt.encryptor_class_name')); + static::assertSame(self::class, $container->getParameter('ambta_doctrine_encrypt.encryptor_class_name')); } public function testConfigImpossibleToUseSecretAndSecretDirectoryPath(): void @@ -99,10 +99,10 @@ public function testConfigUseSecret(): void ]; $this->extension->load([$config], $container); - $this->assertIsString($container->getParameter('ambta_doctrine_encrypt.secret')); + static::assertIsString($container->getParameter('ambta_doctrine_encrypt.secret')); $this->assertStringNotContainsString('Halite', $container->getParameter('ambta_doctrine_encrypt.secret')); $this->assertStringNotContainsString('.key', $container->getParameter('ambta_doctrine_encrypt.secret')); - $this->assertEquals('my-secret', $container->getParameter('ambta_doctrine_encrypt.secret')); + static::assertEquals('my-secret', $container->getParameter('ambta_doctrine_encrypt.secret')); } public function testHaliteSecretIsCreatedWhenSecretFileDoesNotExistAndSecretCreationIsEnabled(): void @@ -120,9 +120,9 @@ public function testHaliteSecretIsCreatedWhenSecretFileDoesNotExistAndSecretCrea } else { $actualSecret = $secretArgument; } - $this->assertIsString($actualSecret); + static::assertIsString($actualSecret); $actualSecretOnDisk = file_get_contents($this->temporaryDirectory.DIRECTORY_SEPARATOR.'.Halite.key'); - $this->assertEquals($actualSecret, $actualSecretOnDisk); + static::assertEquals($actualSecret, $actualSecretOnDisk); try { KeyFactory::importEncryptionKey(new HiddenString($actualSecret)); @@ -147,9 +147,9 @@ public function testDefuseSecretIsCreatedWhenSecretFileDoesNotExistAndSecretCrea } else { $actualSecret = $secretArgument; } - $this->assertIsString($actualSecret); + static::assertIsString($actualSecret); $actualSecretOnDisk = file_get_contents($this->temporaryDirectory.DIRECTORY_SEPARATOR.'.Defuse.key'); - $this->assertEquals($actualSecret, $actualSecretOnDisk); + static::assertEquals($actualSecret, $actualSecretOnDisk); if (strlen(hex2bin($actualSecret)) !== 255) { $this->fail('Generated key is not valid'); @@ -199,8 +199,8 @@ public function testSecretsAreReadFromFile(): void } else { $actualSecret = $secretArgument; } - $this->assertIsString($actualSecret); - $this->assertEquals($expectedSecret, $actualSecret); + static::assertIsString($actualSecret); + static::assertEquals($expectedSecret, $actualSecret); } /** diff --git a/tests/Unit/Encryptors/DefuseEncryptorTest.php b/tests/Unit/Encryptors/DefuseEncryptorTest.php index 71933c88..3729113f 100644 --- a/tests/Unit/Encryptors/DefuseEncryptorTest.php +++ b/tests/Unit/Encryptors/DefuseEncryptorTest.php @@ -33,9 +33,9 @@ public function testEncrypt(): void $this->assertNotSame(self::DATA, $encrypted); $decrypted = $defuse->decrypt($encrypted); - $this->assertSame(self::DATA, $decrypted); + static::assertSame(self::DATA, $decrypted); $newkey = file_get_contents($keyfile); - $this->assertSame($key, $newkey, 'The key must not be modified'); + static::assertSame($key, $newkey, 'The key must not be modified'); } public function testEncryptorThrowsOwnExceptionWhenExceptionsAreNotWrapped(): void diff --git a/tests/Unit/Encryptors/HaliteEncryptorTest.php b/tests/Unit/Encryptors/HaliteEncryptorTest.php index 4bd15d4b..b3e88c14 100644 --- a/tests/Unit/Encryptors/HaliteEncryptorTest.php +++ b/tests/Unit/Encryptors/HaliteEncryptorTest.php @@ -27,7 +27,7 @@ protected function tearDown(): void public function testEncryptExtension(): void { if (!extension_loaded('sodium') && !class_exists('ParagonIE_Sodium_Compat')) { - $this->markTestSkipped('This test only runs when the sodium extension is enabled.'); + static::markTestSkipped('This test only runs when the sodium extension is enabled.'); } $keyfile = __DIR__.'/fixtures/halite.key'; $key = file_get_contents($keyfile); @@ -37,7 +37,7 @@ public function testEncryptExtension(): void $this->assertNotSame(self::DATA, $encrypted); $decrypted = $halite->decrypt($encrypted); - $this->assertSame(self::DATA, $decrypted); + static::assertSame(self::DATA, $decrypted); } public function testEncryptorThrowsOwnExceptionWhenExceptionsAreNotWrapped(): void diff --git a/tests/Unit/Subscribers/DoctrineEncryptSubscriberTest.php b/tests/Unit/Subscribers/DoctrineEncryptSubscriberTest.php index 866b2eb8..c50b9829 100644 --- a/tests/Unit/Subscribers/DoctrineEncryptSubscriberTest.php +++ b/tests/Unit/Subscribers/DoctrineEncryptSubscriberTest.php @@ -116,11 +116,11 @@ public function testSetRestorEncryptor(): void { $replaceEncryptor = $this->createMock(EncryptorInterface::class); - $this->assertSame($this->encryptor, $this->subscriber->getEncryptor()); + static::assertSame($this->encryptor, $this->subscriber->getEncryptor()); $this->subscriber->setEncryptor($replaceEncryptor); - $this->assertSame($replaceEncryptor, $this->subscriber->getEncryptor()); + static::assertSame($replaceEncryptor, $this->subscriber->getEncryptor()); $this->subscriber->restoreEncryptor(); - $this->assertSame($this->encryptor, $this->subscriber->getEncryptor()); + static::assertSame($this->encryptor, $this->subscriber->getEncryptor()); } private function triggerProcessFields(object $entity, bool $encrypt) @@ -159,7 +159,7 @@ public function testProcessFieldsEncryptEmbedded(): void $this->triggerProcessFields($withUser, true); $this->assertStringStartsWith('encrypted-', $withUser->name); - $this->assertSame('foo', $withUser->foo); + static::assertSame('foo', $withUser->foo); $this->assertStringStartsWith('encrypted-', $withUser->user->name); $this->assertStringStartsWith('encrypted-', $withUser->user->getAddress()); } @@ -181,8 +181,8 @@ public function testProcessFieldsNoEncryptor(): void $this->subscriber->setEncryptor(null); $this->triggerProcessFields($user, true); - $this->assertSame('David', $user->name); - $this->assertSame('Switzerland', $user->getAddress()); + static::assertSame('David', $user->name); + static::assertSame('Switzerland', $user->getAddress()); } public function testProcessFieldsDecrypt(): void @@ -191,8 +191,8 @@ public function testProcessFieldsDecrypt(): void $this->triggerProcessFields($user, false); - $this->assertSame('David', $user->name); - $this->assertSame('Switzerland', $user->getAddress()); + static::assertSame('David', $user->name); + static::assertSame('Switzerland', $user->getAddress()); } public function testProcessFieldsDecryptExtended(): void @@ -201,9 +201,9 @@ public function testProcessFieldsDecryptExtended(): void $this->triggerProcessFields($user, false); - $this->assertSame('David', $user->name); - $this->assertSame('Switzerland', $user->getAddress()); - $this->assertSame('extra', $user->extra); + static::assertSame('David', $user->name); + static::assertSame('Switzerland', $user->getAddress()); + static::assertSame('extra', $user->extra); } public function testProcessFieldsDecryptEmbedded(): void @@ -212,10 +212,10 @@ public function testProcessFieldsDecryptEmbedded(): void $this->triggerProcessFields($withUser, false); - $this->assertSame('Thing', $withUser->name); - $this->assertSame('foo', $withUser->foo); - $this->assertSame('David', $withUser->user->name); - $this->assertSame('Switzerland', $withUser->user->getAddress()); + static::assertSame('Thing', $withUser->name); + static::assertSame('foo', $withUser->foo); + static::assertSame('David', $withUser->user->name); + static::assertSame('Switzerland', $withUser->user->getAddress()); } public function testProcessFieldsDecryptNull(): void @@ -224,7 +224,7 @@ public function testProcessFieldsDecryptNull(): void $this->triggerProcessFields($user, false); - $this->assertSame('David', $user->name); + static::assertSame('David', $user->name); $this->assertNull($user->getAddress()); } @@ -235,8 +235,8 @@ public function testProcessFieldsDecryptNonEncrypted(): void $this->triggerProcessFields($user, false); - $this->assertSame('encrypted-David', $user->name); - $this->assertSame('encrypted-Switzerland', $user->getAddress()); + static::assertSame('encrypted-David', $user->name); + static::assertSame('encrypted-Switzerland', $user->getAddress()); } /** @@ -314,8 +314,8 @@ public function testPostFlush(): void $this->subscriber->postFlush($postFlush); - $this->assertSame('David', $user->name); - $this->assertSame('Switzerland', $user->getAddress()); + static::assertSame('David', $user->name); + static::assertSame('Switzerland', $user->getAddress()); } public function testAnnotationsAreOnlyReadOnce(): void