-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathTransactionIdAssertTrait.php
31 lines (27 loc) · 1.13 KB
/
TransactionIdAssertTrait.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
<?php
namespace Ekyna\Component\Payum\Payzen\Tests\Assert;
use Ekyna\Component\Payum\Payzen\Tests\Constraint\ArrayItem;
use PHPUnit\Framework\Constraint\ArrayHasKey;
use PHPUnit\Framework\Constraint\Constraint;
use PHPUnit\Framework\Constraint\IsType;
use PHPUnit\Framework\Constraint\LogicalAnd;
use PHPUnit\Framework\Constraint\RegularExpression;
trait TransactionIdAssertTrait
{
abstract public static function assertThat($value, Constraint $constraint, string $message = ''): void;
protected function assertArrayHasVadsTransIdAndDateKeysTypedString($array, string $message = '')
{
$this->assertThat(
$array,
LogicalAnd::fromConstraints(
new ArrayHasKey('vads_trans_id'),
new ArrayHasKey('vads_trans_date'),
new ArrayItem('vads_trans_id', new IsType('string')),
new ArrayItem('vads_trans_date', new IsType('string')),
new ArrayItem('vads_trans_id', new RegularExpression('/\d{6}/')),
new ArrayItem('vads_trans_date', new RegularExpression('/\d{8}/'))
),
$message
);
}
}