SummaryStepTest   A
last analyzed

Complexity

Total Complexity 8

Size/Duplication

Total Lines 96
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 8
eloc 28
c 1
b 0
f 0
dl 0
loc 96
rs 10

8 Methods

Rating   Name   Duplication   Size   Complexity  
A testPostConditionShouldReturnWhenQuoteReadyForSummaryDisplay() 0 14 1
A testRequireInputShouldBeTrue() 0 5 1
A getCheckoutClientMock() 0 3 1
A createSummaryStep() 0 13 1
A createShipmentServiceMock() 0 6 1
A createConfigMock() 0 3 1
A createProductBundleClient() 0 3 1
A createRequest() 0 3 1
1
<?php
2
3
/**
4
 * This file is part of the Spryker Commerce OS.
5
 * For full license information, please view the LICENSE file that was distributed with this source code.
6
 */
7
8
declare(strict_types = 1);
9
10
namespace PyzTest\Yves\Checkout\Process\Steps;
11
12
use Codeception\Test\Unit;
13
use Generated\Shared\Transfer\AddressTransfer;
0 ignored issues
show
Bug introduced by
The type Generated\Shared\Transfer\AddressTransfer was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
14
use Generated\Shared\Transfer\PaymentTransfer;
0 ignored issues
show
Bug introduced by
The type Generated\Shared\Transfer\PaymentTransfer was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
15
use Generated\Shared\Transfer\QuoteTransfer;
0 ignored issues
show
Bug introduced by
The type Generated\Shared\Transfer\QuoteTransfer was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
16
use Generated\Shared\Transfer\ShipmentTransfer;
0 ignored issues
show
Bug introduced by
The type Generated\Shared\Transfer\ShipmentTransfer was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
17
use SprykerShop\Yves\CheckoutPage\CheckoutPageConfig;
18
use SprykerShop\Yves\CheckoutPage\Dependency\Client\CheckoutPageToCheckoutClientInterface;
19
use SprykerShop\Yves\CheckoutPage\Dependency\Client\CheckoutPageToProductBundleClientInterface;
20
use SprykerShop\Yves\CheckoutPage\Dependency\Service\CheckoutPageToShipmentServiceBridge;
21
use SprykerShop\Yves\CheckoutPage\Dependency\Service\CheckoutPageToShipmentServiceInterface;
22
use SprykerShop\Yves\CheckoutPage\Process\Steps\SummaryStep;
23
use Symfony\Component\HttpFoundation\Request;
24
25
/**
26
 * Auto-generated group annotations
27
 *
28
 * @group PyzTest
29
 * @group Yves
30
 * @group Checkout
31
 * @group Process
32
 * @group Steps
33
 * @group SummaryStepTest
34
 * Add your own group annotations below this line
35
 */
