45 require_once __DIR__ .
'/../AbstractTestBase.php';
60 protected function setUp(): void
63 $this->storage_handler_mock = $this->createMock(StorageHandler::class);
64 $this->storage_handler_mock->expects($this->any())->method(
'isPrimary')->willReturn(
true);
66 $this->storage_handler_mock
68 $this->flavour_repo = $this->createMock(FlavourRepository::class);
69 $this->resource_builder = $this->createMock(ResourceBuilder::class);
70 $this->stream_access =
new StreamAccess(self::BASE_DIR, $this->storage_handler_factory);
78 $this->machine_factory,
79 $this->resource_builder,
80 $this->storage_handler_factory,
86 $flavour_definition = $this->createMock(FlavourDefinition::class);
87 $flavour_definition->expects($this->exactly(2))
88 ->method(
'getVariantName')
89 ->willReturn(str_repeat(
'a', 768));
95 $this->assertTrue(
true);
98 $flavour_definition = $this->createMock(FlavourDefinition::class);
99 $flavour_definition->expects($this->exactly(2))
100 ->method(
'getVariantName')
101 ->willReturn(str_repeat(
'a', 769));
103 $this->expectException(\InvalidArgumentException::class);
117 $this->machine_factory,
118 $this->resource_builder,
119 $this->storage_handler_factory,
120 $this->stream_access,
125 $flavour_definition = $this->createMock(FlavourDefinition::class);
126 $flavour_definition->expects($this->exactly(4))
127 ->method(
'getVariantName')
128 ->willReturn(
'short');
132 [[$rid_one, 0, $flavour_definition],
false],
133 [[$rid_two, 0, $flavour_definition],
true],
136 ->expects($this->exactly(2))
138 ->willReturnCallback(
139 function ($rid, $mid, $def) use (&$consecutive) {
140 list($expected, $ret) = array_shift($consecutive);
141 $this->assertEquals($expected, [$rid, $mid, $def]);
167 $this->machine_factory,
168 $this->resource_builder,
169 $this->storage_handler_factory,
170 $this->stream_access,
175 $flavour_definition = $this->createMock(FlavourDefinition::class);
176 $flavour_definition->expects($this->any())
177 ->method(
'getVariantName')
178 ->willReturn(
'short');
180 $this->flavour_repo->expects($this->once())
182 ->with($rid_one, 0, $flavour_definition)
185 $this->resource_builder->expects($this->exactly(1))
190 $revision = $this->createMock(FileRevision::class);
192 $revision->expects($this->once())
193 ->method(
'getInformation')
194 ->willReturn($this->createMock(FileInformation::class));
198 $resource = $this->createMock(StorableResource::class);
200 $this->resource_builder->expects($this->once())
203 ->willReturn($resource);
205 $resource->expects($this->any())
206 ->method(
'getCurrentRevision')
207 ->willReturn($revision);
210 $this->resource_builder->expects($this->exactly(1))
211 ->method(
'extractStream')
213 ->willReturn($stream);
221 $this->assertInstanceOf(Flavour::class, $flavour);
222 $stream_resolvers = $flavour->getStreamResolvers();
223 $this->assertCount(1, $stream_resolvers);
224 $first_stream_access = $stream_resolvers[0];
225 $this->assertInstanceOf(StreamResolver::class, $first_stream_access);
226 $resolved_stream = $first_stream_access->getStream();
227 $this->assertEquals(
'empty', (
string) $resolved_stream);
testDefinitionVariantNameLengths()
Class FileResourceHandler.
get(ResourceIdentification $rid, FlavourDefinition $definition, bool $force_building=false)
Interface Observer Contains several chained tasks and infos about them.
StreamAccess $stream_access
has(ResourceIdentification $identification, FlavourDefinition $definition)
StorageHandler $storage_handler_mock
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Class ResourceIdentification.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static ofString(string $string)
Creates a new stream with an initial value.
FlavourRepository $flavour_repo
Class StorageHandlerFactory.
Class ResourceBuilderTest.
FlavourBuilder $flavour_builder