Skip to content

Commit

Permalink
Added hasPath method.
Browse files Browse the repository at this point in the history
  • Loading branch information
rotexdegba committed Sep 21, 2016
1 parent d32b0e6 commit a149d22
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/Renderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -419,6 +419,19 @@ public function prependPath( $path ) {
array_unshift($this->file_paths, $path);
}

/**
*
* Checks if a path has been registered for an instance of this class
*
* @param string $path
* @return bool
*/
public function hasPath($path) {

return in_array($path, $this->file_paths);
}


/**
*
* Removes the first `n` elements in the array of path(s) to directorie(s)
Expand Down
14 changes: 14 additions & 0 deletions tests/RendererTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,20 @@ public function testThatPrependPathWorksAsExpected() {
$this->assertEquals($expected_file_paths, $renderer->getFilePaths());
}

public function testThatHasPathWorksAsExpected() {

$expected_file_name = 'fizaile';
$expected_data = array( 'a'=>'b' );
$original_file_paths = array('/b');

$renderer = new FileRendererWrapper($expected_file_name, $expected_data, $original_file_paths);
$renderer->prependPath('/a');
$renderer->appendPath('/c');
$this->assertEquals( $renderer->hasPath('/a'), true);
$this->assertEquals( $renderer->hasPath('/b'), true);
$this->assertEquals( $renderer->hasPath('/c'), true);
}

public function testThatRemoveFirstNPathsWorksAsExpected() {

$expected_file_name = 'fizaile';
Expand Down

0 comments on commit a149d22

Please sign in to comment.