|
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 Angelov\Donut\Behat\Pages\Communities\CreateCommunityPage; |
|
32
|
|
|
use Angelov\Donut\Behat\Service\AlertsChecker\AlertsCheckerInterface; |
|
33
|
|
|
use Angelov\Donut\Behat\Service\ValidationErrorsChecker\ValidationErrorsCheckerInterface; |
|
34
|
|
|
use Webmozart\Assert\Assert; |
|
35
|
|
|
|
|
36
|
|
|
class CreatingCommunitiesContext implements Context |
|
37
|
|
|
{ |
|
38
|
|
|
private $createCommunityPage; |
|
39
|
|
|
private $alertsChecker; |
|
40
|
|
|
private $validationErrorsChecker; |
|
41
|
|
|
|
|
42
|
|
|
public function __construct( |
|
43
|
|
|
CreateCommunityPage $createCommunityPage, |
|
44
|
|
|
AlertsCheckerInterface $alertsChecker, |
|
45
|
|
|
ValidationErrorsCheckerInterface $validationErrorsChecker |
|
46
|
|
|
) { |
|
47
|
|
|
$this->createCommunityPage = $createCommunityPage; |
|
48
|
|
|
$this->alertsChecker = $alertsChecker; |
|
49
|
|
|
$this->validationErrorsChecker = $validationErrorsChecker; |
|
50
|
|
|
} |
|
51
|
|
|
|
|
52
|
|
|
/** |
|
53
|
|
|
* @When I want to create a new community |
|
54
|
|
|
*/ |
|
55
|
|
|
public function iWantToCreateANewCommunity() : void |
|
56
|
|
|
{ |
|
57
|
|
|
$this->createCommunityPage->open(); |
|
58
|
|
|
} |
|
59
|
|
|
|
|
60
|
|
|
/** |
|
61
|
|
|
* @When I specify the name as :name |
|
62
|
|
|
* @When I don't specify the name |
|
63
|
|
|
*/ |
|
64
|
|
|
public function iSpecifyTheNameAs(string $name = '') : void |
|
65
|
|
|
{ |
|
66
|
|
|
$this->createCommunityPage->specifyName($name); |
|
67
|
|
|
} |
|
68
|
|
|
|
|
69
|
|
|
/** |
|
70
|
|
|
* @When I try to create it |
|
71
|
|
|
*/ |
|
72
|
|
|
public function iTryToCreateIt() : void |
|
73
|
|
|
{ |
|
74
|
|
|
$this->createCommunityPage->create(); |
|
75
|
|
|
} |
|
76
|
|
|
|
|
77
|
|
|
/** |
|
78
|
|
|
* @Then I should be notified that the community is created |
|
79
|
|
|
*/ |
|
80
|
|
|
public function iShouldBeNotifiedThatTheCommunityIsCreated() : void |
|
81
|
|
|
{ |
|
82
|
|
|
Assert::true( |
|
83
|
|
|
$this->alertsChecker->hasAlert('Community was successfully created!', AlertsCheckerInterface::TYPE_SUCCESS) |
|
84
|
|
|
); |
|
85
|
|
|
} |
|
86
|
|
|
|
|
87
|
|
|
/** |
|
88
|
|
|
* @Given I specify the description as :description |
|
89
|
|
|
*/ |
|
90
|
|
|
public function iSpecifyTheDescriptionAs(string $description) : void |
|
91
|
|
|
{ |
|
92
|
|
|
$this->createCommunityPage->specifyDescription($description); |
|
93
|
|
|
} |
|
94
|
|
|
|
|
95
|
|
|
/** |
|
96
|
|
|
* @Then I should be notified that the name is required |
|
97
|
|
|
*/ |
|
98
|
|
|
public function iShouldBeNotifiedThatTheNameIsRequired() : void |
|
99
|
|
|
{ |
|
100
|
|
|
Assert::true( |
|
101
|
|
|
$this->validationErrorsChecker->checkMessageForField('name', 'Please enter a name for the community.'), |
|
102
|
|
|
'Could not find the proper validation message.' |
|
103
|
|
|
); |
|
104
|
|
|
} |
|
105
|
|
|
} |
|
106
|
|
|
|