These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | namespace OpenOrchestra\FunctionalTests\BackofficeBundle\Controller; |
||
4 | |||
5 | use OpenOrchestra\FunctionalTests\Utils\AbstractFormTest; |
||
6 | use OpenOrchestra\ModelInterface\Model\NodeInterface; |
||
7 | use OpenOrchestra\ModelInterface\Repository\NodeRepositoryInterface; |
||
8 | use OpenOrchestra\ModelInterface\Repository\SiteRepositoryInterface; |
||
9 | |||
10 | /** |
||
11 | * Class SiteControllerTest |
||
12 | * |
||
13 | * @group backofficeTest |
||
14 | */ |
||
15 | class SiteControllerTest extends AbstractFormTest |
||
16 | { |
||
17 | /** |
||
18 | * @var NodeRepositoryInterface |
||
19 | */ |
||
20 | protected $nodeRepository; |
||
21 | |||
22 | /** |
||
23 | * @var SiteRepositoryInterface |
||
24 | */ |
||
25 | protected $siteRepository; |
||
26 | |||
27 | protected $siteId; |
||
28 | |||
29 | /** |
||
30 | * Set up the test |
||
31 | */ |
||
32 | public function setUp() |
||
33 | { |
||
34 | parent::setUp(); |
||
35 | |||
36 | $this->siteId = (string) microtime(true); |
||
37 | $this->nodeRepository = static::$kernel->getContainer()->get('open_orchestra_model.repository.node'); |
||
38 | $this->siteRepository = static::$kernel->getContainer()->get('open_orchestra_model.repository.site'); |
||
39 | } |
||
40 | |||
41 | /** |
||
42 | * Test when you create a site and update it |
||
43 | */ |
||
44 | public function testCreateSite() |
||
45 | { |
||
46 | $this->markTestSkipped(); |
||
47 | |||
48 | $this->assertNodeCount(0, 'fr'); |
||
49 | $this->assertNodeCount(0, 'en'); |
||
50 | |||
51 | $this->createSite(); |
||
52 | |||
53 | $this->assertNodeCount(1, 'fr'); |
||
54 | $this->assertNodeCount(0, 'en'); |
||
55 | |||
56 | $crawler = $this->client->request('GET', '/admin/site/form/' . $this->siteId); |
||
57 | $form = $crawler->selectButton('Save')->form(); |
||
58 | foreach($form->all() as $key => $value){ |
||
59 | if (preg_match('/^oo_site\[aliases\]\[.*\]\[language\]$/', $key)) { |
||
60 | $form[$key] = 'en'; |
||
61 | } |
||
62 | } |
||
63 | $this->submitForm($form); |
||
64 | |||
65 | $this->assertNodeCount(1, 'fr'); |
||
66 | $this->assertNodeCount(1, 'en'); |
||
67 | } |
||
68 | |||
69 | /** |
||
70 | * Test create 2 site with the same siteId only one is save |
||
71 | */ |
||
72 | public function testUniqueSiteId() |
||
73 | { |
||
74 | $this->markTestSkipped('Updated when site form is refacto'); |
||
75 | $this->assertSiteCount(0, $this->siteId); |
||
76 | |||
77 | $this->createSite(); |
||
78 | |||
79 | $this->assertSiteCount(1, $this->siteId); |
||
80 | |||
81 | $this->createSite(); |
||
82 | |||
83 | $this->assertSiteCount(1, $this->siteId); |
||
84 | } |
||
85 | |||
86 | /** |
||
87 | * Create a site |
||
88 | */ |
||
89 | protected function createSite() |
||
90 | { |
||
91 | $crawler = $this->client->request('GET', '/admin/site/new'); |
||
92 | |||
93 | $form = $crawler->selectButton('Save')->form(); |
||
94 | $form['oo_site[siteId]'] = $this->siteId; |
||
95 | $form['oo_site[name]'] = $this->siteId . 'domain'; |
||
96 | foreach($form->all() as $key => $value){ |
||
97 | if (preg_match('/^oo_site\[aliases\]\[.*\]\[domain\]$/', $key)) { |
||
98 | $form[$key] = $this->siteId . 'name'; |
||
99 | } |
||
100 | if (preg_match('/^oo_site\[aliases\]\[.*\]\[language\]$/', $key)) { |
||
101 | $form[$key] = 'fr'; |
||
102 | } |
||
103 | if (preg_match('/^oo_site\[aliases\]\[.*\]\[main\]$/', $key)) { |
||
104 | $form[$key] = true; |
||
105 | } |
||
106 | } |
||
107 | |||
108 | $this->submitForm($form); |
||
109 | } |
||
110 | |||
111 | /** |
||
112 | * @param int $count |
||
113 | * @param string $language |
||
114 | */ |
||
115 | protected function assertNodeCount($count, $language) |
||
116 | { |
||
117 | $nodes = $this->nodeRepository->findNotDeletedSortByUpdatedAt(NodeInterface::ROOT_NODE_ID, $language, $this->siteId); |
||
118 | |||
119 | $this->assertCount($count, $nodes); |
||
120 | } |
||
121 | |||
122 | /** |
||
123 | * @param int $count |
||
124 | * @param string $siteId |
||
125 | */ |
||
126 | protected function assertSiteCount($count, $siteId) |
||
127 | { |
||
128 | $sites = $this->siteRepository->findBy(array('siteId' => $siteId)); |
||
0 ignored issues
–
show
|
|||
129 | |||
130 | $this->assertCount($count, $sites); |
||
131 | } |
||
132 | } |
||
133 |
This check marks calls to methods that do not seem to exist on an object.
This is most likely the result of a method being renamed without all references to it being renamed likewise.