|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* Donut Social Network - Yet another experimental social network. |
|
5
|
|
|
* Copyright (C) 2016-2017, Dejan Angelov <[email protected]> |
|
6
|
|
|
* |
|
7
|
|
|
* This file is part of Donut Social Network. |
|
8
|
|
|
* |
|
9
|
|
|
* Donut Social Network is free software: you can redistribute it and/or modify |
|
10
|
|
|
* it under the terms of the GNU General Public License as published by |
|
11
|
|
|
* the Free Software Foundation, either version 3 of the License, or |
|
12
|
|
|
* (at your option) any later version. |
|
13
|
|
|
* |
|
14
|
|
|
* Donut Social Network is distributed in the hope that it will be useful, |
|
15
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
16
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
17
|
|
|
* GNU General Public License for more details. |
|
18
|
|
|
* |
|
19
|
|
|
* You should have received a copy of the GNU General Public License |
|
20
|
|
|
* along with Donut Social Network. If not, see <http://www.gnu.org/licenses/>. |
|
21
|
|
|
* |
|
22
|
|
|
* @package Donut Social Network |
|
23
|
|
|
* @copyright Copyright (C) 2016-2017, Dejan Angelov <[email protected]> |
|
24
|
|
|
* @license https://github.com/angelov/donut/blob/master/LICENSE |
|
25
|
|
|
* @author Dejan Angelov <[email protected]> |
|
26
|
|
|
*/ |
|
27
|
|
|
|
|
28
|
|
|
namespace AppBundle\FeatureContexts; |
|
29
|
|
|
|
|
30
|
|
|
use Behat\Behat\Context\Context; |
|
31
|
|
|
use Behat\Gherkin\Node\TableNode; |
|
32
|
|
|
use Angelov\Donut\Behat\Pages\Movies\BrowsingMoviesPage; |
|
33
|
|
|
use Webmozart\Assert\Assert; |
|
34
|
|
|
|
|
35
|
|
|
class BrowsingMoviesContext implements Context |
|
36
|
|
|
{ |
|
37
|
|
|
private $browsingMoviesPage; |
|
38
|
|
|
|
|
39
|
|
|
public function __construct(BrowsingMoviesPage $browsingMoviesPage) |
|
40
|
|
|
{ |
|
41
|
|
|
$this->browsingMoviesPage = $browsingMoviesPage; |
|
42
|
|
|
} |
|
43
|
|
|
|
|
44
|
|
|
/** |
|
45
|
|
|
* @When I want to browse the movies |
|
46
|
|
|
*/ |
|
47
|
|
|
public function iWantToBrowseTheMovies() : void |
|
48
|
|
|
{ |
|
49
|
|
|
$this->browsingMoviesPage->open(); |
|
50
|
|
|
} |
|
51
|
|
|
|
|
52
|
|
|
/** |
|
53
|
|
|
* @Then I should see :count listed movies |
|
54
|
|
|
*/ |
|
55
|
|
|
public function iShouldSeeListedMovies(int $count) : void |
|
56
|
|
|
{ |
|
57
|
|
|
Assert::eq( |
|
58
|
|
|
$count, $this->browsingMoviesPage->countDisplayedMovies(), 'Expected to find %s movies, found %s.' |
|
59
|
|
|
); |
|
60
|
|
|
} |
|
61
|
|
|
|
|
62
|
|
|
/** |
|
63
|
|
|
* @Then those movies should be the following |
|
64
|
|
|
*/ |
|
65
|
|
|
public function thoseMoviesShouldBeTheFollowing(TableNode $table) : void |
|
66
|
|
|
{ |
|
67
|
|
|
$expected = array_map(function ($row) : string { |
|
68
|
|
|
return $row[0]; |
|
69
|
|
|
}, $table->getRows()); |
|
70
|
|
|
array_shift($expected); |
|
71
|
|
|
|
|
72
|
|
|
$found = $this->browsingMoviesPage->getDisplayedMovieTitles(); |
|
73
|
|
|
|
|
74
|
|
|
sort($expected); |
|
75
|
|
|
sort($found); |
|
76
|
|
|
|
|
77
|
|
|
$expected = implode(', ', $expected); |
|
78
|
|
|
$found = implode(', ', $found); |
|
79
|
|
|
|
|
80
|
|
|
Assert::same($expected, $found); |
|
81
|
|
|
} |
|
82
|
|
|
|
|
83
|
|
|
/** |
|
84
|
|
|
* @When I don't specify any filters |
|
85
|
|
|
*/ |
|
86
|
|
|
public function iDonTSpecifyAnyFilters() : void |
|
87
|
|
|
{ |
|
88
|
|
|
// do nothing |
|
89
|
|
|
} |
|
90
|
|
|
|
|
91
|
|
|
/** |
|
92
|
|
|
* @When I choose the :genre genre |
|
93
|
|
|
* @When I choose the :first and :second genres |
|
94
|
|
|
*/ |
|
95
|
|
|
public function iChooseTheGenre(string ...$genres) : void |
|
96
|
|
|
{ |
|
97
|
|
|
foreach ($genres as $genre) { |
|
98
|
|
|
$this->browsingMoviesPage->checkGenre($genre); |
|
99
|
|
|
} |
|
100
|
|
|
|
|
101
|
|
|
$this->browsingMoviesPage->applyFilters(); |
|
102
|
|
|
} |
|
103
|
|
|
|
|
104
|
|
|
/** |
|
105
|
|
|
* @When I choose the :period period |
|
106
|
|
|
*/ |
|
107
|
|
|
public function iChooseThePeriod(string $period) : void |
|
108
|
|
|
{ |
|
109
|
|
|
$this->browsingMoviesPage->choosePeriod($period); |
|
110
|
|
|
$this->browsingMoviesPage->applyFilters(); |
|
111
|
|
|
} |
|
112
|
|
|
} |
|
113
|
|
|
|