-
Notifications
You must be signed in to change notification settings - Fork 0
/
FeatureContext.php
114 lines (102 loc) · 2.44 KB
/
FeatureContext.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
<?php
use Behat\Behat\Tester\Exception\PendingException;
use Behat\Behat\Context\Context;
use Behat\Gherkin\Node\PyStringNode;
use Behat\Gherkin\Node\TableNode;
/**
* Defines application features from the specific context.
*/
class FeatureContext extends \Tests\TestCase implements Context
{
public $user;
/**
* @var int
*/
private $apple;
public $products = [];
/**
* @var \Illuminate\Foundation\Testing\TestResponse
*/
private $response;
/**
* Initializes context.
*
* Every scenario gets its own context instance.
* You can also pass arbitrary arguments to the
* context constructor through behat.yml.
*/
public function __construct()
{
parent::setUp();
}
/**
* @Given there are :arg1 cucumbers
*/
public function thereAreCucumbers($arg1)
{
$this->apple = $arg1;
}
/**
* @When I eat :arg1 cucumbers
*/
public function iEatCucumbers($arg1)
{
$this->apple = $this->apple - $arg1;
}
/**
* @Then I should have :arg1 cucumbers
*/
public function iShouldHaveCucumbers($arg1)
{
$this->assertEquals($this->apple, $arg1);
}
/**
* @Given i have created :arg1 product
*/
public function iHaveCreatedProduct($arg1)
{
$this->products = [['id' => 1], ['id' => 2]];
}
/**
* @When i send :arg1 request to :arg2
*/
public function iSendRequestTo($arg1, $arg2)
{
$this->response = $this->getJson($arg2);
}
/**
* @Then i should receive json:
*/
public function iShouldReceiveJson(PyStringNode $string)
{
$response = $string->getRaw();
$this->assertJsonStringEqualsJsonString($response, $this->response->getContent());
$this->response->assertStatus(400);
}
/**
* @Given I have created product with title :arg1
*/
public function iHaveCreatedProductWithTitle($arg1)
{
$this->mockAPI = [
'id' => 1,
'message' => 'gadfa'
];
// throw new PendingException();
}
/**
* @Given I am Unauthorized user
*/
public function iAmUnauthorizedUser()
{
Order::getTelegramContent($this->mockAPI);
// throw new PendingException();
}
/**
* @When I send post req to :arg1
*/
public function iSendPostReqTo($arg1)
{
$this->response = $this->postJson($arg1);
}
}