layoutPath = $this->guessViewPath('/layouts'); } } class ViewMakerTest extends TestCase { private $stub; private $relativePath; protected function normalizePath(string $path): string { return str_replace('/', DIRECTORY_SEPARATOR, $path); } public function setUp() : void { $this->createApplication(); $this->stub = new ViewMakerStub(); $this->relativePath = $this->normalizePath('modules/system/tests/traits/viewmakerstub'); } public function testViewPaths() { // Tests guessViewPath() and guessViewPathFrom() $this->assertEquals( $this->normalizePath(base_path($this->relativePath)), $this->normalizePath($this->stub->guessViewPath()) ); // Request a view path first to set the default $path = $this->stub->getViewPath('_overridden.php'); $this->assertEquals( $this->normalizePath(base_path("$this->relativePath/_overridden.php")), $this->normalizePath($path) ); // Test prependViewPath() & getViewPaths() $overridePath = "~/{$this->relativePath}override"; $this->stub->prependViewPath($overridePath); $this->assertEquals( [ $this->normalizePath($overridePath), $this->normalizePath(base_path($this->relativePath)), ], array_map(function ($path) { return $this->normalizePath($path); }, $this->stub->getViewPaths()) ); // Test override taking effect $this->assertEquals('overridden', trim($this->stub->makePartial('overridden'))); // Test override of PHP base file with HTM overriding file $this->assertEquals('overridden', trim($this->stub->makePartial('can_override_php_with_htm'))); // Test getViewPath() $paths = [ 'non_existant' => 'non_existant', 'view.php' => base_path($this->relativePath . '/view.php'), '_overridden.php' => base_path($this->relativePath . 'override/_overridden.php'), '_can_override_php_with_htm.php' => base_path($this->relativePath . 'override/_can_override_php_with_htm.htm'), "~/{$this->relativePath}/symbols.php" => base_path($this->relativePath . '/symbols.php'), ]; foreach ($paths as $path => $expected) { $this->assertEquals($this->normalizePath($expected), $this->normalizePath($this->stub->getViewPath($path))); } } public function testMakePartial() { $sectionContent = '' . PHP_EOL . '
comment
' . PHP_EOL . '