@@ 26-69 (lines=44) @@ | ||
23 | class CrudGeneratorGeneratorTest extends GeneratorTest |
|
24 | { |
|
25 | ||
26 | public function testGenerateYamlFull() |
|
27 | { |
|
28 | $advancedConfig = new Configuration(); |
|
29 | $advancedConfig->setRoutePrefix('post'); |
|
30 | $advancedConfig->setFormat('yml'); |
|
31 | $advancedConfig->setOverwrite(true); |
|
32 | ||
33 | $this->getGenerator()->generateCrud($this->getBundle(), 'Post', $this->getMetadata(), $advancedConfig); |
|
34 | $files = array( |
|
35 | 'Controller/PostController.php', |
|
36 | 'Tests/Controller/PostControllerTest.php', |
|
37 | 'Resources/config/routing/post.yml', |
|
38 | 'Resources/views/post/index.html.twig', |
|
39 | 'Resources/views/post/show.html.twig', |
|
40 | 'Resources/views/post/new.html.twig', |
|
41 | 'Resources/views/post/edit.html.twig', |
|
42 | ); |
|
43 | foreach ($files as $file) { |
|
44 | $this->assertTrue(file_exists($this->tmpDir . '/' . $file), sprintf('%s has been generated', $file)); |
|
45 | } |
|
46 | $files = array( |
|
47 | 'Resources/config/routing/post.xml', |
|
48 | ); |
|
49 | foreach ($files as $file) { |
|
50 | $this->assertFalse(file_exists($this->tmpDir . '/' . $file), sprintf('%s has not been generated', $file)); |
|
51 | } |
|
52 | $content = file_get_contents($this->tmpDir . '/Controller/PostController.php'); |
|
53 | $strings = array( |
|
54 | 'namespace Foo\BarBundle\Controller;', |
|
55 | 'public function indexAction', |
|
56 | 'public function showAction', |
|
57 | 'public function newAction', |
|
58 | 'public function editAction', |
|
59 | ); |
|
60 | foreach ($strings as $string) { |
|
61 | $this->assertContains($string, $content); |
|
62 | } |
|
63 | ||
64 | ||
65 | $this->assertBulk(); |
|
66 | $this->assertPagination(); |
|
67 | $this->assertSorting(); |
|
68 | $this->assertPageSize(); |
|
69 | } |
|
70 | ||
71 | public function testGenerateXml() |
|
72 | { |
|
@@ 119-161 (lines=43) @@ | ||
116 | $this->assertPageSize(); |
|
117 | } |
|
118 | ||
119 | public function testGenerateAnnotationWrite() |
|
120 | { |
|
121 | $advancedConfig = new Configuration(); |
|
122 | $advancedConfig->setFormat('annotation'); |
|
123 | $advancedConfig->setRoutePrefix('/post'); |
|
124 | $this->getGenerator()->generateCrud($this->getBundle(), 'Post', $this->getMetadata(), $advancedConfig); |
|
125 | $files = array( |
|
126 | 'Controller/PostController.php', |
|
127 | 'Tests/Controller/PostControllerTest.php', |
|
128 | 'Resources/views/post/index.html.twig', |
|
129 | 'Resources/views/post/show.html.twig', |
|
130 | 'Resources/views/post/new.html.twig', |
|
131 | 'Resources/views/post/edit.html.twig', |
|
132 | ); |
|
133 | foreach ($files as $file) { |
|
134 | $this->assertTrue(file_exists($this->tmpDir . '/' . $file), sprintf('%s has been generated', $file)); |
|
135 | } |
|
136 | $files = array( |
|
137 | 'Resources/config/routing/post.yml', |
|
138 | 'Resources/config/routing/post.xml', |
|
139 | ); |
|
140 | foreach ($files as $file) { |
|
141 | $this->assertFalse(file_exists($this->tmpDir . '/' . $file), sprintf('%s has not been generated', $file)); |
|
142 | } |
|
143 | $content = file_get_contents($this->tmpDir . '/Controller/PostController.php'); |
|
144 | $strings = array( |
|
145 | 'namespace Foo\BarBundle\Controller;', |
|
146 | 'public function indexAction', |
|
147 | 'public function showAction', |
|
148 | 'public function newAction', |
|
149 | 'public function editAction', |
|
150 | '@Route', |
|
151 | ); |
|
152 | foreach ($strings as $string) { |
|
153 | $this->assertContains($string, $content); |
|
154 | } |
|
155 | ||
156 | ||
157 | $this->assertBulk(); |
|
158 | $this->assertPagination(); |
|
159 | $this->assertSorting(); |
|
160 | $this->assertPageSize(); |
|
161 | } |
|
162 | ||
163 | public function testGenerateAnnotation() |
|
164 | { |
|
@@ 163-204 (lines=42) @@ | ||
160 | $this->assertPageSize(); |
|
161 | } |
|
162 | ||
163 | public function testGenerateAnnotation() |
|
164 | { |
|
165 | $advancedConfig = new Configuration(); |
|
166 | $advancedConfig->setRoutePrefix('post'); |
|
167 | $advancedConfig->setFormat('annotation'); |
|
168 | $advancedConfig->setOverwrite(true); |
|
169 | ||
170 | $this->getGenerator()->generateCrud($this->getBundle(), 'Post', $this->getMetadata(), $advancedConfig); |
|
171 | $files = array( |
|
172 | 'Controller/PostController.php', |
|
173 | 'Tests/Controller/PostControllerTest.php', |
|
174 | 'Resources/views/post/index.html.twig', |
|
175 | 'Resources/views/post/show.html.twig', |
|
176 | 'Resources/views/post/new.html.twig', |
|
177 | 'Resources/views/post/edit.html.twig', |
|
178 | ); |
|
179 | foreach ($files as $file) { |
|
180 | $this->assertTrue(file_exists($this->tmpDir . '/' . $file), sprintf('%s has been generated', $file)); |
|
181 | } |
|
182 | $files = array( |
|
183 | 'Resources/config/routing/post.yml', |
|
184 | 'Resources/config/routing/post.xml', |
|
185 | ); |
|
186 | foreach ($files as $file) { |
|
187 | $this->assertFalse(file_exists($this->tmpDir . '/' . $file), sprintf('%s has not been generated', $file)); |
|
188 | } |
|
189 | $content = file_get_contents($this->tmpDir . '/Controller/PostController.php'); |
|
190 | $strings = array( |
|
191 | 'namespace Foo\BarBundle\Controller;', |
|
192 | 'public function indexAction', |
|
193 | 'public function showAction', |
|
194 | '@Route', |
|
195 | ); |
|
196 | foreach ($strings as $string) { |
|
197 | $this->assertContains($string, $content); |
|
198 | } |
|
199 | ||
200 | $this->assertBulk(); |
|
201 | $this->assertPagination(); |
|
202 | $this->assertSorting(); |
|
203 | $this->assertPageSize(); |
|
204 | } |
|
205 | ||
206 | public function testGenerateWithBaseTemplate() |
|
207 | { |