Skip to content

Commit

Permalink
feature: Assembly::containsDistinctFile (#16)
Browse files Browse the repository at this point in the history
* feature: Assembly::containsDistinctFile
closes #15

* build: update deps
  • Loading branch information
g105b authored Feb 21, 2022
1 parent 00c0f69 commit 72e6b4f
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 1 deletion.
11 changes: 11 additions & 0 deletions src/Assembly.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,17 @@ public function remove(string $path):void {
$this->pathList = array_values($this->pathList);
}

public function containsDistinctFile():bool {
foreach($this->pathList as $path) {
$fileName = pathinfo($path, PATHINFO_FILENAME);
if($fileName[0] !== "_") {
return true;
}
}

return false;
}

public function current():string {
return $this->pathList[$this->iteratorIndex];
}
Expand Down
27 changes: 27 additions & 0 deletions test/phpunit/AssemblyTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,31 @@ public function testIterator():void {
self::assertSame($pathList[$i], $path);
}
}

public function testContainsDistincFile_allMagic():void {
$pathList = [
"/var/www/_header.html",
"/var/www/_footer.html",
];
$sut = new Assembly();
foreach($pathList as $path) {
$sut->add($path);
}

self::assertFalse($sut->containsDistinctFile());
}

public function testContainsDistinctFile():void {
$pathList = [
"/var/www/_header.html",
"/var/www/index.html",
"/var/www/_footer.html",
];
$sut = new Assembly();
foreach($pathList as $path) {
$sut->add($path);
}

self::assertTrue($sut->containsDistinctFile());
}
}
2 changes: 1 addition & 1 deletion test/phpunit/phpunit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@
</testsuite>
</testsuites>
<logging/>
</phpunit>
</phpunit>

0 comments on commit 72e6b4f

Please sign in to comment.