Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9a38731
commit 8ae2222
Showing
1 changed file
with
38 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -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]); | |||
} | |||
} | |||
} |