ILIAS  trunk Revision v12.0_alpha-1221-g4e438232683
ILIAS\Component\Tests\Resource\PublicAssetManagerTest Class Reference
+ Inheritance diagram for ILIAS\Component\Tests\Resource\PublicAssetManagerTest:
+ Collaboration diagram for ILIAS\Component\Tests\Resource\PublicAssetManagerTest:

Public Member Functions

 setUp ()
 
 testDifferentBasePaths (string $base_path)
 
 testTargetCanOnlyBeUsedOnce ()
 
 testTargetCanNotBeWithinOtherTarget1 ()
 
 testTargetCanNotBeWithinOtherTarget2 ()
 
 testBuildAssetFolderEmpty ()
 
 testBuildAssetFolder ()
 
 testValidFolderPaths ()
 
 testInvalidFolderPaths (string $ilias_base, string $target)
 

Static Public Member Functions

static provideValidBasePathData ()
 
static provideInvalidFolderPathData ()
 

Protected Member Functions

 newPublicAsset ($source, $target)
 

Protected Attributes

R PublicAssetManager $manager
 

Detailed Description

Definition at line 28 of file PublicAssetManagerTest.php.

Member Function Documentation

◆ newPublicAsset()

ILIAS\Component\Tests\Resource\PublicAssetManagerTest::newPublicAsset (   $source,
  $target 
)
protected

Definition at line 32 of file PublicAssetManagerTest.php.

32 : PublicAsset
33 {
34 return new class ($source, $target) implements R\PublicAsset {
35 public function __construct(
36 protected string $source,
37 protected string $target,
38 ) {
39 }
40
41 public function getSource(): string
42 {
43 return $this->source;
44 }
45
46 public function getTarget(): string
47 {
48 return $this->target;
49 }
50 };
51 }
__construct()
Constructor setup ILIAS global object @access public.
Definition: class.ilias.php:76

References ILIAS\__construct().

Referenced by ILIAS\Component\Tests\Resource\PublicAssetManagerTest\testBuildAssetFolder(), ILIAS\Component\Tests\Resource\PublicAssetManagerTest\testTargetCanNotBeWithinOtherTarget1(), ILIAS\Component\Tests\Resource\PublicAssetManagerTest\testTargetCanNotBeWithinOtherTarget2(), and ILIAS\Component\Tests\Resource\PublicAssetManagerTest\testTargetCanOnlyBeUsedOnce().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ provideInvalidFolderPathData()

static ILIAS\Component\Tests\Resource\PublicAssetManagerTest::provideInvalidFolderPathData ( )
static

Definition at line 176 of file PublicAssetManagerTest.php.

176 : \Iterator
177 {
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'];
198 }

◆ provideValidBasePathData()

static ILIAS\Component\Tests\Resource\PublicAssetManagerTest::provideValidBasePathData ( )
static

Definition at line 85 of file PublicAssetManagerTest.php.

85 : \Iterator
86 {
87 yield ['/var/www/ilias'];
88 yield ['/var/www/html'];
89 yield ['/var/www/html/ilias'];
90 yield ['/srv/ilias'];
91 yield ['/srv/ilias10'];
92 yield ['/srv/ilias-10'];
93 yield ['/srv/ilias_10'];
94 yield ['/srv/ilias.10'];
95 yield ['/base'];
96 yield ['/base/path'];
97 yield ['/base-path'];
98 yield ['/base.path'];
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'];
103 }

◆ setUp()

ILIAS\Component\Tests\Resource\PublicAssetManagerTest::setUp ( )

Definition at line 53 of file PublicAssetManagerTest.php.

53 : void
54 {
55 $this->manager = new class () extends R\PublicAssetManager {
56 public $copied = [];
57 public $purged = [];
58 public $madeDir = [];
59
60 protected function copy(string $source, $target): void
61 {
62 $this->copied[] = [$source, $target];
63 }
64
65 protected function purge(string $path, array $dont_purge): bool
66 {
67 $this->purged[] = $path;
68 return true;
69 }
70
71 protected function makeDir(string $path): void
72 {
73 $this->madeDir[] = $path;
74 }
75 };
76 }
$path
Definition: ltiservices.php:30

References $path.

◆ testBuildAssetFolder()

ILIAS\Component\Tests\Resource\PublicAssetManagerTest::testBuildAssetFolder ( )

Definition at line 143 of file PublicAssetManagerTest.php.

