44 require_once __DIR__ .
'/../AbstractTestBase.php';
59 protected function setUp(): void
62 $storage_handler_mock = $this->createMock(StorageHandler::class);
63 $storage_handler_mock->method(
'isPrimary')->willReturn(
true);
67 $this->flavour_repo = $this->createMock(FlavourRepository::class);
68 $this->resource_builder = $this->createMock(ResourceBuilder::class);
69 $this->stream_access =
new StreamAccess(self::BASE_DIR, $this->storage_handler_factory);
77 $this->machine_factory,
78 $this->resource_builder,
79 $this->storage_handler_factory,
85 $flavour_definition = $this->createMock(FlavourDefinition::class);
86 $flavour_definition->expects($this->exactly(2))
87 ->method(
'getVariantName')
88 ->willReturn(str_repeat(
'a', 768));
90 $flavour_builder->has(
94 $this->assertTrue(
true);
97 $flavour_definition = $this->createMock(FlavourDefinition::class);
98 $flavour_definition->expects($this->exactly(2))
99 ->method(
'getVariantName')
100 ->willReturn(str_repeat(
'a', 769));
102 $this->expectException(\InvalidArgumentException::class);
103 $flavour_builder->has(
116 $this->machine_factory,
117 $this->resource_builder,
118 $this->storage_handler_factory,
119 $this->stream_access,
124 $flavour_definition = $this->createMock(FlavourDefinition::class);
125 $flavour_definition->expects($this->exactly(4))
126 ->method(
'getVariantName')
127 ->willReturn(
'short');
131 [[$rid_one, 0, $flavour_definition],
false],
132 [[$rid_two, 0, $flavour_definition],
true],
135 ->expects($this->exactly(2))
137 ->willReturnCallback(
138 function ($rid, $mid, $def) use (&$consecutive) {
139 [$expected, $ret] = array_shift($consecutive);
140 $this->assertEquals($expected, [$rid, $mid, $def]);
147 $flavour_builder->has(
153 $flavour_builder->has(
166 $this->machine_factory,
167 $this->resource_builder,
168 $this->storage_handler_factory,
169 $this->stream_access,
174 $flavour_definition = $this->createMock(FlavourDefinition::class);
176 ->method(
'getVariantName')
177 ->willReturn(
'short');
179 $this->flavour_repo->expects($this->once())
181 ->with($rid_one, 0, $flavour_definition)
184 $this->resource_builder->expects($this->once())
189 $revision = $this->createMock(FileRevision::class);
191 $revision->expects($this->once())
192 ->method(
'getInformation')
193 ->willReturn($this->createMock(FileInformation::class));
197 $resource = $this->createMock(StorableResource::class);
199 $this->resource_builder->expects($this->once())
202 ->willReturn($resource);
205 ->method(
'getCurrentRevision')
206 ->willReturn($revision);
209 $this->resource_builder->expects($this->once())
210 ->method(
'extractStream')
212 ->willReturn($stream);
216 $flavour = $flavour_builder->get(
220 $this->assertInstanceOf(Flavour::class, $flavour);
221 $stream_resolvers = $flavour->getStreamResolvers();
222 $this->assertCount(1, $stream_resolvers);
223 $first_stream_access = $stream_resolvers[0];
224 $this->assertInstanceOf(StreamResolver::class, $first_stream_access);
225 $resolved_stream = $first_stream_access->getStream();
226 $this->assertSame(
'empty', (
string) $resolved_stream);
testDefinitionVariantNameLengths()
Interface Observer Contains several chained tasks and infos about them.
StreamAccess $stream_access
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Class ResourceIdentification.
MockObject $resource_builder
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.
Class StorageHandlerFactory.
Class ResourceBuilderTest.