45 require_once __DIR__ .
'/../AbstractBaseTest.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');
130 $this->flavour_repo->expects($this->exactly(2))
132 ->withConsecutive([$rid_one, 0, $flavour_definition], [$rid_two, 0, $flavour_definition])
133 ->willReturnOnConsecutiveCalls(
false,
true);
157 $this->machine_factory,
158 $this->resource_builder,
159 $this->storage_handler_factory,
160 $this->stream_access,
165 $flavour_definition = $this->createMock(FlavourDefinition::class);
166 $flavour_definition->expects($this->any())
167 ->method(
'getVariantName')
168 ->willReturn(
'short');
170 $this->flavour_repo->expects($this->once())
172 ->with($rid_one, 0, $flavour_definition)
175 $this->resource_builder->expects($this->exactly(1))
180 $revision = $this->createMock(FileRevision::class);
182 $revision->expects($this->once())
183 ->method(
'getInformation')
184 ->willReturn($this->createMock(FileInformation::class));
188 $resource = $this->createMock(StorableResource::class);
190 $this->resource_builder->expects($this->once())
193 ->willReturn($resource);
195 $resource->expects($this->any())
196 ->method(
'getCurrentRevision')
197 ->willReturn($revision);
200 $this->resource_builder->expects($this->exactly(1))
201 ->method(
'extractStream')
203 ->willReturn($stream);
211 $this->assertInstanceOf(Flavour::class, $flavour);
212 $stream_resolvers = $flavour->getStreamResolvers();
213 $this->assertCount(1, $stream_resolvers);
214 $first_stream_access = $stream_resolvers[0];
215 $this->assertInstanceOf(StreamResolver::class, $first_stream_access);
216 $resolved_stream = $first_stream_access->getStream();
217 $this->assertEquals(
'empty', (
string) $resolved_stream);
testDefinitionVariantNameLengths()
Class FileResourceHandler.
get(ResourceIdentification $rid, FlavourDefinition $definition, bool $force_building=false)
Class ResourceBuilderTest.
Class ChatMainBarProvider .
StreamAccess $stream_access
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
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.
FlavourBuilder $flavour_builder