ILIAS  trunk Revision v11.0_alpha-2645-g16283d3b3f8
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 ()
 
 testTargetCanOnlyBeUsedOnce ()
 
 testTargetCanNotBeWithinOtherTarget1 ()
 
 testTargetCanNotBeWithinOtherTarget2 ()
 
 testBuildAssetFolderEmpty ()
 
 testBuildAssetFolder ()
 
 testValidFolderPaths ()
 
 testInvalidFolderPaths (string $ilias_base, string $target)
 

Static Public Member Functions

static provideInvalidFolderPathData ()
 

Protected Member Functions

 newPublicAsset ($source, $target)
 

Protected Attributes

R PublicAssetManager $manager
 

Detailed Description

Definition at line 27 of file PublicAssetManagerTest.php.

Member Function Documentation

◆ newPublicAsset()

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

Definition at line 31 of file PublicAssetManagerTest.php.

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().

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

145  : array
146  {
147  return [
148  'base - missing leading slash' => ['base', '/public'],
149  'base - extra trailing slash' => ['/base/', '/public'],
150  'base - dot only' => ['.', '/public'],
151  'base - dash only' => ['-', '/public'],
152  'base - invalid trailing dash' => ['/base/demo-', '/public'],
153  'base - invalid trailing dot' => ['/base/demo.', '/public'],
154  'base - invalid leading dash' => ['/base/.demo', '/public'],
155  'base - invalid leading dot' => ['/base/-demo', '/public'],
156  'base - invalid dot sub directory' => ['/./test', '/public'],
157  'base - invalid dash sub directory' => ['/-/test', '/public'],
158  'target - missing leading slash' => ['/base', 'public'],
159  'target - extra trailing slash' => ['/base', '/public/'],
160  'target - dot only' => ['/base', '.'],
161  'target - dash only' => ['/base', '-'],
162  'target - invalid trailing dash' => ['/base', '/public.'],
163  'target - invalid trailing dot' => ['/base', '/public-'],
164  'target - invalid leading dash' => ['/base', '/.public'],
165  'target - invalid leading dot' => ['/base', '/-public'],
166  'target - invalid dot sub directory' => ['/base', '/./public'],
167  'target - invalid dash sub directory' => ['/base', '/-/public'],
168  ];
169  }

◆ setUp()

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

Definition at line 52 of file PublicAssetManagerTest.php.

References $path.

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

◆ testBuildAssetFolder()

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

Definition at line 115 of file PublicAssetManagerTest.php.

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

116  {
117  $this->manager->addAssets(
118  $this->newPublicAsset("source1", "target1"),
119  $this->newPublicAsset("source2", "second/target")
120  );
121 
122  $this->manager->buildPublicFolder("/base", "/public");
123 
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);
127  }
+ Here is the call graph for this function:

◆ testBuildAssetFolderEmpty()

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

Definition at line 107 of file PublicAssetManagerTest.php.

108  {
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);
113  }

◆ testInvalidFolderPaths()

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

Definition at line 139 of file PublicAssetManagerTest.php.

139  : void
140  {
141  $this->expectException(\InvalidArgumentException::class);
142  $this->manager->buildPublicFolder($ilias_base, $target);
143  }

◆ testTargetCanNotBeWithinOtherTarget1()

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

Definition at line 87 of file PublicAssetManagerTest.php.

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

88  {
89  $this->expectException(\LogicException::class);
90 
91  $asset1 = $this->newPublicAsset("some/source", "target");
92  $asset2 = $this->newPublicAsset("some/other/source", "target/sub");
93 
94  $this->manager->addAssets($asset1, $asset2);
95  }
+ Here is the call graph for this function:

◆ testTargetCanNotBeWithinOtherTarget2()

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

Definition at line 97 of file PublicAssetManagerTest.php.

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

98  {
99  $this->expectException(\LogicException::class);
100 
101  $asset1 = $this->newPublicAsset("some/source", "target/sub");
102  $asset2 = $this->newPublicAsset("some/other/source", "target");
103 
104  $this->manager->addAssets($asset1, $asset2);
105  }
+ Here is the call graph for this function:

◆ testTargetCanOnlyBeUsedOnce()

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

Definition at line 77 of file PublicAssetManagerTest.php.

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

78  {
79  $this->expectException(\LogicException::class);
80 
81  $asset1 = $this->newPublicAsset("some/source", "target");
82  $asset2 = $this->newPublicAsset("some/other/source", "target");
83 
84  $this->manager->addAssets($asset1, $asset2);
85  }
+ Here is the call graph for this function:

◆ testValidFolderPaths()

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

Definition at line 129 of file PublicAssetManagerTest.php.

129  : void
130  {
131  $this->expectNotToPerformAssertions();
132 
133  $this->manager->buildPublicFolder("/base", "/public");
134  $this->manager->buildPublicFolder("/srv/demo10-ilias", "/public");
135  $this->manager->buildPublicFolder("/srv/demo10.ilias.de", "/public");
136  }

Field Documentation

◆ $manager

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

Definition at line 29 of file PublicAssetManagerTest.php.


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