Skip to content

Commit 72e6b4f

Browse files
author
Greg Bowler
authored
feature: Assembly::containsDistinctFile (#16)
* feature: Assembly::containsDistinctFile closes #15 * build: update deps
1 parent 00c0f69 commit 72e6b4f

File tree

3 files changed

+39
-1
lines changed

3 files changed

+39
-1
lines changed

src/Assembly.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,17 @@ public function remove(string $path):void {
3333
$this->pathList = array_values($this->pathList);
3434
}
3535

36+
public function containsDistinctFile():bool {
37+
foreach($this->pathList as $path) {
38+
$fileName = pathinfo($path, PATHINFO_FILENAME);
39+
if($fileName[0] !== "_") {
40+
return true;
41+
}
42+
}
43+
44+
return false;
45+
}
46+
3647
public function current():string {
3748
return $this->pathList[$this->iteratorIndex];
3849
}

test/phpunit/AssemblyTest.php

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,4 +65,31 @@ public function testIterator():void {
6565
self::assertSame($pathList[$i], $path);
6666
}
6767
}
68+
69+
public function testContainsDistincFile_allMagic():void {
70+
$pathList = [
71+
"/var/www/_header.html",
72+
"/var/www/_footer.html",
73+
];
74+
$sut = new Assembly();
75+
foreach($pathList as $path) {
76+
$sut->add($path);
77+
}
78+
79+
self::assertFalse($sut->containsDistinctFile());
80+
}
81+
82+
public function testContainsDistinctFile():void {
83+
$pathList = [
84+
"/var/www/_header.html",
85+
"/var/www/index.html",
86+
"/var/www/_footer.html",
87+
];
88+
$sut = new Assembly();
89+
foreach($pathList as $path) {
90+
$sut->add($path);
91+
}
92+
93+
self::assertTrue($sut->containsDistinctFile());
94+
}
6895
}

test/phpunit/phpunit.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,4 @@
1515
</testsuite>
1616
</testsuites>
1717
<logging/>
18-
</phpunit>
18+
</phpunit>

0 commit comments

Comments
 (0)