Completed
Push — master ( 9a394c...0861ee )
by
unknown
01:32 queued 01:11
created

PaylaterMgBuyRegisteredTest::setNotifyUrl()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace DigitalOrigin\Pmt\Test\Buy;
4
5
use DigitalOrigin\Pmt\Test\Common\AbstractMg21Selenium;
6
use Httpful\Request;
7
8
/**
9
 * @requires magento-install
10
 * @requires magento-register
11
 *
12
 * @group magento-buy-registered
13
 */
14
class PaylaterMgBuyRegisteredTest extends AbstractMg21Selenium
15
{
16
    /**
17
     * @var string
18
     */
19
    protected $checkoutPrice;
20
21
    /**
22
     * @var string
23
     */
24
    protected $confirmationPrice;
25
26
    /**
27
     * @var string
28
     */
29
    protected $notifyUrl;
30
31
    /**
32
     * @throws  \Exception
33
     */
34
    public function testBuy()
35
    {
36
        $this->createAccount();
37
        $this->goToProduct();
38
        $this->configureProduct();
39
        $this->checkProductPage();
40
        $this->goToCheckout();
41
        $this->goToPayment();
42
        $this->setCheckoutPrice($this->preparePaymentMethod());
43
        $this->verifyPaylater();
44
        $this->verifyOrder();
45
        $this->setConfirmationPrice($this->verifyOrderInformation());
46
        $this->comparePrices();
47
        $this->checkProcessed();
48
        $this->quit();
49
    }
50
51
    private function comparePrices()
52
    {
53
        $this->assertContains($this->getCheckoutPrice(), $this->getConfirmationPrice(), "PR46");
54
    }
55
56
    private function checkProcessed()
57
    {
58
        $orderUrl = $this->webDriver->getCurrentURL();
59
        $this->assertNotEmpty($orderUrl);
60
61
        $orderArray = explode('/', $orderUrl);
62
        $magentoOrderId = (int)$orderArray['8'];
63
        $this->assertNotEmpty($magentoOrderId);
64
        $notifyUrl = self::MAGENTO_URL.self::NOTIFICATION_FOLDER.'?'.self::NOTIFICATION_PARAMETER.'='.$magentoOrderId;
65
        $response = Request::post($notifyUrl)->expects('json')->send();
66
        $this->assertNotEmpty($response->body->result);
67
        $this->assertContains(self::NOORDER_TITLE, $response->body->result_description, "PR51=>".$response->body->result_description);
68
69
        $magentoOrderId = 0;
70
        $notifyUrl = self::MAGENTO_URL.self::NOTIFICATION_FOLDER.'?'.self::NOTIFICATION_PARAMETER.'='.$magentoOrderId;
71
        $response = Request::post($notifyUrl)->expects('json')->send();
72
        $this->assertNotEmpty($response->body->result);
73
        $this->assertContains(self::NOTFOUND_TITLE, $response->body->result, "PR53=>".$response->body->result);
74
    }
75
76
    /**
77
     * @return string
78
     */
79
    public function getCheckoutPrice()
80
    {
81
        return $this->checkoutPrice;
82
    }
83
84
    /**
85
     * @param string $checkoutPrice
86
     */
87
    public function setCheckoutPrice($checkoutPrice)
88
    {
89
        $this->checkoutPrice = $checkoutPrice;
90
    }
91
92
    /**
93
     * @return string
94
     */
95
    public function getConfirmationPrice()
96
    {
97
        return $this->confirmationPrice;
98
    }
99
100
    /**
101
     * @param string $confirmationPrice
102
     */
103
    public function setConfirmationPrice($confirmationPrice)
104
    {
105
        $this->confirmationPrice = $confirmationPrice;
106
    }
107
108
    /**
109
     * @return string
110
     */
111
    public function getNotifyUrl()
112
    {
113
        return $this->notifyUrl;
114
    }
115
116
    /**
117
     * @param string $notifyUrl
118
     */
119
    public function setNotifyUrl($notifyUrl)
120
    {
121
        $this->notifyUrl = $notifyUrl;
122
    }
123
}
124