Test Failed
Push — master ( d3990f...a5a1b1 )
by Martin
02:27
created

AcceptanceTester::iShouldSeeRemainingTasks()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 8
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 4
nc 2
nop 1
1
<?php
2
3
4
/**
5
 * Inherited Methods
6
 * @method void wantToTest($text)
7
 * @method void wantTo($text)
8
 * @method void execute($callable)
9
 * @method void expectTo($prediction)
10
 * @method void expect($prediction)
11
 * @method void amGoingTo($argumentation)
12
 * @method void am($role)
13
 * @method void lookForwardTo($achieveValue)
14
 * @method void comment($description)
15
 * @method \Codeception\Lib\Friend haveFriend($name, $actorClass = NULL)
16
 *
17
 * @SuppressWarnings(PHPMD)
18
*/
19
class AcceptanceTester extends \Codeception\Actor
0 ignored issues
show
Bug introduced by
There is one abstract method getScenario in this class; you could implement it, or declare this class as abstract.
Loading history...
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
20
{
21
    use _generated\AcceptanceTesterActions;
22
23
24
25
    /**
26
     * @Given There is no task named :arg1
27
     */
28
    public function thereIsNoTaskNamed($arg1)
29
    {
30
        $this->amOnPage('/task/list');
31
        $this->dontSee($arg1);
32
    }
33
34
    /**
35
     * @When I create a new task named :arg1
36
     */
37
    public function iCreateANewTaskNamed($arg1)
38
    {
39
        $this->amOnPage('/task/list');
40
        $this->click('Create new');
41
        $this->fillField('create_task_form[name]', $arg1);
42
        $this->click('create_task_form[submit]');
43
    }
44
45
    /**
46
     * @Then The task :arg1 should be created
47
     */
48
    public function theTaskShouldBeCreated($arg1)
49
    {
50
        $this->see($arg1);
51
    }
52
53
    /**
54
     * @Then The status of task :arg1 should be :arg2
55
     */
56
    public function theStatusOfTaskShouldBe($arg1, $arg2)
57
    {
58
        $this->see($arg1 . ' (' . $arg2 . ')');
59
    }
60
61
    /**
62
     * @Given There is a task named :arg1
63
     */
64
    public function thereIsATaskNamed($arg1)
65
    {
66
        $this->amOnPage('/task/list');
67
        $this->see($arg1);
68
    }
69
70
    /**
71
     * @Then The new task :arg1 should not be created
72
     */
73
    public function theNewTaskShouldNotBeCreated($arg1)
74
    {
75
        $this->see($arg1 . " is already existed");
76
    }
77
78
    /**
79
     * @Given There are tasks:
80
     */
81
    public function thereAreTasks(\Behat\Gherkin\Node\TableNode $tableNode)
82
    {
83
        $this->amOnPage('/task/list');
84
        foreach ($tableNode as $row) {
85
            $name = $row['name'];
86
            $status = $row['status'];
87
88
            $this->see($name . ' (' . $status . ')');
89
        }
90
    }
91
92
    /**
93
     * @When I list tasks
94
     */
95
    public function iListTasks()
96
    {
97
        $this->amOnPage('/task/list');
98
    }
99
100
    /**
101
     * @Then I should see remaining tasks:
102
     */
103
    public function iShouldSeeRemainingTasks(\Behat\Gherkin\Node\TableNode $tableNode)
104
    {
105
        foreach ($tableNode as $row) {
106
            $name = $row['name'];
107
108
            $this->see($name . ' (remaining)');
109
        }
110
    }
111
112
    /**
113
     * @Then I should see completed tasks:
114
     */
115
    public function iShouldSeeCompletedTasks(\Behat\Gherkin\Node\TableNode $tableNode)
116
    {
117
        foreach ($tableNode as $row) {
118
            $name = $row['name'];
119
120
            $this->see($name . ' (completed)');
121
        }
122
    }
123
124
    /**
125
     * @Given There is a task named :arg1 with status :arg2
126
     */
127
    public function thereIsATaskNamedWithStatus($arg1, $arg2)
128
    {
129
        $this->amOnPage('/task/list');
130
        $this->see($arg1 . ' (' . $arg2 . ')');
131
    }
132
133
    /**
134
     * @When I modify task :arg1 with name :arg2 and status :arg3
135
     */
136
    public function iModifyTaskWithNameAndStatus($arg1, $arg2, $arg3)
137
    {
138
        $this->click("a[data-edit='" . $arg1 . "']");
139
        $this->fillField('update_task_form[name]', $arg2);
140
        $this->selectOption('update_task_form[status]', $arg3);
141
        $this->click('update_task_form[submit]');
142
    }
143
144
145
    /**
146
     * @Then The task :arg1 should have name :arg2 and status :arg3
147
     */
148
    public function theTaskShouldHaveNameAndStatus($arg1, $arg2, $arg3)
149
    {
150
        $this->dontSee($arg1);
151
        $this->see($arg2 . ' (' . $arg3 . ')');
152
    }
153
154
155
    /**
156
     * @When I modify task :arg1 with status :arg2
157
     */
158
    public function iModifyTaskWithStatus($arg1, $arg2)
159
    {
160
        if ($arg2 === 'remaining') {
161
            $this->click("a[data-redo='" . $arg1 . "']");
162
        } else if ($arg2 === 'completed') {
163
            $this->click("a[data-done='" . $arg1 . "']");
164
        } else {
165
            throw new \Exception('Invalid status');
166
        }
167
168
    }
169
170
    /**
171
     * @Then The task :arg1 should have status :arg2
172
     */
173
    public function theTaskShouldHaveStatus($arg1, $arg2)
174
    {
175
        $this->see($arg1 . ' (' . $arg2 . ')');
176
    }
177
178
    /**
179
     * @When I remove task :arg1
180
     */
181
    public function iRemoveTask($arg1)
182
    {
183
        $this->click("a[data-remove='" . $arg1 . "']");
184
    }
185
186
    /**
187
     * @Then The task :arg1 should be deleted
188
     */
189
    public function theTaskShouldBeDeleted($arg1)
190
    {
191
        $this->dontSee($arg1);
192
    }
193
194
195
    /**
196
     * @When I cleanup completed tasks
197
     */
198
    public function iCleanupCompletedTasks()
199
    {
200
        $this->click('Clean');
201
    }
202
203
    /**
204
     * @Then The completed tasks should be removed:
205
     */
206
    public function theCompletedTasksShouldBeRemoved(\Behat\Gherkin\Node\TableNode $tableNode)
207
    {
208
        foreach ($tableNode as $row) {
209
            $name = $row['name'];
210
211
            $this->dontSee($name);
212
        }
213
    }
214
215
}
216