diff --git a/src/Assembly.php b/src/Assembly.php index 7ce7953..3e3c5ac 100644 --- a/src/Assembly.php +++ b/src/Assembly.php @@ -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]; } diff --git a/test/phpunit/AssemblyTest.php b/test/phpunit/AssemblyTest.php index be64fe7..cbebc4d 100644 --- a/test/phpunit/AssemblyTest.php +++ b/test/phpunit/AssemblyTest.php @@ -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()); + } } diff --git a/test/phpunit/phpunit.xml b/test/phpunit/phpunit.xml index cf95bea..ff2e2a2 100644 --- a/test/phpunit/phpunit.xml +++ b/test/phpunit/phpunit.xml @@ -15,4 +15,4 @@ - \ No newline at end of file +