1 | <?php |
||||
2 | |||||
3 | namespace ByTIC\Payments\Mobilpay\Tests\FileLoader; |
||||
4 | |||||
5 | use ByTIC\Payments\Mobilpay\Gateway; |
||||
6 | use ByTIC\Payments\Mobilpay\Tests\AbstractTest; |
||||
7 | use ByTIC\Payments\Mobilpay\Tests\Fixtures\MobilpayData; |
||||
8 | use ByTIC\Payments\Mobilpay\Tests\Fixtures\Records\PaymentMethods\PaymentMethod; |
||||
9 | use ByTIC\Payments\Mobilpay\Tests\Fixtures\Records\PaymentMethods\PaymentMethods; |
||||
10 | use ByTIC\Payments\Models\Methods\Types\CreditCards; |
||||
11 | use Nip\Records\Locator\ModelLocator; |
||||
12 | |||||
13 | /** |
||||
14 | * Class HasFileLoaderTest |
||||
15 | * @package ByTIC\Payments\Mobilpay\Tests\FileLoader |
||||
16 | */ |
||||
17 | class HasFileLoaderTest extends AbstractTest |
||||
18 | { |
||||
19 | public function testSaveToModelOptions() |
||||
20 | { |
||||
21 | /** @var PaymentMethod $paymentMethod */ |
||||
22 | $paymentMethods = \Mockery::mock(PaymentMethods::class)->makePartial(); |
||||
23 | $paymentMethods->shouldReceive('save'); |
||||
24 | |||||
25 | ModelLocator::set(PaymentMethods::class, $paymentMethods); |
||||
0 ignored issues
–
show
Bug
introduced
by
![]() |
|||||
26 | |||||
27 | $paymentMethod = new PaymentMethod(); |
||||
28 | |||||
29 | $paymentMethod->type = 'credit-cards'; |
||||
0 ignored issues
–
show
The property
type does not exist on ByTIC\Payments\Mobilpay\...ntMethods\PaymentMethod . Since you implemented __set , consider adding a @property annotation.
![]() |
|||||
30 | $options = unserialize(MobilpayData::getMethodOptions()); |
||||
31 | $options['mobilpay']['file'] = 'public.cer'; |
||||
32 | $options['mobilpay']['private-key'] = 'private.key'; |
||||
33 | $paymentMethod->options = serialize($options); |
||||
34 | |||||
35 | $type = new CreditCards(); |
||||
36 | $type->setItem($paymentMethod); |
||||
37 | $paymentMethod->setType($type); |
||||
38 | |||||
39 | $directoryPath = $paymentMethod->getFilesDirectory(); |
||||
40 | MobilpayData::buildCertificates(); |
||||
41 | self::assertDirectoryExists($directoryPath); |
||||
42 | |||||
43 | /** @var Gateway $gateway */ |
||||
44 | $gateway = $paymentMethod->getType()->getGateway(); |
||||
0 ignored issues
–
show
The method
getGateway() does not exist on ByTIC\Payments\Models\Methods\Types\AbstractType . It seems like you code against a sub-type of ByTIC\Payments\Models\Methods\Types\AbstractType such as ByTIC\Payments\Models\Methods\Types\CreditCards .
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||
45 | |||||
46 | self::assertGreaterThan(5, strlen($gateway->getCertificate())); |
||||
0 ignored issues
–
show
It seems like
$gateway->getCertificate() can also be of type null ; however, parameter $string of strlen() does only seem to accept string , maybe add an additional type check?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||
47 | self::assertGreaterThan(5, strlen($gateway->getPrivateKey())); |
||||
48 | |||||
49 | $options = $paymentMethod->getPaymentGatewayOptions(); |
||||
50 | |||||
51 | self::assertArrayNotHasKey('file', $options); |
||||
52 | self::assertArrayNotHasKey('private-key', $options); |
||||
53 | |||||
54 | self::assertGreaterThan(50, strlen($options['certificate'])); |
||||
55 | self::assertGreaterThan(50, strlen($options['privateKey'])); |
||||
56 | self::assertDirectoryNotExists($directoryPath); |
||||
57 | } |
||||
58 | } |
||||
59 |