|
@@ -10,7 +10,7 @@ class GroupControllerTest extends FunctionalTest
|
10
|
10
|
/**
|
11
|
11
|
* Test de création d'un groupe
|
12
|
12
|
*/
|
13
|
|
- public function testGroupAdd()
|
|
13
|
+ public function testGroupAddAndDelete()
|
14
|
14
|
{
|
15
|
15
|
$this->client = self::createClient();
|
16
|
16
|
$this->connectUser('bob', 'toor');
|
|
@@ -78,6 +78,67 @@ class GroupControllerTest extends FunctionalTest
|
78
|
78
|
$this->assertEquals(1, count($group_tags));
|
79
|
79
|
}
|
80
|
80
|
|
|
81
|
+ // Maintenant on va supprimer le groupe fans de psytrance
|
|
82
|
+ $this->crawler = $this->client->request('GET', $this->generateUrl('groups_own_list'));
|
|
83
|
+ // test du lien de suppression
|
|
84
|
+
|
|
85
|
+ $this->exist('a[href="'.($url = $this->generateUrl('group_delete', array(
|
|
86
|
+ 'group_id' => $Fans_de_psytrance->getId(),
|
|
87
|
+ 'token' => $this->getUser()->getPersonalHash()
|
|
88
|
+ ))).'"]');
|
|
89
|
+
|
|
90
|
+ $this->crawler = $this->client->request('GET', $url);
|
|
91
|
+
|
|
92
|
+ $this->isResponseRedirection();
|
|
93
|
+ $this->followRedirection();
|
|
94
|
+ $this->isResponseSuccess();
|
|
95
|
+
|
|
96
|
+ $fangrp = $this->getDoctrine()->getRepository('MuzichCoreBundle:Group')->findOneByName('Fans de psytrance');
|
|
97
|
+
|
|
98
|
+ $this->assertTrue(is_null($fangrp));
|
|
99
|
+ }
|
|
100
|
+
|
|
101
|
+ public function testGroupAddFail()
|
|
102
|
+ {
|
|
103
|
+ $this->client = self::createClient();
|
|
104
|
+ $this->connectUser('bob', 'toor');
|
|
105
|
+
|
|
106
|
+ $Fans_de_psytrance = $this->getDoctrine()->getRepository('MuzichCoreBundle:Group')->findOneByName('Fans de psytrance');
|
|
107
|
+ $hardtek_id = $this->getDoctrine()->getRepository('MuzichCoreBundle:Tag')->findOneByName('Hardtek')->getId();
|
|
108
|
+ $tribe_id = $this->getDoctrine()->getRepository('MuzichCoreBundle:Tag')->findOneByName('Tribe')->getId();
|
|
109
|
+
|
|
110
|
+ $this->crawler = $this->client->request('GET', $this->generateUrl('groups_own_list'));
|
|
111
|
+
|
|
112
|
+ // Le groupe que nous voulons créer n'existe pas dans la base
|
|
113
|
+ $group = $this->getDoctrine()->getRepository('MuzichCoreBundle:Group')
|
|
114
|
+ ->findOneByName('Ha')
|
|
115
|
+ ;
|
|
116
|
+
|
|
117
|
+ $this->assertTrue(is_null($group));
|
|
118
|
+
|
|
119
|
+ // bob administre le groupe Fan de psytrance
|
|
120
|
+ $this->exist('a[href="'.$this->generateUrl('show_group', array('slug' => $Fans_de_psytrance->getSlug())).'"]');
|
|
121
|
+ // On a le formulaire de création sur la page
|
|
122
|
+ $this->exist('form[action="'.($url = $this->generateUrl('group_add')).'"]');
|
|
123
|
+ $this->exist('form[action="'.$url.'"] input[id="group_name"]');
|
|
124
|
+ $this->exist('form[action="'.$url.'"] textarea[id="group_description"]');
|
|
125
|
+ $this->exist('form[action="'.$url.'"] input[type="submit"]');
|
|
126
|
+
|
|
127
|
+ $form = $this->selectForm('form[action="'.$url.'"] input[type="submit"]');
|
|
128
|
+ $form['group[name]'] = 'Ha';
|
|
129
|
+ $form['group[description]'] = '';
|
|
130
|
+ $form['group[tags]'] = json_encode(array($hardtek_id,$tribe_id));
|
|
131
|
+ $this->submit($form);
|
|
132
|
+
|
|
133
|
+ // Pas de redirection, la création a échoué (nom trop court)
|
|
134
|
+ $this->outputDebug();
|
|
135
|
+ $this->isResponseSuccess();
|
|
136
|
+
|
|
137
|
+ // Le groupe que créé existe bien dans la base
|
|
138
|
+ $group = $this->getDoctrine()->getRepository('MuzichCoreBundle:Group')
|
|
139
|
+ ->findOneByName('Ha');
|
|
140
|
+
|
|
141
|
+ $this->assertTrue(is_null($group));
|
81
|
142
|
}
|
82
|
143
|
|
83
|
144
|
/**
|