From f731b33f06ad44af05a2bdf629284cf2ad0e247d Mon Sep 17 00:00:00 2001 From: Marcin Warzybok Date: Thu, 18 Jan 2024 13:45:52 +0100 Subject: [PATCH] SP-771 PHP Key Utils 2.0.0 --- composer.json | 3 ++- .../Storage/EncryptedFilesystemStorageTest.php | 2 +- .../Storage/FilesystemStorageTest.php | 2 +- test/unit/BitPayKeyUtils/Storage/test1.txt | 2 +- test/unit/BitPayKeyUtils/Storage/test11.txt | 2 +- test/unit/BitPayKeyUtils/Util/ErrorTest.php | 13 ++++++++++--- test/unit/BitPayKeyUtils/Util/SecureRandomTest.php | 2 +- 7 files changed, 17 insertions(+), 9 deletions(-) diff --git a/composer.json b/composer.json index c2c98c0..7a57955 100644 --- a/composer.json +++ b/composer.json @@ -15,6 +15,7 @@ } }, "require": { + "php": "^8.1 || ^8.2 || ^8.3", "ext-bcmath": "*", "ext-openssl": "*", "ext-curl": "*", @@ -22,7 +23,7 @@ "ext-iconv": "*" }, "require-dev": { - "phpunit/phpunit": "^7.5 || ^9.0" + "phpunit/phpunit": "^10.0" }, "suggest": { "ext-gmp": "Required to use this package with GMP instead of BCMath" diff --git a/test/unit/BitPayKeyUtils/Storage/EncryptedFilesystemStorageTest.php b/test/unit/BitPayKeyUtils/Storage/EncryptedFilesystemStorageTest.php index 8547e4e..dcd0d67 100644 --- a/test/unit/BitPayKeyUtils/Storage/EncryptedFilesystemStorageTest.php +++ b/test/unit/BitPayKeyUtils/Storage/EncryptedFilesystemStorageTest.php @@ -15,7 +15,7 @@ public function testInstanceOf() public function testPersist() { $encryptedFilesystemStorage = $this->createClassObject(); - $keyInterface = $this->getMockBuilder(Key::class)->getMock(); + $keyInterface = $this->getMockBuilder(Key::class)->setMockClassName('KeyMock')->getMock(); $keyInterface->method('getId')->willReturn(__DIR__ . '/test11.txt'); $this->assertFileExists(__DIR__ . '/test11.txt'); $this->assertEquals(null, $encryptedFilesystemStorage->persist($keyInterface)); diff --git a/test/unit/BitPayKeyUtils/Storage/FilesystemStorageTest.php b/test/unit/BitPayKeyUtils/Storage/FilesystemStorageTest.php index 7aec66b..8dfe388 100644 --- a/test/unit/BitPayKeyUtils/Storage/FilesystemStorageTest.php +++ b/test/unit/BitPayKeyUtils/Storage/FilesystemStorageTest.php @@ -16,7 +16,7 @@ public function testInstanceOf() public function testPersist() { $filesystemStorage = $this->createClassObject(); - $keyInterface = $this->getMockBuilder(Key::class)->getMock(); + $keyInterface = $this->getMockBuilder(Key::class)->setMockClassName('KeyMock')->getMock(); $keyInterface->method('getId')->willReturn(__DIR__ . '/test1.txt'); $this->assertFileExists(__DIR__ . '/test1.txt'); @chmod(__DIR__ . 'test1.txt', 0777); diff --git a/test/unit/BitPayKeyUtils/Storage/test1.txt b/test/unit/BitPayKeyUtils/Storage/test1.txt index 46f07be..ae24bcd 100755 --- a/test/unit/BitPayKeyUtils/Storage/test1.txt +++ b/test/unit/BitPayKeyUtils/Storage/test1.txt @@ -1 +1 @@ -O:17:"Mock_Key_c1e4b2bf":0:{} \ No newline at end of file +O:7:"KeyMock":0:{} \ No newline at end of file diff --git a/test/unit/BitPayKeyUtils/Storage/test11.txt b/test/unit/BitPayKeyUtils/Storage/test11.txt index 92c1ed0..e7b67c5 100644 --- a/test/unit/BitPayKeyUtils/Storage/test11.txt +++ b/test/unit/BitPayKeyUtils/Storage/test11.txt @@ -1 +1 @@ -a2c2ae8c5cd35cc02dfeef6309593cfe0ddcd995e6de235a033c889bc2c23299 \ No newline at end of file +7ebba060008a3f86d972e0d679fffaec7d0e99d02fa1ed9bf330dc26befd4ff8 \ No newline at end of file diff --git a/test/unit/BitPayKeyUtils/Util/ErrorTest.php b/test/unit/BitPayKeyUtils/Util/ErrorTest.php index ae3ddb9..a1b9101 100644 --- a/test/unit/BitPayKeyUtils/Util/ErrorTest.php +++ b/test/unit/BitPayKeyUtils/Util/ErrorTest.php @@ -1,7 +1,6 @@ getTestedClassObject(); $result = $testedObject->handler('error', 'set', null); - $this->assertInstanceOf(ErrorHandler::class, $result); + $this->assertInstanceOf(\PHPUnit\Runner\ErrorHandler::class, $result); } public function testHandlerWithActionFalse() @@ -110,8 +109,16 @@ public function testHandlerWithUnhandledType() public function testRaise() { + set_error_handler( + static function ( $errno, $errstr ) { + restore_error_handler(); + throw new Exception( $errstr, $errno ); + }, + E_ALL + ); $testedObject = $this->getTestedClassObject(); - $this->expectError(); + $this->expectExceptionMessage('error'); + $result = $testedObject->raise('error'); $this->assertTrue($result); } diff --git a/test/unit/BitPayKeyUtils/Util/SecureRandomTest.php b/test/unit/BitPayKeyUtils/Util/SecureRandomTest.php index c459ae8..ae7f80e 100644 --- a/test/unit/BitPayKeyUtils/Util/SecureRandomTest.php +++ b/test/unit/BitPayKeyUtils/Util/SecureRandomTest.php @@ -20,7 +20,7 @@ public function testHasOpenSSL() $reflection->setAccessible(true); $this->assertTrue($reflection->getValue()); - $this->assertObjectHasAttribute('hasOpenSSL', $secureRandom); + $this->assertTrue(property_exists($secureRandom, 'hasOpenSSL')); } public function testGenerateRandom()