49 require_once __DIR__ .
'/../AbstractTestBase.php';
50 require_once __DIR__ .
'/DummyDefinition.php';
51 require_once __DIR__ .
'/DummyMachine.php';
52 require_once __DIR__ .
'/BrokenDummyMachine.php';
53 require_once __DIR__ .
'/SVGDummyMachine.php';
73 protected function setUp(): void
80 $factory =
new Factory($this->engine_factory_mock, [
81 \stdClass::class => \stdClass::class,
82 BrokenDummyMachine::class => BrokenDummyMachine::class
86 $definition = $this->createMock(FlavourDefinition::class);
87 $definition->expects($this->once())->method(
'getFlavourMachineId')->willReturn(\stdClass::class);
89 $null_machine = $factory->get($definition);
90 $this->assertInstanceOf(NullMachine::class, $null_machine);
91 $this->assertEquals(
'Machine stdClass does not implement FlavourMachine', $null_machine->getReason());
92 $this->assertEquals(
'null_machine', $null_machine->getId());
93 $this->assertEquals(NoEngine::class, $null_machine->dependsOnEngine());
96 $definition = $this->createMock(FlavourDefinition::class);
97 $definition->expects($this->once())->method(
'getFlavourMachineId')->willReturn(BrokenDummyMachine::class);
98 $null_machine = $factory->get($definition);
99 $this->assertInstanceOf(NullMachine::class, $null_machine);
101 'Could not instantiate machine ILIAS\ResourceStorage\Flavours\BrokenDummyMachine',
102 $null_machine->getReason()
104 $this->assertEquals(
'null_machine', $null_machine->getId());
105 $this->assertEquals(NoEngine::class, $null_machine->dependsOnEngine());
111 [
new PagesToExtract(
true), ExtractPages::class, ImagickEngineWithOptionalFFMpeg::class],
112 [
new CropToSquare(), CropSquare::class, GDEngine::class],
113 [
new FitToSquare(), FitSquare::class, GDEngine::class],
114 [
new ToGreyScale(), MakeGreyScale::class, GDEngine::class],
119 #[DataProvider('definitionsToMachines')] 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],
143 #[DataProvider('machinesToEngines')] 146 $factory = new \ILIAS\ResourceStorage\Flavour\Engine\Factory();
147 $engine_instance = $factory->get(
new $machine());
148 $this->assertInstanceOf($engine, $engine_instance);
151 #[DataProvider('definitionsToMachines')] 154 $factory =
new Factory($this->engine_factory_mock);
156 $engine_mock = $this->createMock(Engine::class);
158 $this->engine_factory_mock->expects($this->once())
160 ->willReturn($engine_mock);
162 $engine_mock->expects($this->once())
163 ->method(
'isRunning')
166 $machine_instance = $factory->get($d);
167 $this->assertInstanceOf(NullMachine::class, $machine_instance);
169 "Machine $machine depends on engine $engine which is not running or available.",
170 $machine_instance->getReason()
178 '<?xml version="1.0" encoding="UTF-8"?> 179 <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>' 186 $result = iterator_to_array($machine->processStream($file_info, $svg_stream, $definition));
187 $this->assertCount(1, $result);
188 $result_one = $result[0];
189 $this->assertInstanceOf(Result::class, $result_one);
190 $this->assertEquals($definition, $result_one->getDefinition());
191 $this->assertInstanceOf(FileStream::class, $result_one->getStream());
193 '<?xml version="1.0" encoding="UTF-8"?> 194 <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>',
195 (
string) $result_one->getStream()
202 public function __construct(
private string $color,
private string $to_color)
206 'svg_color_changing_machine' 210 public function getColor():
string 215 public function getToColor():
string 217 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...
static ofString(string $string)
Creates a new stream with an initial value.
static machinesToEngines()
__construct(Container $dic, ilPlugin $plugin)
testDefaultMachineEngines(string $machine, string $engine)
__construct(protected FlavourBuilder $flavour_builder, protected ResourceBuilder $resource_builder)
Class ResourceBuilderTest.
static definitionsToMachines()
testNullMachineFallback(FlavourDefinition $d, string $machine, string $engine)
MockObject $engine_factory_mock
testDefaultMachines(FlavourDefinition $d, string $machine)