From 31533bce34a27ab2f951cdb6a5f26e08458ac520 Mon Sep 17 00:00:00 2001 From: spiralbot Date: Sat, 4 Jan 2025 12:31:30 +0000 Subject: [PATCH] refactor: enable phpunit code quality set for rector (#1186) --- tests/ConfigTest.php | 2 +- tests/EncrypterFactoryTest.php | 25 ++++++++----------------- tests/EncrypterTest.php | 22 +++++++++++----------- 3 files changed, 20 insertions(+), 29 deletions(-) diff --git a/tests/ConfigTest.php b/tests/ConfigTest.php index 9b27961..90a970d 100644 --- a/tests/ConfigTest.php +++ b/tests/ConfigTest.php @@ -15,6 +15,6 @@ public function testKey(): void 'key' => 'abc' ]); - $this->assertSame('abc', $config->getKey()); + self::assertSame('abc', $config->getKey()); } } diff --git a/tests/EncrypterFactoryTest.php b/tests/EncrypterFactoryTest.php index f326033..9f82cc9 100644 --- a/tests/EncrypterFactoryTest.php +++ b/tests/EncrypterFactoryTest.php @@ -30,15 +30,12 @@ public function testInjection(): void new EncrypterConfig(['key' => $key]) ); - $this->assertInstanceOf( - EncrypterInterface::class, - $container->get(EncrypterInterface::class) - ); + self::assertInstanceOf(EncrypterInterface::class, $container->get(EncrypterInterface::class)); - $this->assertInstanceOf(Encrypter::class, $container->get(EncrypterInterface::class)); + self::assertInstanceOf(Encrypter::class, $container->get(EncrypterInterface::class)); $encrypter = $container->get(EncrypterInterface::class); - $this->assertSame($key, $encrypter->getKey()); + self::assertSame($key, $encrypter->getKey()); } public function testGetEncrypter(): void @@ -55,19 +52,13 @@ public function testGetEncrypter(): void new EncrypterConfig(['key' => $key]) ); - $this->assertInstanceOf( - EncryptionInterface::class, - $container->get(EncryptionInterface::class) - ); + self::assertInstanceOf(EncryptionInterface::class, $container->get(EncryptionInterface::class)); - $this->assertInstanceOf( - EncrypterFactory::class, - $container->get(EncryptionInterface::class) - ); + self::assertInstanceOf(EncrypterFactory::class, $container->get(EncryptionInterface::class)); $encrypter = $container->get(EncryptionInterface::class)->getEncrypter(); - $this->assertSame($key, $encrypter->getKey()); - $this->assertSame($key, $container->get(EncryptionInterface::class)->getKey()); + self::assertSame($key, $encrypter->getKey()); + self::assertSame($key, $container->get(EncryptionInterface::class)->getKey()); } public function testExceptionKey(): void @@ -88,6 +79,6 @@ public function testGenerateKey(): void 'key' => $key, ])); - $this->assertNotSame($key, $manager->generateKey()); + self::assertNotSame($key, $manager->generateKey()); } } diff --git a/tests/EncrypterTest.php b/tests/EncrypterTest.php index 68a365a..1cdb4a3 100644 --- a/tests/EncrypterTest.php +++ b/tests/EncrypterTest.php @@ -18,10 +18,10 @@ public function testImmutable(): void $encrypter = new Encrypter($keyA = Key::CreateNewRandomKey()->saveToAsciiSafeString()); $new = $encrypter->withKey($keyB = Key::CreateNewRandomKey()->saveToAsciiSafeString()); - $this->assertNotSame($encrypter, $new); + self::assertNotSame($encrypter, $new); - $this->assertEquals($keyA, $encrypter->getKey()); - $this->assertEquals($keyB, $new->getKey()); + self::assertEquals($keyA, $encrypter->getKey()); + self::assertEquals($keyB, $new->getKey()); } public function testEncryption(): void @@ -29,18 +29,18 @@ public function testEncryption(): void $encrypter = new Encrypter(Key::CreateNewRandomKey()->saveToAsciiSafeString()); $encrypted = $encrypter->encrypt('test string'); - $this->assertNotEquals('test string', $encrypted); - $this->assertEquals('test string', $encrypter->decrypt($encrypted)); + self::assertNotSame('test string', $encrypted); + self::assertEquals('test string', $encrypter->decrypt($encrypted)); $encrypter = $encrypter->withKey(Key::CreateNewRandomKey()->saveToAsciiSafeString()); $encrypted = $encrypter->encrypt('test string'); - $this->assertNotEquals('test string', $encrypted); - $this->assertEquals('test string', $encrypter->decrypt($encrypted)); + self::assertNotSame('test string', $encrypted); + self::assertEquals('test string', $encrypter->decrypt($encrypted)); $encrypted = $encrypter->encrypt('test string'); - $this->assertNotEquals('test string', $encrypted); - $this->assertEquals('test string', $encrypter->decrypt($encrypted)); + self::assertNotSame('test string', $encrypted); + self::assertEquals('test string', $encrypter->decrypt($encrypted)); } public function testBadData(): void @@ -50,8 +50,8 @@ public function testBadData(): void $encrypter = new Encrypter(Key::CreateNewRandomKey()->saveToAsciiSafeString()); $encrypted = $encrypter->encrypt('test string'); - $this->assertNotEquals('test string', $encrypted); - $this->assertEquals('test string', $encrypter->decrypt($encrypted)); + self::assertNotSame('test string', $encrypted); + self::assertEquals('test string', $encrypter->decrypt($encrypted)); $encrypter->decrypt('badData.' . $encrypted); }