|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/* |
|
4
|
|
|
* This file is part of the Sylius package. |
|
5
|
|
|
* |
|
6
|
|
|
* (c) Paweł Jędrzejewski |
|
7
|
|
|
* |
|
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
|
9
|
|
|
* file that was distributed with this source code. |
|
10
|
|
|
*/ |
|
11
|
|
|
|
|
12
|
|
|
namespace spec\Sylius\Behat\Context\Ui; |
|
13
|
|
|
|
|
14
|
|
|
use Behat\Mink\Mink; |
|
15
|
|
|
use Behat\Mink\WebAssert; |
|
16
|
|
|
use PhpSpec\ObjectBehavior; |
|
17
|
|
|
use Sylius\Behat\Context\FeatureContext; |
|
18
|
|
|
use Sylius\Behat\Extension\Factory\PageObjectFactory; |
|
19
|
|
|
use Sylius\Behat\Page\Cart\CartSummaryPage; |
|
20
|
|
|
|
|
21
|
|
|
/** |
|
22
|
|
|
* @author Mateusz Zalewski <[email protected]> |
|
23
|
|
|
*/ |
|
24
|
|
|
class CartContextSpec extends ObjectBehavior |
|
25
|
|
|
{ |
|
26
|
|
|
function let(PageObjectFactory $pageObjectFactory, Mink $mink) |
|
27
|
|
|
{ |
|
28
|
|
|
$this->setPageObjectFactory($pageObjectFactory); |
|
29
|
|
|
$this->setMink($mink); |
|
30
|
|
|
} |
|
31
|
|
|
|
|
32
|
|
|
function it_is_initializable() |
|
33
|
|
|
{ |
|
34
|
|
|
$this->shouldHaveType('Sylius\Behat\Context\Ui\CartContext'); |
|
35
|
|
|
} |
|
36
|
|
|
|
|
37
|
|
|
function it_is_feature_context() |
|
38
|
|
|
{ |
|
39
|
|
|
$this->shouldHaveType(FeatureContext::class); |
|
40
|
|
|
} |
|
41
|
|
|
|
|
42
|
|
|
function it_checks_if_cart_has_given_total($pageObjectFactory, $mink, CartSummaryPage $cartSummaryPage, WebAssert $assert) |
|
43
|
|
|
{ |
|
44
|
|
|
$pageObjectFactory->createPage('Cart\CartSummaryPage')->willReturn($cartSummaryPage); |
|
45
|
|
|
$cartSummaryPage->open()->shouldBeCalled(); |
|
46
|
|
|
|
|
47
|
|
|
$mink->assertSession(null)->willReturn($assert); |
|
48
|
|
|
$assert->elementTextContains('css', '#cart-summary', 'Grand total: $100.00')->shouldBeCalled(); |
|
49
|
|
|
|
|
50
|
|
|
$this->myCartTotalShouldBe('$100.00'); |
|
51
|
|
|
} |
|
52
|
|
|
|
|
53
|
|
|
function it_checks_if_cart_has_given_tax_total($pageObjectFactory, $mink, CartSummaryPage $cartSummaryPage, WebAssert $assert) |
|
54
|
|
|
{ |
|
55
|
|
|
$pageObjectFactory->createPage('Cart\CartSummaryPage')->willReturn($cartSummaryPage); |
|
56
|
|
|
$cartSummaryPage->open()->shouldBeCalled(); |
|
57
|
|
|
|
|
58
|
|
|
$mink->assertSession(null)->willReturn($assert); |
|
59
|
|
|
$assert->elementTextContains('css', '#cart-summary', 'Tax total: $50.00')->shouldBeCalled(); |
|
60
|
|
|
|
|
61
|
|
|
$this->myCartTaxesShouldBe('$50.00'); |
|
62
|
|
|
} |
|
63
|
|
|
} |
|
64
|
|
|
|