1
|
|
|
<?php |
2
|
|
|
/* |
3
|
|
|
* Copyright 2014-2017 Arnaud Bienvenu |
4
|
|
|
* |
5
|
|
|
* This file is part of Kyela. |
6
|
|
|
|
7
|
|
|
* Kyela is free software: you can redistribute it and/or modify |
8
|
|
|
* it under the terms of the GNU Affero General Public License as published by |
9
|
|
|
* the Free Software Foundation, either version 3 of the License, or |
10
|
|
|
* (at your option) any later version. |
11
|
|
|
|
12
|
|
|
* Kyela is distributed in the hope that it will be useful, |
13
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
14
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
15
|
|
|
* GNU Affero General Public License for more details. |
16
|
|
|
|
17
|
|
|
* You should have received a copy of the GNU Affero General Public License |
18
|
|
|
* along with Kyela. If not, see <http://www.gnu.org/licenses/>. |
19
|
|
|
* |
20
|
|
|
*/ |
21
|
|
|
|
22
|
|
|
namespace Abienvenu\KyelaBundle\Tests\Controller; |
23
|
|
|
|
24
|
|
|
class ChoiceControllerTest extends PollWebTestCase |
25
|
|
|
{ |
26
|
|
|
|
27
|
|
|
public function testCompleteScenario() |
28
|
|
|
{ |
29
|
|
|
// Create a poll to work with |
30
|
|
|
$crawler = self::createPollEntry(); |
31
|
|
|
|
32
|
|
|
// Go to options list |
33
|
|
|
$crawler = self::clickLink($crawler, 'edit.options'); |
34
|
|
|
$this->assertNotNull($crawler); |
35
|
|
|
|
36
|
|
|
// Create a choice |
37
|
|
|
$name = uniqid('Test Choice '); |
38
|
|
|
$crawler = self::clickLink($crawler, 'add.an.option'); |
39
|
|
|
self::checkElement($crawler, 'h1:contains("' . self::$translator->trans('new.choice') . '")'); |
40
|
|
|
$crawler = self::submitForm($crawler, 'create', 'choice', ['name' => $name, 'value' => 1, 'color' => 'green', 'icon' => 'ok']); |
41
|
|
|
|
42
|
|
|
// Check data in the show view |
43
|
|
|
$filter = 'tr:contains("' . $name . '")'; |
44
|
|
|
$crawler = self::checkElement($crawler, $filter); |
45
|
|
|
|
46
|
|
|
// Edit the choice |
47
|
|
|
$crawler = self::clickLink($crawler, 'edit'); |
48
|
|
|
$name = "M $name"; |
49
|
|
|
$crawler = self::submitForm($crawler, 'save', 'choice', ['name' => $name, 'value' => 1, 'color' => 'green']); |
50
|
|
|
|
51
|
|
|
// Check data in the show view |
52
|
|
|
$filter = 'tr:contains("' . $name . '")'; |
53
|
|
|
$crawler = self::checkElement($crawler, $filter); |
54
|
|
|
|
55
|
|
|
// Delete the choice |
56
|
|
|
$crawler = self::clickLink($crawler, 'edit'); |
57
|
|
|
$crawler = self::submitForm($crawler, 'delete'); |
58
|
|
|
|
59
|
|
|
// Check the choice has been deleted from the list |
60
|
|
|
$this->assertNotRegExp("/$name/", self::$client->getResponse()->getContent()); |
61
|
|
|
|
62
|
|
|
// Go back to the poll |
63
|
|
|
$crawler = self::clickLink($crawler, 'back'); |
64
|
|
|
|
65
|
|
|
// Delete the poll |
66
|
|
|
self::deletePollEntry($crawler); |
67
|
|
|
} |
68
|
|
|
} |
69
|
|
|
|