19 declare(strict_types=1);
33 return new class ($source, $target) implements
R\
PublicAsset {
35 protected string $source,
36 protected string $target,
40 public function getSource():
string 45 public function getTarget():
string 54 $this->manager =
new class () extends
R\PublicAssetManager {
59 protected function copy(
string $source, $target):
void 61 $this->copied[] = [$source, $target];
64 protected function purge(
string $path, array $dont_purge):
bool 66 $this->purged[] =
$path;
70 protected function makeDir(
string $path):
void 72 $this->madeDir[] =
$path;
79 $this->expectException(\LogicException::class);
84 $this->manager->addAssets($asset1, $asset2);
89 $this->expectException(\LogicException::class);
92 $asset2 = $this->
newPublicAsset(
"some/other/source",
"target/sub");
94 $this->manager->addAssets($asset1, $asset2);
99 $this->expectException(\LogicException::class);
104 $this->manager->addAssets($asset1, $asset2);
109 $this->manager->buildPublicFolder(
"/base",
"/target");
110 $this->assertEquals([], $this->manager->copied);
111 $this->assertEquals([
"/target"], $this->manager->purged);
112 $this->assertEquals([
"/target"], $this->manager->madeDir);
117 $this->manager->addAssets(
122 $this->manager->buildPublicFolder(
"/base",
"/public");
124 $this->assertEquals([
"/public"], $this->manager->purged);
125 $this->assertEquals([
"/public",
"/public/second"], $this->manager->madeDir);
126 $this->assertEquals([[
"/base/source1",
"/public/target1"], [
"/base/source2",
"/public/second/target"]], $this->manager->copied);
131 $this->expectNotToPerformAssertions();
133 $this->manager->buildPublicFolder(
"/base",
"/public");
134 $this->manager->buildPublicFolder(
"/srv/demo10-ilias",
"/public");
135 $this->manager->buildPublicFolder(
"/srv/demo10.ilias.de",
"/public");
143 $this->expectException(\InvalidArgumentException::class);
144 $this->manager->buildPublicFolder($ilias_base, $target);
150 'base - missing leading slash' => [
'base',
'/public'],
151 'base - extra trailing slash' => [
'/base/',
'/public'],
152 'base - dot only' => [
'.',
'/public'],
153 'base - dash only' => [
'-',
'/public'],
154 'base - invalid trailing dash' => [
'/base/demo-',
'/public'],
155 'base - invalid trailing dot' => [
'/base/demo.',
'/public'],
156 'base - invalid leading dash' => [
'/base/.demo',
'/public'],
157 'base - invalid leading dot' => [
'/base/-demo',
'/public'],
158 'base - invalid dot sub directory' => [
'/./test',
'/public'],
159 'base - invalid dash sub directory' => [
'/-/test',
'/public'],
160 'target - missing leading slash' => [
'/base',
'public'],
161 'target - extra trailing slash' => [
'/base',
'/public/'],
162 'target - dot only' => [
'/base',
'.'],
163 'target - dash only' => [
'/base',
'-'],
164 'target - invalid trailing dash' => [
'/base',
'/public.'],
165 'target - invalid trailing dot' => [
'/base',
'/public-'],
166 'target - invalid leading dash' => [
'/base',
'/.public'],
167 'target - invalid leading dot' => [
'/base',
'/-public'],
168 'target - invalid dot sub directory' => [
'/base',
'/./public'],
169 'target - invalid dash sub directory' => [
'/base',
'/-/public'],
static provideInvalidFolderPathData()
testTargetCanOnlyBeUsedOnce()
testTargetCanNotBeWithinOtherTarget2()
An public asset is a file or folder that should be served via the web.
__construct()
Constructor setup ILIAS global object public.
testTargetCanNotBeWithinOtherTarget1()
testInvalidFolderPaths(string $ilias_base, string $target)
provideInvalidFolderPathData
newPublicAsset($source, $target)
Will take care of the public assets, just like a good manager does.
testBuildAssetFolderEmpty()
R PublicAssetManager $manager