ParticipationControllerTest   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 54
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 1
lcom 1
cbo 1
dl 0
loc 54
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A testCompleteScenario() 0 48 1
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 ParticipationControllerTest extends PollWebTestCase
25
{
26
    /**
27
     * Creates, edits and deletes a participation
28
     */
29
    public function testCompleteScenario()
30
    {
31
        // Create a poll to work with
32
        $crawler = self::createPollEntry();
33
34
        // Create a participant
35
        $participant = uniqid('Test Participant ');
36
        $crawler = self::submitForm($crawler, 'add.a.participant', 'participant', ['name' => $participant]);
37
38
        // Create an event
39
        $event = uniqid('Test Event ');
40
        $crawler = self::clickLink($crawler, 'add.a.date');
41
        $crawler = self::submitForm($crawler, 'create', 'event',
42
            ['name' => $event, 'place' => 'Nowhere', 'date' => date('d-m-Y', strtotime("tomorrow")), 'time' => '20:30']);
43
44
        // Check "yes" is not selected
45
        $filter = 'button.dropdown-toggle:contains("' . self::$translator->trans('yes') . '")';
46
        self::checkElement($crawler, $filter, 0);
47
48
        // Choose "yes"
49
        $button = $crawler->selectButton(self::$translator->trans('yes'));
50
        $url = $button->extract(['data-url'])[0];
51
        self::$client->request('GET', $url);
52
        self::$client->back();
53
        $crawler = self::$client->reload();
54
55
        // Check "yes is selected
56
        $filter = 'button.dropdown-toggle:contains("' . self::$translator->trans('yes') . '")';
57
        self::checkElement($crawler, $filter, 1);
58
59
        // Choose "no"
60
        $button = $crawler->selectButton(self::$translator->trans('no'));
61
        $url = $button->extract(['data-url'])[0];
62
        self::$client->request('GET', $url);
63
        self::$client->back();
64
        $crawler = self::$client->reload();
65
66
        // Check "yes" is not selected anymore
67
        $filter = 'button.dropdown-toggle:contains("' . self::$translator->trans('yes') . '")';
68
        self::checkElement($crawler, $filter, 0);
69
70
        // Check "no" is selected
71
        $filter = 'button.dropdown-toggle:contains("' . self::$translator->trans('no') . '")';
72
        self::checkElement($crawler, $filter, 1);
73
74
        // Delete the poll
75
        self::deletePollEntry($crawler);
76
    }
77
}
78