19declare(strict_types=1);
24use PHPUnit\Framework\TestCase;
26use PHPUnit\Framework\Attributes\DataProvider;
34 return new class ($source, $target) implements
R\
PublicAsset {
36 protected string $source,
37 protected string $target,
41 public function getSource():
string
46 public function getTarget():
string
55 $this->manager =
new class () extends
R\PublicAssetManager {
60 protected function copy(
string $source, $target):
void
62 $this->copied[] = [$source, $target];
65 protected function purge(
string $path, array $dont_purge):
bool
67 $this->purged[] =
$path;
71 protected function makeDir(
string $path):
void
73 $this->madeDir[] =
$path;
78 #[DataProvider('provideValidBasePathData')]
81 $this->assertIsString($base_path);
82 $this->manager->buildPublicFolder($base_path,
'/target');
87 yield [
'/var/www/ilias'];
88 yield [
'/var/www/html'];
89 yield [
'/var/www/html/ilias'];
91 yield [
'/srv/ilias10'];
92 yield [
'/srv/ilias-10'];
93 yield [
'/srv/ilias_10'];
94 yield [
'/srv/ilias.10'];
99 yield [
'/var/www/vhosts/bl-a.blubs/httpdoc'];
100 yield [
'/var/www/v_hosts/bl-a.blubs/httpdoc'];
101 yield [
'/var/www/v_hosts/bl-a.blubs_one/httpdoc'];
102 yield [
'/srv/ilias-build/work/ilias-10.4.0'];
107 $this->expectException(\LogicException::class);
112 $this->manager->addAssets($asset1, $asset2);
117 $this->expectException(\LogicException::class);
120 $asset2 = $this->
newPublicAsset(
"some/other/source",
"target/sub");
122 $this->manager->addAssets($asset1, $asset2);
127 $this->expectException(\LogicException::class);
132 $this->manager->addAssets($asset1, $asset2);
137 $this->manager->buildPublicFolder(
"/base",
"/target");
138 $this->assertEquals([], $this->manager->copied);
139 $this->assertEquals([
"/target"], $this->manager->purged);
140 $this->assertEquals([
"/target"], $this->manager->madeDir);
145 $this->manager->addAssets(
150 $this->manager->buildPublicFolder(
"/base",
"/public");
152 $this->assertEquals([
"/public"], $this->manager->purged);
153 $this->assertEquals([
"/public",
"/public/second"], $this->manager->madeDir);
155 [[
"/base/source1",
"/public/target1"], [
"/base/source2",
"/public/second/target"]],
156 $this->manager->copied
162 $this->expectNotToPerformAssertions();
164 $this->manager->buildPublicFolder(
"/base",
"/public");
165 $this->manager->buildPublicFolder(
"/srv/demo10-ilias",
"/public");
166 $this->manager->buildPublicFolder(
"/srv/demo10.ilias.de",
"/public");
169 #[DataProvider('provideInvalidFolderPathData')]
172 $this->expectException(\InvalidArgumentException::class);
173 $this->manager->buildPublicFolder($ilias_base, $target);
178 yield
'base - missing leading slash' => [
'base',
'/public'];
179 yield
'base - extra trailing slash' => [
'/base/',
'/public'];
180 yield
'base - dot only' => [
'.',
'/public'];
181 yield
'base - dash only' => [
'-',
'/public'];
182 yield
'base - invalid trailing dash' => [
'/base/demo-',
'/public'];
183 yield
'base - invalid trailing dot' => [
'/base/demo.',
'/public'];
184 yield
'base - invalid leading dash' => [
'/base/.demo',
'/public'];
185 yield
'base - invalid leading dot' => [
'/base/-demo',
'/public'];
186 yield
'base - invalid dot sub directory' => [
'/./test',
'/public'];
187 yield
'base - invalid dash sub directory' => [
'/-/test',
'/public'];
188 yield
'target - missing leading slash' => [
'/base',
'public'];
189 yield
'target - extra trailing slash' => [
'/base',
'/public/'];
190 yield
'target - dot only' => [
'/base',
'.'];
191 yield
'target - dash only' => [
'/base',
'-'];
192 yield
'target - invalid trailing dash' => [
'/base',
'/public.'];
193 yield
'target - invalid trailing dot' => [
'/base',
'/public-'];
194 yield
'target - invalid leading dash' => [
'/base',
'/.public'];
195 yield
'target - invalid leading dot' => [
'/base',
'/-public'];
196 yield
'target - invalid dot sub directory' => [
'/base',
'/./public'];
197 yield
'target - invalid dash sub directory' => [
'/base',
'/-/public'];
Will take care of the public assets, just like a good manager does.
static provideInvalidFolderPathData()
testTargetCanOnlyBeUsedOnce()
static provideValidBasePathData()
testTargetCanNotBeWithinOtherTarget2()
testTargetCanNotBeWithinOtherTarget1()
newPublicAsset($source, $target)
R PublicAssetManager $manager
testBuildAssetFolderEmpty()
testDifferentBasePaths(string $base_path)
testInvalidFolderPaths(string $ilias_base, string $target)
__construct()
Constructor setup ILIAS global object @access public.
An public asset is a file or folder that should be served via the web.