Issues (3641)

...heckoutRequestAttributesValidatorPluginTest.php (1 issue)

1
<?php
2
3
/**
4
 * Copyright © 2016-present Spryker Systems GmbH. All rights reserved.
5
 * Use of this software requires acceptance of the Evaluation License Agreement. See LICENSE file.
6
 */
7
8
namespace SprykerTest\Glue\CheckoutRestApi\Plugin;
9
10
use Codeception\Test\Unit;
11
use Generated\Shared\DataBuilder\RestCheckoutRequestAttributesBuilder;
12
use Spryker\Glue\CheckoutRestApi\CheckoutRestApiConfig;
13
use Spryker\Glue\CheckoutRestApi\Plugin\SinglePaymentCheckoutRequestAttributesValidatorPlugin;
14
15
/**
16
 * Auto-generated group annotations
17
 *
18
 * @group SprykerTest
19
 * @group Glue
20
 * @group CheckoutRestApi
21
 * @group Plugin
22
 * @group SinglePaymentCheckoutRequestAttributesValidatorPluginTest
23
 * Add your own group annotations below this line
24
 */
25
class SinglePaymentCheckoutRequestAttributesValidatorPluginTest extends Unit
26
{
27
    /**
28
     * @var \Spryker\Glue\CheckoutRestApiExtension\Dependency\Plugin\CheckoutRequestValidatorPluginInterface
29
     */
30
    protected $singlePaymentCheckoutRequestValidatorPlugin;
31
32
    /**
33
     * @return void
34
     */
35
    protected function setUp(): void
36
    {
37
        parent::setUp();
38
39
        $this->singlePaymentCheckoutRequestValidatorPlugin = new SinglePaymentCheckoutRequestAttributesValidatorPlugin();
0 ignored issues
show
Documentation Bug introduced by
It seems like new Spryker\Glue\Checkou...ibutesValidatorPlugin() of type Spryker\Glue\CheckoutRes...tributesValidatorPlugin is incompatible with the declared type Spryker\Glue\CheckoutRes...alidatorPluginInterface of property $singlePaymentCheckoutRequestValidatorPlugin.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
40
    }
41
42
    /**
43
     * @return void
44
     */
45
    public function testValidateAttributesWillNotReturnErrorIfOnlyOnePaymentMethodWasProvided(): void
46
    {
47
        // Arrange
48
        $restCheckoutRequestAttributesTransfer = (new RestCheckoutRequestAttributesBuilder())->withPayment()->build();
49
50
        // Act
51
        $restErrorCollectionTransfer = $this->singlePaymentCheckoutRequestValidatorPlugin->validateAttributes($restCheckoutRequestAttributesTransfer);
52
53
        // Assert
54
        $this->assertCount(0, $restErrorCollectionTransfer->getRestErrors());
55
    }
56
57
    /**
58
     * @return void
59
     */
60
    public function testValidateAttributesWillNotReturnErrorWithExpectedCodeIfMoreThanOnePaymentMethodWasProvided(): void
61
    {
62
        // Arrange
63
        $restCheckoutRequestAttributesTransfer = (new RestCheckoutRequestAttributesBuilder())
64
            ->withPayment()
65
            ->withAnotherPayment()
66
            ->build();
67
68
        // Act
69
        $restErrorCollectionTransfer = $this->singlePaymentCheckoutRequestValidatorPlugin->validateAttributes($restCheckoutRequestAttributesTransfer);
70
71
        // Assert
72
        $this->assertCount(1, $restErrorCollectionTransfer->getRestErrors());
73
        /** @var \Generated\Shared\Transfer\RestErrorMessageTransfer $restErrorMessageTransfer */
74
        $restErrorMessageTransfer = $restErrorCollectionTransfer->getRestErrors()->offsetGet(0);
75
        $this->assertEquals(CheckoutRestApiConfig::RESPONSE_CODE_MULTIPLE_PAYMENTS_NOT_ALLOWED, $restErrorMessageTransfer->getCode());
76
    }
77
}
78