diff --git a/.travis.yml b/.travis.yml index 8ce365be..feddc2d9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -26,6 +26,12 @@ matrix: - php: 7.3 env: COVERAGE=true PHPUNIT_FLAGS="-v --coverage-text" + - php: 7.4 + env: COVERAGE=true PHPUNIT_FLAGS="-v --coverage-text" + + - php: 8.0 + env: COVERAGE=true PHPUNIT_FLAGS="-v --coverage-text" + # Latest commit to master - php: 7.3 env: STABILITY="dev" diff --git a/Tests/Functional/AbstractFunctionalTestCase.php b/Tests/Functional/AbstractFunctionalTestCase.php index 58552630..cf98cc11 100644 --- a/Tests/Functional/AbstractFunctionalTestCase.php +++ b/Tests/Functional/AbstractFunctionalTestCase.php @@ -32,7 +32,7 @@ abstract class AbstractFunctionalTestCase extends TestCase abstract protected function getEncryptor(): EncryptorInterface; - public function setUp() + public function setUp(): void { // Create a simple "default" Doctrine ORM configuration for Annotations $isDevMode = true; @@ -73,7 +73,7 @@ public function setUp() error_reporting(E_ALL); } - public function tearDown() + public function tearDown(): void { unlink($this->dbFile); } @@ -132,4 +132,4 @@ public function assertStringDoesNotContain($needle, $string, $ignoreCase = false static::assertThat($string, $constraint, $message); } -} \ No newline at end of file +} diff --git a/Tests/Functional/BasicQueryTest/AbstractBasicQueryTestCase.php b/Tests/Functional/BasicQueryTest/AbstractBasicQueryTestCase.php index 442b6f66..0065311c 100644 --- a/Tests/Functional/BasicQueryTest/AbstractBasicQueryTestCase.php +++ b/Tests/Functional/BasicQueryTest/AbstractBasicQueryTestCase.php @@ -8,7 +8,7 @@ abstract class AbstractBasicQueryTestCase extends AbstractFunctionalTestCase { - public function testPersistEntity() + public function testPersistEntity(): void { $user = new CascadeTarget(); $user->setNotSecret('My public information'); @@ -21,7 +21,7 @@ public function testPersistEntity() $this->assertEquals(3,$this->getCurrentQueryCount()); } - public function testNoUpdateOnReadEncrypted() + public function testNoUpdateOnReadEncrypted(): void { $this->entityManager->beginTransaction(); $this->assertEquals(1,$this->getCurrentQueryCount()); @@ -57,7 +57,7 @@ public function testNoUpdateOnReadEncrypted() $this->assertEquals(4,$this->getCurrentQueryCount()); } - public function testStoredDataIsEncrypted() + public function testStoredDataIsEncrypted(): void { $user = new CascadeTarget(); $user->setNotSecret('My public information'); diff --git a/Tests/Functional/DoctrineEncryptSubscriber/AbstractDoctrineEncryptSubscriberTestCase.php b/Tests/Functional/DoctrineEncryptSubscriber/AbstractDoctrineEncryptSubscriberTestCase.php index 7b113de6..2c11b33f 100644 --- a/Tests/Functional/DoctrineEncryptSubscriber/AbstractDoctrineEncryptSubscriberTestCase.php +++ b/Tests/Functional/DoctrineEncryptSubscriber/AbstractDoctrineEncryptSubscriberTestCase.php @@ -11,7 +11,7 @@ abstract class AbstractDoctrineEncryptSubscriberTestCase extends AbstractFunctionalTestCase { - public function testEncryptionHappensOnOnlyAnnotatedFields() + public function testEncryptionHappensOnOnlyAnnotatedFields(): void { $secret = "It's a secret"; $notSecret = "You're all welcome to know this."; @@ -44,7 +44,7 @@ public function testEncryptionHappensOnOnlyAnnotatedFields() $this->assertEquals($secret, $decrypted); } - public function testEncryptionCascades() + public function testEncryptionCascades(): void { $secret = "It's a secret"; $notSecret = "You're all welcome to know this."; @@ -87,7 +87,7 @@ public function testEncryptionCascades() * @throws \Doctrine\DBAL\DBALException * @throws \Doctrine\ORM\OptimisticLockException */ - public function testEncryptionDoesNotHappenWhenThereIsNoChange() + public function testEncryptionDoesNotHappenWhenThereIsNoChange(): void { $secret = "It's a secret"; $notSecret = "You're all welcome to know this."; @@ -155,7 +155,7 @@ public function testEncryptionDoesNotHappenWhenThereIsNoChange() } - public function testEncryptionDoesHappenWhenASecretIsChanged() + public function testEncryptionDoesHappenWhenASecretIsChanged(): void { $secret = "It's a secret"; $notSecret = "You're all welcome to know this."; @@ -198,4 +198,4 @@ public function testEncryptionDoesHappenWhenASecretIsChanged() $this->assertStringEndsWith('', $shouldBeDifferentFromBefore); // is encrypted $this->assertNotEquals($originalEncryption, $shouldBeDifferentFromBefore); } -} \ No newline at end of file +} diff --git a/Tests/Unit/DependencyInjection/DoctrineEncryptExtensionTest.php b/Tests/Unit/DependencyInjection/DoctrineEncryptExtensionTest.php index 42b422c8..4aced3d8 100644 --- a/Tests/Unit/DependencyInjection/DoctrineEncryptExtensionTest.php +++ b/Tests/Unit/DependencyInjection/DoctrineEncryptExtensionTest.php @@ -16,12 +16,12 @@ class DoctrineEncryptExtensionTest extends TestCase */ private $extension; - protected function setUp() + protected function setUp(): void { $this->extension = new DoctrineEncryptExtension(); } - public function testConfigLoadHalite() + public function testConfigLoadHalite(): void { $container = $this->createContainer(); $this->extension->load([[]], $container); @@ -29,7 +29,7 @@ public function testConfigLoadHalite() $this->assertSame(HaliteEncryptor::class, $container->getParameter('ambta_doctrine_encrypt.encryptor_class_name')); } - public function testConfigLoadDefuse() + public function testConfigLoadDefuse(): void { $container = $this->createContainer(); @@ -41,7 +41,7 @@ public function testConfigLoadDefuse() $this->assertSame(DefuseEncryptor::class, $container->getParameter('ambta_doctrine_encrypt.encryptor_class_name')); } - public function testConfigLoadCustom() + public function testConfigLoadCustom(): void { $container = $this->createContainer(); $config = [ @@ -54,7 +54,7 @@ public function testConfigLoadCustom() $this->assertSame(self::class, $container->getParameter('ambta_doctrine_encrypt.encryptor_class_name')); } - private function createContainer() + private function createContainer(): ContainerBuilder { $container = new ContainerBuilder( new ParameterBag(['kernel.debug' => false]) diff --git a/Tests/Unit/Encryptors/DefuseEncryptorTest.php b/Tests/Unit/Encryptors/DefuseEncryptorTest.php index c57e9813..cf3e0d8e 100644 --- a/Tests/Unit/Encryptors/DefuseEncryptorTest.php +++ b/Tests/Unit/Encryptors/DefuseEncryptorTest.php @@ -9,7 +9,7 @@ class DefuseEncryptorTest extends TestCase { private const DATA = 'foobar'; - public function testEncrypt() + public function testEncrypt(): void { $keyfile = __DIR__.'/fixtures/defuse.key'; $key = file_get_contents($keyfile); @@ -24,7 +24,7 @@ public function testEncrypt() $this->assertSame($key, $newkey, 'The key must not be modified'); } - public function testGenerateKey() + public function testGenerateKey(): void { $keyfile = sys_get_temp_dir().'/defuse-'.md5(time()); if (file_exists($keyfile)) { diff --git a/Tests/Unit/Encryptors/HaliteEncryptorTest.php b/Tests/Unit/Encryptors/HaliteEncryptorTest.php index 96c064b5..794b5a2f 100644 --- a/Tests/Unit/Encryptors/HaliteEncryptorTest.php +++ b/Tests/Unit/Encryptors/HaliteEncryptorTest.php @@ -9,7 +9,7 @@ class HaliteEncryptorTest extends TestCase { private const DATA = 'foobar'; - public function testEncryptExtension() + public function testEncryptExtension(): void { if (! extension_loaded('sodium')) { $this->markTestSkipped('This test only runs when the sodium extension is enabled.'); @@ -27,7 +27,7 @@ public function testEncryptExtension() $this->assertSame($key, $newkey, 'The key must not be modified'); } - public function testGenerateKey() + public function testGenerateKey(): void { if (! extension_loaded('sodium')) { $this->markTestSkipped('This test only runs when the sodium extension is enabled.'); @@ -46,7 +46,7 @@ public function testGenerateKey() } - public function testEncryptWithoutExtensionThrowsException() + public function testEncryptWithoutExtensionThrowsException(): void { if (extension_loaded('sodium')) { $this->markTestSkipped('This only runs when the sodium extension is disabled.'); diff --git a/Tests/Unit/Subscribers/DoctrineEncryptSubscriberTest.php b/Tests/Unit/Subscribers/DoctrineEncryptSubscriberTest.php index 59b880cb..0a407cc3 100644 --- a/Tests/Unit/Subscribers/DoctrineEncryptSubscriberTest.php +++ b/Tests/Unit/Subscribers/DoctrineEncryptSubscriberTest.php @@ -35,7 +35,7 @@ class DoctrineEncryptSubscriberTest extends TestCase */ private $reader; - protected function setUp() + protected function setUp(): void { $this->encryptor = $this->createMock(EncryptorInterface::class); $this->encryptor @@ -71,7 +71,7 @@ protected function setUp() $this->subscriber = new DoctrineEncryptSubscriber($this->reader, $this->encryptor); } - public function testSetRestorEncryptor() + public function testSetRestorEncryptor(): void { $replaceEncryptor = $this->createMock(EncryptorInterface::class); @@ -82,7 +82,7 @@ public function testSetRestorEncryptor() $this->assertSame($this->encryptor, $this->subscriber->getEncryptor()); } - public function testProcessFieldsEncrypt() + public function testProcessFieldsEncrypt(): void { $user = new User('David', 'Switzerland'); @@ -92,7 +92,7 @@ public function testProcessFieldsEncrypt() $this->assertStringStartsWith('encrypted-', $user->getAddress()); } - public function testProcessFieldsEncryptExtend() + public function testProcessFieldsEncryptExtend(): void { $user = new ExtendedUser('David', 'Switzerland', 'extra'); @@ -103,7 +103,7 @@ public function testProcessFieldsEncryptExtend() $this->assertStringStartsWith('encrypted-', $user->extra); } - public function testProcessFieldsEncryptEmbedded() + public function testProcessFieldsEncryptEmbedded(): void { $withUser = new WithUser('Thing', 'foo', new User('David', 'Switzerland')); @@ -115,7 +115,7 @@ public function testProcessFieldsEncryptEmbedded() $this->assertStringStartsWith('encrypted-', $withUser->user->getAddress()); } - public function testProcessFieldsEncryptNull() + public function testProcessFieldsEncryptNull(): void { $user = new User('David', null); @@ -125,7 +125,7 @@ public function testProcessFieldsEncryptNull() $this->assertNull($user->getAddress()); } - public function testProcessFieldsNoEncryptor() + public function testProcessFieldsNoEncryptor(): void { $user = new User('David', 'Switzerland'); @@ -136,7 +136,7 @@ public function testProcessFieldsNoEncryptor() $this->assertSame('Switzerland', $user->getAddress()); } - public function testProcessFieldsDecrypt() + public function testProcessFieldsDecrypt(): void { $user = new User('encrypted-David', 'encrypted-Switzerland'); @@ -146,7 +146,7 @@ public function testProcessFieldsDecrypt() $this->assertSame('Switzerland', $user->getAddress()); } - public function testProcessFieldsDecryptExtended() + public function testProcessFieldsDecryptExtended(): void { $user = new ExtendedUser('encrypted-David', 'encrypted-Switzerland', 'encrypted-extra'); @@ -157,7 +157,7 @@ public function testProcessFieldsDecryptExtended() $this->assertSame('extra', $user->extra); } - public function testProcessFieldsDecryptEmbedded() + public function testProcessFieldsDecryptEmbedded(): void { $withUser = new WithUser('encrypted-Thing', 'foo', new User('encrypted-David', 'encrypted-Switzerland')); @@ -169,7 +169,7 @@ public function testProcessFieldsDecryptEmbedded() $this->assertSame('Switzerland', $withUser->user->getAddress()); } - public function testProcessFieldsDecryptNull() + public function testProcessFieldsDecryptNull(): void { $user = new User('encrypted-David', null); @@ -179,7 +179,7 @@ public function testProcessFieldsDecryptNull() $this->assertNull($user->getAddress()); } - public function testProcessFieldsDecryptNonEncrypted() + public function testProcessFieldsDecryptNonEncrypted(): void { // no trailing but somethint that our mock decrypt would change if called $user = new User('encrypted-David', 'encrypted-Switzerland'); @@ -193,7 +193,7 @@ public function testProcessFieldsDecryptNonEncrypted() /** * Test that fields are encrypted before flushing. */ - public function testOnFlush() + public function testOnFlush(): void { $user = new User('David', 'Switzerland'); @@ -222,7 +222,7 @@ public function testOnFlush() /** * Test that fields are decrypted again after flushing */ - public function testPostFlush() + public function testPostFlush(): void { $user = new User('encrypted-David', 'encrypted-Switzerland'); diff --git a/composer.json b/composer.json index c463c326..233846ae 100644 --- a/composer.json +++ b/composer.json @@ -5,7 +5,7 @@ "license": "MIT", "description": "Encrypted symfony entity's by verified and standardized libraries", "require": { - "php": "^7.2", + "php": "^7.2|^8.0", "paragonie/halite": "^4.6", "paragonie/sodium_compat": "^1.5", "doctrine/orm": "^2.5", @@ -16,7 +16,7 @@ "symfony/config": "^4.1|^5.0" }, "require-dev": { - "phpunit/phpunit": "^6.5", + "phpunit/phpunit": "^8.0|^9.0", "defuse/php-encryption": "^2.1" }, "suggest": { diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 3d09a6ff..80037be4 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -4,8 +4,7 @@ colors="true" convertErrorsToExceptions="true" convertNoticesToExceptions="true" - convertWarningsToExceptions="true" - syntaxCheck="true"> + convertWarningsToExceptions="true"> @@ -16,15 +15,15 @@ - - + + ./Command ./Configuration ./DependencyInjection ./Encryptors ./Subscribers - - + +