Skip to content

Commit

Permalink
SP-771 PHP Key Utils 2.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
mwarzybok-sumoheavy committed Jan 18, 2024
1 parent 4428301 commit f731b33
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 9 deletions.
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,15 @@
}
},
"require": {
"php": "^8.1 || ^8.2 || ^8.3",
"ext-bcmath": "*",
"ext-openssl": "*",
"ext-curl": "*",
"ext-json": "*",
"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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
2 changes: 1 addition & 1 deletion test/unit/BitPayKeyUtils/Storage/FilesystemStorageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion test/unit/BitPayKeyUtils/Storage/test1.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
O:17:"Mock_Key_c1e4b2bf":0:{}
O:7:"KeyMock":0:{}
2 changes: 1 addition & 1 deletion test/unit/BitPayKeyUtils/Storage/test11.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
a2c2ae8c5cd35cc02dfeef6309593cfe0ddcd995e6de235a033c889bc2c23299
7ebba060008a3f86d972e0d679fffaec7d0e99d02fa1ed9bf330dc26befd4ff8
13 changes: 10 additions & 3 deletions test/unit/BitPayKeyUtils/Util/ErrorTest.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<?php

use PHPUnit\Framework\TestCase;
use PHPUnit\Util\ErrorHandler;
use BitPayKeyUtils\Util\Error;

class ErrorTest extends TestCase
Expand Down Expand Up @@ -70,7 +69,7 @@ public function testHandlerWithActionSet()
{
$testedObject = $this->getTestedClassObject();
$result = $testedObject->handler('error', 'set', null);
$this->assertInstanceOf(ErrorHandler::class, $result);
$this->assertInstanceOf(\PHPUnit\Runner\ErrorHandler::class, $result);
}

public function testHandlerWithActionFalse()
Expand Down Expand Up @@ -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);
}
Expand Down
2 changes: 1 addition & 1 deletion test/unit/BitPayKeyUtils/Util/SecureRandomTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit f731b33

Please sign in to comment.