143 : void
144 {
145 $this->manager->addAssets(
146 $this->newPublicAsset("source1", "target1"),
147 $this->newPublicAsset("source2", "second/target")
148 );
149
150 $this->manager->buildPublicFolder("/base", "/public");
151
152 $this->assertEquals(["/public"], $this->manager->purged);
153 $this->assertEquals(["/public", "/public/second"], $this->manager->madeDir);
154 $this->assertEquals(
155 [["/base/source1", "/public/target1"], ["/base/source2", "/public/second/target"]],
156 $this->manager->copied
157 );
158 }

References ILIAS\Component\Tests\Resource\PublicAssetManagerTest\newPublicAsset().

+ Here is the call graph for this function:

◆ testBuildAssetFolderEmpty()

ILIAS\Component\Tests\Resource\PublicAssetManagerTest::testBuildAssetFolderEmpty ( )

Definition at line 135 of file PublicAssetManagerTest.php.

135 : void
136 {
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);
141 }

◆ testDifferentBasePaths()

ILIAS\Component\Tests\Resource\PublicAssetManagerTest::testDifferentBasePaths ( string  $base_path)

Definition at line 79 of file PublicAssetManagerTest.php.

79 : void
80 {
81 $this->assertIsString($base_path);
82 $this->manager->buildPublicFolder($base_path, '/target');
83 }

◆ testInvalidFolderPaths()

ILIAS\Component\Tests\Resource\PublicAssetManagerTest::testInvalidFolderPaths ( string  $ilias_base,
string  $target 
)

Definition at line 170 of file PublicAssetManagerTest.php.

170 : void
171 {
172 $this->expectException(\InvalidArgumentException::class);
173 $this->manager->buildPublicFolder($ilias_base, $target);
174 }

◆ testTargetCanNotBeWithinOtherTarget1()

ILIAS\Component\Tests\Resource\PublicAssetManagerTest::testTargetCanNotBeWithinOtherTarget1 ( )

Definition at line 115 of file PublicAssetManagerTest.php.

115 : void
116 {
117 $this->expectException(\LogicException::class);
118
119 $asset1 = $this->newPublicAsset("some/source", "target");
120 $asset2 = $this->newPublicAsset("some/other/source", "target/sub");
121
122 $this->manager->addAssets($asset1, $asset2);
123 }

References ILIAS\Component\Tests\Resource\PublicAssetManagerTest\newPublicAsset().

+ Here is the call graph for this function:

◆ testTargetCanNotBeWithinOtherTarget2()

ILIAS\Component\Tests\Resource\PublicAssetManagerTest::testTargetCanNotBeWithinOtherTarget2 ( )

Definition at line 125 of file PublicAssetManagerTest.php.

125 : void
126 {
127 $this->expectException(\LogicException::class);
128
129 $asset1 = $this->newPublicAsset("some/source", "target/sub");
130 $asset2 = $this->newPublicAsset("some/other/source", "target");
131
132 $this->manager->addAssets($asset1, $asset2);
133 }

References ILIAS\Component\Tests\Resource\PublicAssetManagerTest\newPublicAsset().

+ Here is the call graph for this function:

◆ testTargetCanOnlyBeUsedOnce()

ILIAS\Component\Tests\Resource\PublicAssetManagerTest::testTargetCanOnlyBeUsedOnce ( )

Definition at line 105 of file PublicAssetManagerTest.php.

105 : void
106 {
107 $this->expectException(\LogicException::class);
108
109 $asset1 = $this->newPublicAsset("some/source", "target");
110 $asset2 = $this->newPublicAsset("some/other/source", "target");
111
112 $this->manager->addAssets($asset1, $asset2);
113 }

References ILIAS\Component\Tests\Resource\PublicAssetManagerTest\newPublicAsset().

+ Here is the call graph for this function:

◆ testValidFolderPaths()

ILIAS\Component\Tests\Resource\PublicAssetManagerTest::testValidFolderPaths ( )

Definition at line 160 of file PublicAssetManagerTest.php.

160 : void
161 {
162 $this->expectNotToPerformAssertions();
163
164 $this->manager->buildPublicFolder("/base", "/public");
165 $this->manager->buildPublicFolder("/srv/demo10-ilias", "/public");
166 $this->manager->buildPublicFolder("/srv/demo10.ilias.de", "/public");
167 }

Field Documentation

◆ $manager

R PublicAssetManager ILIAS\Component\Tests\Resource\PublicAssetManagerTest::$manager
protected

Definition at line 30 of file PublicAssetManagerTest.php.


The documentation for this class was generated from the following file: