21use PHPUnit\Framework\MockObject\MockObject;
44require_once __DIR__ .
'/../AbstractTestBase.php';
65 protected function setUp(): void
68 $storage_handler_mock = $this->createMock(StorageHandler::class);
69 $storage_handler_mock->method(
'isPrimary')->willReturn(
true);
73 $this->flavour_repo = $this->createMock(FlavourRepository::class);
74 $this->resource_builder = $this->createMock(ResourceBuilder::class);
75 $this->stream_access =
new StreamAccess(self::BASE_DIR, $this->storage_handler_factory);
83 $this->machine_factory,
84 $this->resource_builder,
85 $this->storage_handler_factory,
91 $flavour_definition = $this->createMock(FlavourDefinition::class);
92 $flavour_definition->expects($this->exactly(2))
93 ->method(
'getVariantName')
96 $flavour_builder->has(
100 $this->assertTrue(
true);
103 $flavour_definition = $this->createMock(FlavourDefinition::class);
104 $flavour_definition->expects($this->exactly(2))
105 ->method(
'getVariantName')
108 $this->expectException(\InvalidArgumentException::class);
109 $flavour_builder->has(
122 $this->machine_factory,
123 $this->resource_builder,
124 $this->storage_handler_factory,
125 $this->stream_access,
130 $flavour_definition = $this->createMock(FlavourDefinition::class);
131 $flavour_definition->expects($this->exactly(4))
132 ->method(
'getVariantName')
133 ->willReturn(
'short');
137 [[$rid_one, 0, $flavour_definition],
false],
138 [[$rid_two, 0, $flavour_definition],
true],
141 ->expects($this->exactly(2))
143 ->willReturnCallback(
144 function ($rid, $mid, $def) use (&$consecutive) {
145 [$expected, $ret] = array_shift($consecutive);
146 $this->assertEquals($expected, [$rid, $mid, $def]);
153 $flavour_builder->has(
159 $flavour_builder->has(
172 $this->machine_factory,
173 $this->resource_builder,
174 $this->storage_handler_factory,
175 $this->stream_access,
180 $flavour_definition = $this->createMock(FlavourDefinition::class);
182 ->method(
'getVariantName')
183 ->willReturn(
'short');
185 $this->flavour_repo->expects($this->once())
187 ->with($rid_one, 0, $flavour_definition)
190 $this->resource_builder->expects($this->once())
195 $revision = $this->createMock(FileRevision::class);
197 $revision->expects($this->once())
198 ->method(
'getInformation')
199 ->willReturn($this->createStub(FileInformation::class));
203 $resource = $this->createMock(StorableResource::class);
205 $this->resource_builder->expects($this->once())
208 ->willReturn($resource);
211 ->method(
'getCurrentRevision')
212 ->willReturn($revision);
215 $this->resource_builder->expects($this->once())
216 ->method(
'extractStream')
218 ->willReturn($stream);
222 $flavour = $flavour_builder->get(
226 $this->assertInstanceOf(Flavour::class, $flavour);
227 $stream_resolvers = $flavour->getStreamResolvers();
228 $this->assertCount(1, $stream_resolvers);
229 $first_stream_access = $stream_resolvers[0];
230 $this->assertInstanceOf(StreamResolver::class, $first_stream_access);
231 $resolved_stream = $first_stream_access->getStream();
232 $this->assertSame(
'empty', (
string) $resolved_stream);
Stream factory which enables the user to create streams without the knowledge of the concrete class.
static ofString(string $string)
Creates a new stream with an initial value.
Class ResourceBuilderTest.
StreamAccess $stream_access
testDefinitionVariantNameLengths()
MockObject $resource_builder
Class ResourceIdentification.
Class StorageHandlerFactory.
Interface StorageResource.
Class FileResourceHandler.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Interface Observer \BackgroundTasks Contains several chained tasks and infos about them.