48 require_once __DIR__ .
'/../AbstractTestBase.php';
49 require_once __DIR__ .
'/DummyDefinition.php';
50 require_once __DIR__ .
'/DummyMachine.php';
51 require_once __DIR__ .
'/BrokenDummyMachine.php';
52 require_once __DIR__ .
'/SVGDummyMachine.php';
71 protected function setUp(): void
78 $factory =
new Factory($this->engine_factory_mock, [
79 \stdClass::class => \stdClass::class,
80 BrokenDummyMachine::class => BrokenDummyMachine::class
84 $definition = $this->createMock(FlavourDefinition::class);
85 $definition->expects($this->once())->method(
'getFlavourMachineId')->willReturn(\stdClass::class);
87 $null_machine = $factory->get($definition);
88 $this->assertInstanceOf(NullMachine::class, $null_machine);
89 $this->assertEquals(
'Machine stdClass does not implement FlavourMachine', $null_machine->getReason());
90 $this->assertEquals(
'null_machine', $null_machine->getId());
91 $this->assertEquals(NoEngine::class, $null_machine->dependsOnEngine());
94 $definition = $this->createMock(FlavourDefinition::class);
95 $definition->expects($this->once())->method(
'getFlavourMachineId')->willReturn(BrokenDummyMachine::class);
96 $null_machine = $factory->get($definition);
97 $this->assertInstanceOf(NullMachine::class, $null_machine);
99 'Could not instantiate machine ILIAS\ResourceStorage\Flavours\BrokenDummyMachine',
100 $null_machine->getReason()
102 $this->assertEquals(
'null_machine', $null_machine->getId());
103 $this->assertEquals(NoEngine::class, $null_machine->dependsOnEngine());
109 [
new PagesToExtract(
true), ExtractPages::class, ImagickEngineWithOptionalFFMpeg::class],
110 [
new CropToSquare(), CropSquare::class, GDEngine::class],
111 [
new FitToSquare(), FitSquare::class, GDEngine::class],
112 [
new ToGreyScale(), MakeGreyScale::class, GDEngine::class],
122 $factory =
new Factory($this->engine_factory_mock);
123 $this->engine_factory_mock->expects($this->exactly(1))
127 $machine_instance = $factory->get($d);
128 $this->assertInstanceOf($machine, $machine_instance);
129 $machine_instance_second_get = $factory->get($d);
130 $this->assertSame($machine_instance, $machine_instance_second_get);
136 [ExtractPages::class, ImagickEngine::class],
137 [CropSquare::class, GDEngine::class],
138 [FitSquare::class, GDEngine::class],
139 [MakeGreyScale::class, GDEngine::class],
148 $factory = new \ILIAS\ResourceStorage\Flavour\Engine\Factory();
149 $engine_instance = $factory->get(
new $machine());
150 $this->assertInstanceOf($engine, $engine_instance);
158 $factory =
new Factory($this->engine_factory_mock);
160 $engine_mock = $this->createMock(Engine::class);
162 $this->engine_factory_mock->expects($this->once())
164 ->willReturn($engine_mock);
166 $engine_mock->expects($this->once())
167 ->method(
'isRunning')
170 $machine_instance = $factory->get($d);
171 $this->assertInstanceOf(NullMachine::class, $machine_instance);
173 "Machine $machine depends on engine $engine which is not running or available.",
174 $machine_instance->getReason()
182 '<?xml version="1.0" encoding="UTF-8"?> 183 <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 155 155"><defs><style>.cls-1{fill:red;}</style></defs><g><g><rect class="cls-1" x="3" y="3" width="150" height="150"/><path d="M151.14,6V151.14H6V6H151.14m6-6H0V157.14H157.14V0h0Z"/></g></g></svg>' 190 $result = iterator_to_array($machine->processStream($file_info, $svg_stream, $definition));
191 $this->assertCount(1, $result);
192 $result_one = $result[0];
193 $this->assertInstanceOf(Result::class, $result_one);
194 $this->assertEquals($definition, $result_one->getDefinition());
195 $this->assertInstanceOf(FileStream::class, $result_one->getStream());
197 '<?xml version="1.0" encoding="UTF-8"?> 198 <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 155 155"><defs><style>.cls-1{fill:blue;}</style></defs><g><g><rect class="cls-1" x="3" y="3" width="150" height="150"/><path d="M151.14,6V151.14H6V6H151.14m6-6H0V157.14H157.14V0h0Z"/></g></g></svg>',
199 (
string)$result_one->getStream()
206 private string $color;
207 private string $to_color;
209 public function __construct(
string $color,
string $to_color)
211 $this->color = $color;
212 $this->to_color = $to_color;
215 'svg_color_changing_machine' 219 public function getColor():
string 224 public function getToColor():
string 226 return $this->to_color;
Interface Observer Contains several chained tasks and infos about them.
createSVGColorChangeDefinition(string $color, string $to_color)
Class FlavourMachineTest.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
__construct(FlavourBuilder $flavour_builder, ResourceBuilder $resource_builder)
static ofString(string $string)
Creates a new stream with an initial value.
static machinesToEngines()
__construct(Container $dic, ilPlugin $plugin)
testDefaultMachineEngines(string $machine, string $engine)
machinesToEngines
Class ResourceBuilderTest.
static definitionsToMachines()
testNullMachineFallback(FlavourDefinition $d, string $machine, string $engine)
definitionsToMachines
PHPUnit Framework MockObject MockObject $engine_factory_mock
testDefaultMachines(FlavourDefinition $d, string $machine)
definitionsToMachines