Browse files

Added ByYear listener tests

  • Loading branch information...
1 parent 9a38731 commit 8ae2222fbaf433208d1dc930e7191e19573a1d04 @weierophinney weierophinney committed Apr 12, 2012
Showing with 38 additions and 0 deletions.
  1. +38 −0 test/PhlyBlog/Compiler/Listener/ByYearTest.php
View
38 test/PhlyBlog/Compiler/Listener/ByYearTest.php
@@ -0,0 +1,38 @@
+<?php
+namespace PhlyBlog\Compiler\Listener;
+
+use PHPUnit_Framework_TestCase as TestCase;
+
+class ByYearTest extends TestCase
+{
+ public function setUp()
+ {
+ TestHelper::injectScaffolds($this);
+ $this->byYear = new ByYear($this->view, $this->writer, $this->file, $this->options);
+ $this->compiler->events()->attach($this->byYear);
+ }
+
+ public function testCreatesNoFilesPriorToCompilation()
+ {
+ $this->byYear->compile();
+ $this->assertTrue(empty($this->writer->files));
+ }
+
+ public function testCreatesFilesFollowingCompilation()
+ {
+ $this->compiler->compile();
+ $this->byYear->compile();
+
+ $this->assertFalse(empty($this->writer->files));
+
+ $filenameTemplate = $this->options->getByYearFilenameTemplate();
+ $filenameTemplate = str_replace('-p%d', '', $filenameTemplate);
+ $yearTitleTemplate = $this->options->getByYearTitle();
+ foreach ($this->expected['years'] as $year) {
+ $filename = sprintf($filenameTemplate, $year);
+ $this->assertArrayHasKey($filename, $this->writer->files);
+ $yearTitle = sprintf($yearTitleTemplate, $year);
+ $this->assertContains($yearTitle, $this->writer->files[$filename]);
+ }
+ }
+}

0 comments on commit 8ae2222

Please sign in to comment.