36
class SummaryStepTest extends Unit
37
{
38
    /**
39
     * @var \PyzTest\Yves\Checkout\CheckoutBusinessTester
40
     */
41
    public $tester;
42
43
    /**
44
     * @return void
45
     */
46
    public function testPostConditionShouldReturnWhenQuoteReadyForSummaryDisplay(): void
47
    {
48
        $summaryStep = $this->createSummaryStep();
49
50
        $quoteTransfer = new QuoteTransfer();
51
        $quoteTransfer->setBillingAddress(new AddressTransfer());
52
53
        $paymentTransfer = new PaymentTransfer();
54
        $paymentTransfer->setPaymentProvider('test');
55
56
        $quoteTransfer->setPayment($paymentTransfer);
57
        $quoteTransfer->setShipment(new ShipmentTransfer());
58
59
        $this->assertTrue($summaryStep->postCondition($quoteTransfer));
60
    }
61
62
    /**
63
     * @return void
64
     */
65
    public function testRequireInputShouldBeTrue(): void
66
    {
67
        $summaryStep = $this->createSummaryStep();
68
69
        $this->assertTrue($summaryStep->requireInput(new QuoteTransfer()));
70
    }
71
72
    /**
73
     * @return \SprykerShop\Yves\CheckoutPage\Process\Steps\SummaryStep
74
     */
75
    protected function createSummaryStep(): SummaryStep
76
    {
77
        $productBundleClient = $this->createProductBundleClient();
78
79
        return new SummaryStep(
80
            $productBundleClient,
81
            $this->createShipmentServiceMock(),
82
            $this->createConfigMock(),
83
            $this->getCheckoutClientMock(),
84
            [],
85
            [],
86
            'shipment',
87
            'escape_route',
88
        );
89
    }
90
91
    /**
92
     * @return \PHPUnit\Framework\MockObject\MockObject|\SprykerShop\Yves\CheckoutPage\Dependency\Client\CheckoutPageToProductBundleClientInterface
93
     */
94
    protected function createProductBundleClient(): CheckoutPageToProductBundleClientInterface
95
    {
96
        return $this->getMockBuilder(CheckoutPageToProductBundleClientInterface::class)->getMock();
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->getMockBui...face::class)->getMock() returns the type PHPUnit\Framework\MockObject\MockObject which is incompatible with the type-hinted return SprykerShop\Yves\Checkou...ctBundleClientInterface.
Loading history...
97
    }
98
99
    /**
100
     * @return \Symfony\Component\HttpFoundation\Request
101
     */
102
    protected function createRequest(): Request
103
    {
104
        return Request::createFromGlobals();
105
    }
106
107
    /**
108
     * @return \PHPUnit\Framework\MockObject\MockObject|\SprykerShop\Yves\CheckoutPage\Dependency\Service\CheckoutPageToShipmentServiceInterface
109
     */
110
    protected function createShipmentServiceMock(): CheckoutPageToShipmentServiceInterface
111
    {
112
        return $this->getMockBuilder(CheckoutPageToShipmentServiceBridge::class)
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->getMockBui...nalMethods()->getMock() returns the type PHPUnit\Framework\MockObject\MockObject which is incompatible with the type-hinted return SprykerShop\Yves\Checkou...hipmentServiceInterface.
Loading history...
Deprecated Code introduced by
The function PHPUnit\Framework\MockOb...yingToOriginalMethods() has been deprecated: https://github.com/sebastianbergmann/phpunit/issues/5307 ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

112
        return /** @scrutinizer ignore-deprecated */ $this->getMockBuilder(CheckoutPageToShipmentServiceBridge::class)

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
113
            ->setConstructorArgs([$this->tester->getShipmentService()])
114
            ->enableProxyingToOriginalMethods()
115
            ->getMock();
116
    }
117
118
    /**
119
     * @return \PHPUnit\Framework\MockObject\MockObject|\SprykerShop\Yves\CheckoutPage\CheckoutPageConfig
120
     */
121
    protected function createConfigMock(): CheckoutPageConfig
122
    {
123
        return $this->getMockBuilder(CheckoutPageConfig::class)->getMock();
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->getMockBui...nfig::class)->getMock() returns the type PHPUnit\Framework\MockObject\MockObject which is incompatible with the type-hinted return SprykerShop\Yves\CheckoutPage\CheckoutPageConfig.
Loading history...
124
    }
125
126
    /**
127
     * @return \PHPUnit\Framework\MockObject\MockObject|\SprykerShop\Yves\CheckoutPage\Dependency\Client\CheckoutPageToCheckoutClientInterface
128
     */
129
    public function getCheckoutClientMock(): CheckoutPageToCheckoutClientInterface
130
    {
131
        return $this->getMockBuilder(CheckoutPageToCheckoutClientInterface::class)->getMock();
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->getMockBui...face::class)->getMock() returns the type PHPUnit\Framework\MockObject\MockObject which is incompatible with the type-hinted return SprykerShop\Yves\Checkou...CheckoutClientInterface.
Loading history...
132
    }
133
}
134