configuration->setBaseUrl('https://www.domain.com/directory');
$this->builder->build($this->sourceFile(), $this->targetFile());
$contents = $this->getFileContents($this->targetFile('index.html'));
self::assertStringContainsString(
'Test reference url',
$contents
);
self::assertStringContainsString(
'
Base URL',
$contents
);
$contents = $this->getFileContents($this->targetFile('subdir/index.html'));
self::assertStringContainsString(
'Test subdir reference url',
$contents
);
self::assertStringContainsString(
'Base URL',
$contents
);
self::assertStringContainsString(
'Subdirectory File',
$contents
);
}
public function testBaseUrlEnabledCallable(): void
{
$this->configuration->setBaseUrl('https://www.domain.com/directory');
$this->configuration->setBaseUrlEnabledCallable(static function (string $path): bool {
return strpos($path, 'subdir/') !== 0;
});
$this->builder->build($this->sourceFile(), $this->targetFile());
$contents = $this->getFileContents($this->targetFile('index.html'));
self::assertStringContainsString(
'Test reference url',
$contents
);
self::assertStringContainsString(
'Base URL',
$contents
);
$contents = $this->getFileContents($this->targetFile('subdir/index.html'));
self::assertStringContainsString(
'Test subdir reference url',
$contents
);
self::assertStringContainsString(
'Test subdir file reference path',
$contents
);
self::assertStringContainsString(
'Subdirectory Index',
$contents
);
self::assertStringContainsString(
'Base URL',
$contents
);
self::assertStringContainsString(
'Subdirectory File',
$contents
);
}
public function testRelativeUrl(): void
{
$this->builder->build($this->sourceFile(), $this->targetFile());
$contents = $this->getFileContents($this->targetFile('index.html'));
self::assertStringContainsString(
'Test reference url',
$contents
);
self::assertStringContainsString(
'Base URL',
$contents
);
$contents = $this->getFileContents($this->targetFile('subdir/index.html'));
self::assertStringContainsString(
'Test subdir reference url',
$contents
);
self::assertStringContainsString(
'Base URL',
$contents
);
self::assertStringContainsString(
'Subdirectory File',
$contents
);
}
protected function setUp(): void
{
$this->configuration = new Configuration();
$this->configuration->setUseCachedMetas(false);
$this->builder = new Builder(new Kernel($this->configuration));
}
protected function getFixturesDirectory(): string
{
return 'BuilderUrl';
}
}