Skip to content

Commit

Permalink
tests - more test coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
nuryagdym committed Aug 17, 2024
1 parent c90143f commit d936c4e
Show file tree
Hide file tree
Showing 5 changed files with 283 additions and 223 deletions.
1 change: 1 addition & 0 deletions tests/Unit/Crypt/AkbankPosCryptTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

/**
* @covers \Mews\Pos\Crypt\AkbankPosCrypt
* @covers \Mews\Pos\Crypt\AbstractCrypt
*/
class AkbankPosCryptTest extends TestCase
{
Expand Down
22 changes: 22 additions & 0 deletions tests/Unit/Crypt/InterPosCryptTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,17 @@
namespace Mews\Pos\Tests\Unit\Crypt;

use Mews\Pos\Crypt\InterPosCrypt;
use Mews\Pos\Entity\Account\AbstractPosAccount;
use Mews\Pos\Entity\Account\InterPosAccount;
use Mews\Pos\Exceptions\NotImplementedException;
use Mews\Pos\Factory\AccountFactory;
use Mews\Pos\PosInterface;
use PHPUnit\Framework\TestCase;
use Psr\Log\NullLogger;

/**
* @covers \Mews\Pos\Crypt\InterPosCrypt
* @covers \Mews\Pos\Crypt\AbstractCrypt
*/
class InterPosCryptTest extends TestCase
{
Expand Down Expand Up @@ -48,6 +51,9 @@ protected function setUp(): void
public function testCheck3DHash(array $responseData): void
{
$this->assertTrue($this->crypt->check3DHash($this->account, $responseData));

$responseData['PurchAmount'] = '';
$this->assertFalse($this->crypt->check3DHash($this->account, $responseData));
}

/**
Expand All @@ -60,6 +66,22 @@ public function testCreate3DHash(array $requestData, string $expected): void
$this->assertSame($expected, $actual);
}

public function testCreateHash(): void
{
$this->expectException(NotImplementedException::class);
$this->crypt->createHash($this->account, []);
}

/**
* @dataProvider threeDHashCheckDataProvider
*/
public function testCheck3DHashException(): void
{
$account = $this->createMock(AbstractPosAccount::class);
$this->expectException(\LogicException::class);
$this->crypt->check3DHash($account, []);
}

public function threeDHashCheckDataProvider(): array
{
return [
Expand Down
12 changes: 12 additions & 0 deletions tests/Unit/Crypt/PosNetV1PosCryptTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

/**
* @covers \Mews\Pos\Crypt\PosNetV1PosCrypt
* @covers \Mews\Pos\Crypt\AbstractCrypt
*/
class PosNetV1PosCryptTest extends TestCase
{
Expand Down Expand Up @@ -44,6 +45,17 @@ public function testHashFromParams(string $storeKey, array $data, string $expect
$this->assertSame($expected, $this->crypt->hashFromParams($storeKey, $data, 'MACParams', ':'));
}

public function testHashFromParamsWhenNotFound(): void
{
$data = self::hashFromParamsDataProvider()[0];
$this->assertSame('', $this->crypt->hashFromParams(
$data['storeKey'],
$data,
'NonExistingField',
':'
));
}

/**
* @dataProvider hashCreateDataProvider
*/
Expand Down
Loading

0 comments on commit d936c4e

Please sign in to comment.