|
@@ -0,0 +1,76 @@
|
|
1
|
+<?php
|
|
2
|
+
|
|
3
|
+namespace Muzich\CoreBundle\Tests\Controller;
|
|
4
|
+
|
|
5
|
+use Muzich\CoreBundle\lib\FunctionalTest;
|
|
6
|
+use Muzich\CoreBundle\Searcher\ElementSearcher;
|
|
7
|
+
|
|
8
|
+class HomeControllerTest extends FunctionalTest
|
|
9
|
+{
|
|
10
|
+ /**
|
|
11
|
+ * Ce test contrôle l'affichage des elements sur la page d'accueil
|
|
12
|
+ * Il modifie egallement le filtre d'éléments
|
|
13
|
+ */
|
|
14
|
+ public function testFilter()
|
|
15
|
+ {
|
|
16
|
+ $this->connectUser('bux', 'toor');
|
|
17
|
+
|
|
18
|
+ // Présence du formulaire d'ajout d'un élément
|
|
19
|
+ $this->exist('form[action="'.($url = $this->generateUrl('element_add')).'"]');
|
|
20
|
+ $this->exist('form[action="'.$url.'"] input[id="element_add_name"]');
|
|
21
|
+ $this->exist('form[action="'.$url.'"] input[id="element_add_url"]');
|
|
22
|
+ $this->exist('form[action="'.$url.'"] select[id="element_add_group"]');
|
|
23
|
+ $this->exist('form[action="'.$url.'"] input[type="submit"]');
|
|
24
|
+
|
|
25
|
+ // Présence du formulaire de filtrage
|
|
26
|
+ $this->exist('form[action="'.($url = $this->generateUrl('search_elements')).'"]');
|
|
27
|
+ $this->exist('form[action="'.$url.'"] select[id="element_search_form_network"]');
|
|
28
|
+ $this->exist('form[action="'.$url.'"] input[type="submit"]');
|
|
29
|
+
|
|
30
|
+ $hardtek_id = $this->getDoctrine()->getRepository('MuzichCoreBundle:Tag')->findOneByName('Hardtek')->getId();
|
|
31
|
+ $tribe_id = $this->getDoctrine()->getRepository('MuzichCoreBundle:Tag')->findOneByName('Tribe')->getId();
|
|
32
|
+
|
|
33
|
+ // On récupére le formulaire de filtrage
|
|
34
|
+ $form = $this->selectForm('form[action="'.$url.'"] input[type="submit"]');
|
|
35
|
+
|
|
36
|
+ // On décoche les tags
|
|
37
|
+ foreach ($this->getDoctrine()->getRepository('MuzichCoreBundle:Tag')->findAll() as $tag)
|
|
38
|
+ {
|
|
39
|
+ $form['element_search_form[tags]['.$tag->getId().']']->untick();
|
|
40
|
+ }
|
|
41
|
+
|
|
42
|
+ // On met ce que l'on veut dans le form
|
|
43
|
+ $form['element_search_form[network]'] = ElementSearcher::NETWORK_PUBLIC;
|
|
44
|
+ $form['element_search_form[tags]['.$hardtek_id.']'] = $hardtek_id;
|
|
45
|
+ $form['element_search_form[tags]['.$tribe_id.']'] = $tribe_id;
|
|
46
|
+ $this->submit($form);
|
|
47
|
+
|
|
48
|
+ $this->client->submit($form);
|
|
49
|
+
|
|
50
|
+ $this->isResponseRedirection();
|
|
51
|
+ $this->followRedirection();
|
|
52
|
+ $this->isResponseSuccess();
|
|
53
|
+
|
|
54
|
+ $this->assertTrue($this->getSession()->has('user.element_search.params'));
|
|
55
|
+ $this->assertEquals(array(
|
|
56
|
+ 'network' => ElementSearcher::NETWORK_PUBLIC,
|
|
57
|
+ 'tags' => array(
|
|
58
|
+ $hardtek_id, $tribe_id
|
|
59
|
+ ),
|
|
60
|
+ 'count' => $this->getContainer()->getParameter('search_default_count'),
|
|
61
|
+ 'user_id' => null,
|
|
62
|
+ 'group_id' => null,
|
|
63
|
+ 'favorite' => false
|
|
64
|
+ ), $this->getSession()->get('user.element_search.params'));
|
|
65
|
+
|
|
66
|
+ // On fabrique l'ElementSearcher correspondant
|
|
67
|
+ $es = new ElementSearcher();
|
|
68
|
+ $es->init($this->getSession()->get('user.element_search.params'));
|
|
69
|
+
|
|
70
|
+ foreach ($es->getElements($this->getDoctrine(), $this->getUser()->getId()) as $element)
|
|
71
|
+ {
|
|
72
|
+ $this->exist('html:contains("'.$element->getName().'")');
|
|
73
|
+ }
|
|
74
|
+ }
|
|
75
|
+
|
|
76
|
+}
|