@@ 193-208 (lines=16) @@ | ||
190 | ); |
|
191 | } |
|
192 | ||
193 | public function testGetTypeOfAnIncludeItemMustBeInclude() |
|
194 | { |
|
195 | $fsDataSource = new FilesystemDataSource([ |
|
196 | 'source_root' => $this->sourcePath, |
|
197 | 'text_extensions' => $this->textExtensions, |
|
198 | ]); |
|
199 | ||
200 | $fsDataSource->load(); |
|
201 | $includes = $fsDataSource->getIncludes(); |
|
202 | ||
203 | $this->assertEquals( |
|
204 | 'include', |
|
205 | $includes['test.html']->getType(), |
|
206 | 'The type of an include item must be "include"' |
|
207 | ); |
|
208 | } |
|
209 | ||
210 | public function testGetContentOfAnIncludeItemMustBeRight() |
|
211 | { |
|
@@ 210-225 (lines=16) @@ | ||
207 | ); |
|
208 | } |
|
209 | ||
210 | public function testGetContentOfAnIncludeItemMustBeRight() |
|
211 | { |
|
212 | $fsDataSource = new FilesystemDataSource([ |
|
213 | 'source_root' => $this->sourcePath, |
|
214 | 'text_extensions' => $this->textExtensions, |
|
215 | ]); |
|
216 | ||
217 | $fsDataSource->load(); |
|
218 | $includes = $fsDataSource->getIncludes(); |
|
219 | ||
220 | $this->assertRegExp( |
|
221 | '/Include test/', |
|
222 | $includes['test.html']->getContent(), |
|
223 | 'The content of the include item must contains the text "Include test"' |
|
224 | ); |
|
225 | } |
|
226 | ||
227 | public function testGetTypeOfAnLayoutItemMustBeLayout() |
|
228 | { |
|
@@ 261-275 (lines=15) @@ | ||
258 | ); |
|
259 | } |
|
260 | ||
261 | public function testGetBinaryOfAnItemMustReturnTrueIfThereIsNotFilenameExtension() |
|
262 | { |
|
263 | $fsDataSource = new FilesystemDataSource([ |
|
264 | 'source_root' => $this->sourcePath, |
|
265 | 'text_extensions' => $this->textExtensions, |
|
266 | ]); |
|
267 | ||
268 | $fsDataSource->load(); |
|
269 | $items = $fsDataSource->getItems(); |
|
270 | ||
271 | $this->assertTrue( |
|
272 | $items['LICENSE']->isBinary(), |
|
273 | 'An item without a filename extension must be treated as a binary item' |
|
274 | ); |
|
275 | } |
|
276 | ||
277 | public function testGetBinaryOfAnItemMustReturnFalseIfTheFilenameExtensionBelongsToTextExtensions() |
|
278 | { |
|
@@ 277-291 (lines=15) @@ | ||
274 | ); |
|
275 | } |
|
276 | ||
277 | public function testGetBinaryOfAnItemMustReturnFalseIfTheFilenameExtensionBelongsToTextExtensions() |
|
278 | { |
|
279 | $fsDataSource = new FilesystemDataSource([ |
|
280 | 'source_root' => $this->sourcePath, |
|
281 | 'text_extensions' => $this->textExtensions, |
|
282 | ]); |
|
283 | ||
284 | $fsDataSource->load(); |
|
285 | $items = $fsDataSource->getItems(); |
|
286 | ||
287 | $this->assertFalse( |
|
288 | $items['posts/2013-08-12-post-example-1.md']->isBinary(), |
|
289 | 'An item with a filename extension included in the text extension list must be treated as a text item' |
|
290 | ); |
|
291 | } |
|
292 | ||
293 | public function testGetBinaryOfAnItemMustReturnTrueIfTheFilenameExtensionDoesNotBelongsToTextExtensions() |
|
294 | { |
|
@@ 368-381 (lines=14) @@ | ||
365 | $this->assertArrayHasKey('extension', $itemAttributes); |
|
366 | } |
|
367 | ||
368 | public function testGetLayoutsMustGivesPreferenceSiteLayoutsOverThemeLayoutsWhenThereIsAEnabledTheme() |
|
369 | { |
|
370 | $fsDataSource = new FilesystemDataSource([ |
|
371 | 'source_root' => $this->sourcePath, |
|
372 | 'text_extensions' => $this->textExtensions, |
|
373 | 'theme_name' => 'theme01', |
|
374 | ]); |
|
375 | ||
376 | $fsDataSource->load(); |
|
377 | $layouts = $fsDataSource->getLayouts(); |
|
378 | ||
379 | $this->assertCount(2, $layouts); |
|
380 | $this->assertRegExp('/Welcome to my site/', $layouts['default.html']->getContent()); |
|
381 | } |
|
382 | ||
383 | public function testGetIncludesMustGivesPreferenceSiteIncludesOverThemeIncludesWhenThereIsAEnabledTheme() |
|
384 | { |
|
@@ 383-396 (lines=14) @@ | ||
380 | $this->assertRegExp('/Welcome to my site/', $layouts['default.html']->getContent()); |
|
381 | } |
|
382 | ||
383 | public function testGetIncludesMustGivesPreferenceSiteIncludesOverThemeIncludesWhenThereIsAEnabledTheme() |
|
384 | { |
|
385 | $fsDataSource = new FilesystemDataSource([ |
|
386 | 'source_root' => $this->sourcePath, |
|
387 | 'text_extensions' => $this->textExtensions, |
|
388 | 'theme_name' => 'theme01', |
|
389 | ]); |
|
390 | ||
391 | $fsDataSource->load(); |
|
392 | $includes = $fsDataSource->getIncludes(); |
|
393 | ||
394 | $this->assertCount(2, $includes); |
|
395 | $this->assertRegExp('/Include test/', $includes['test.html']->getContent()); |
|
396 | } |
|
397 | ||
398 | public function testGetItemsMustGivesPreferenceSiteAssetsOverThemeAssetsWhenThereIsAEnabledTheme() |
|
399 | { |
|
@@ 398-409 (lines=12) @@ | ||
395 | $this->assertRegExp('/Include test/', $includes['test.html']->getContent()); |
|
396 | } |
|
397 | ||
398 | public function testGetItemsMustGivesPreferenceSiteAssetsOverThemeAssetsWhenThereIsAEnabledTheme() |
|
399 | { |
|
400 | $fsDataSource = new FilesystemDataSource([ |
|
401 | 'source_root' => $this->sourcePath, |
|
402 | 'text_extensions' => $this->textExtensions, |
|
403 | 'theme_name' => 'theme01', |
|
404 | ]); |
|
405 | ||
406 | $fsDataSource->load(); |
|
407 | $items = $fsDataSource->getItems(); |
|
408 | $this->assertRegExp('/styles of the site/', $items['assets/style.css']->getContent()); |
|
409 | } |
|
410 | ||
411 | public function testGetItemsMustReturnThemeAssetsIfItDoesNotExistsInTheSiteAssetsWhenThereIsAEnabledTheme() |
|
412 | { |
|
@@ 426-439 (lines=14) @@ | ||
423 | $this->assertRegExp('/extra styles of the theme/', $items['assets/extra.css']->getContent()); |
|
424 | } |
|
425 | ||
426 | public function testGetIncludesMustReturnThemeIncludesIfItDoesNotExistsInTheSiteIncludesWhenThereIsAEnabledTheme() |
|
427 | { |
|
428 | $fsDataSource = new FilesystemDataSource([ |
|
429 | 'source_root' => $this->sourcePath, |
|
430 | 'text_extensions' => $this->textExtensions, |
|
431 | 'theme_name' => 'theme01', |
|
432 | ]); |
|
433 | ||
434 | $fsDataSource->load(); |
|
435 | $includes = $fsDataSource->getIncludes(); |
|
436 | ||
437 | $this->assertCount(2, $includes); |
|
438 | $this->assertRegExp('/Include theme 01 - test2/', $includes['test2.html']->getContent()); |
|
439 | } |
|
440 | ||
441 | public function testGetLayoutsMustReturnThemeLayoutsIfItDoesNotExistsInTheSiteLayoutsWhenThereIsAEnabledTheme() |
|
442 | { |
|
@@ 441-454 (lines=14) @@ | ||
438 | $this->assertRegExp('/Include theme 01 - test2/', $includes['test2.html']->getContent()); |
|
439 | } |
|
440 | ||
441 | public function testGetLayoutsMustReturnThemeLayoutsIfItDoesNotExistsInTheSiteLayoutsWhenThereIsAEnabledTheme() |
|
442 | { |
|
443 | $fsDataSource = new FilesystemDataSource([ |
|
444 | 'source_root' => $this->sourcePath, |
|
445 | 'text_extensions' => $this->textExtensions, |
|
446 | 'theme_name' => 'theme01', |
|
447 | ]); |
|
448 | ||
449 | $fsDataSource->load(); |
|
450 | $layouts = $fsDataSource->getLayouts(); |
|
451 | ||
452 | $this->assertCount(2, $layouts); |
|
453 | $this->assertRegExp('/Theme 01 layout/', $layouts['page.html']->getContent()); |
|
454 | } |
|
455 | ||
456 | public function testGetItemsMustReturnAnExtraItemWhenIncludeOptionIsSetWithAFile() |
|
457 | { |
|
@@ 456-468 (lines=13) @@ | ||
453 | $this->assertRegExp('/Theme 01 layout/', $layouts['page.html']->getContent()); |
|
454 | } |
|
455 | ||
456 | public function testGetItemsMustReturnAnExtraItemWhenIncludeOptionIsSetWithAFile() |
|
457 | { |
|
458 | $fsDataSource = new FilesystemDataSource([ |
|
459 | 'source_root' => $this->sourcePath, |
|
460 | 'include' => [$this->extraPagesPath.'/extra-page1.html'], |
|
461 | 'text_extensions' => $this->textExtensions, |
|
462 | ]); |
|
463 | $fsDataSource->load(); |
|
464 | $items = $fsDataSource->getItems(); |
|
465 | ||
466 | $this->assertCount(16, $items); |
|
467 | $this->assertArrayHasKey('extra-page1.html', $items); |
|
468 | } |
|
469 | ||
470 | public function testGetItemsMustReturnDotItemsWhenThereAreDotFiles() |
|
471 | { |
|
@@ 470-480 (lines=11) @@ | ||
467 | $this->assertArrayHasKey('extra-page1.html', $items); |
|
468 | } |
|
469 | ||
470 | public function testGetItemsMustReturnDotItemsWhenThereAreDotFiles() |
|
471 | { |
|
472 | $fsDataSource = new FilesystemDataSource([ |
|
473 | 'source_root' => $this->sourcePath, |
|
474 | 'text_extensions' => $this->textExtensions, |
|
475 | ]); |
|
476 | $fsDataSource->load(); |
|
477 | $items = $fsDataSource->getItems(); |
|
478 | ||
479 | $this->assertArrayHasKey('.htaccess', $items); |
|
480 | } |
|
481 | ||
482 | public function testGetItemsMustNotReturnItemsInVCSFolders() |
|
483 | { |