37 require_once(
'./libs/composer/vendor/autoload.php');
74 protected function setUp() : void
78 $this->plugin_mock = Mockery::mock(ilPlugin::class);
80 $this->provider_mock = Mockery::mock(Provider::class);
81 $this->provider_mock->shouldReceive(
'getProviderNameForPresentation')->andReturn(
'Provider')->byDefault();
83 $this->provider_factory = Mockery::mock(ProviderFactory::class);
84 $this->provider_factory->shouldReceive(
'getProviderByClassName')->with(self::MOCKED_PROVIDER_CLASSNAME)->andReturn($this->provider_mock);
85 $this->provider_factory->shouldReceive(
'isInstanceCreationPossible')->andReturn(
true);
86 $this->provider_factory->shouldReceive(
'isRegistered')->andReturn(
true);
97 foreach ($r->getMethods(ReflectionMethod::IS_PUBLIC) as $method) {
98 $methods[] = $method->getName();
105 2 =>
'fromSerializedIdentification',
116 $this->assertInstanceOf(IdentificationProviderInterface::class, $this->identification->core($this->provider_mock));
117 $this->assertInstanceOf(IdentificationInterface::class, $this->identification->core($this->provider_mock)->identifier(
'dummy'));
123 $this->plugin_mock->shouldReceive(
'getId')->once()->andReturn(
'xdemo');
124 $identification_provider = $this->identification->plugin($this->plugin_mock->getId(),
$this->provider_mock);
125 $this->assertInstanceOf(IdentificationProviderInterface::class, $identification_provider);
127 $this->assertInstanceOf(IdentificationInterface::class,
$identification);
133 $identification = $this->identification->core($this->provider_mock)->identifier(
'dummy');
135 $this->assertEquals(
$identification->serialize(), get_class($this->provider_mock) .
"|dummy");
141 $identification = $this->identification->core($this->provider_mock)->identifier(
'dummy');
144 $new_identification = $this->identification->fromSerializedIdentification($serialized_identification);
151 $this->plugin_mock->shouldReceive(
'getId')->once()->andReturn(
'xdemo');
154 $this->provider_mock->shouldReceive(
'getProviderNameForPresentation')->andReturn(
'Provider');
155 $new_identification = $this->identification->fromSerializedIdentification($serialized_identification);
162 $this->expectException(InvalidArgumentException::class);
163 $this->expectExceptionMessage(
"Nobody can handle serialized identification 'ThisStringWillNobodyHandle'.");
164 $this->identification->fromSerializedIdentification(
"ThisStringWillNobodyHandle");
170 $class_name = self::MOCKED_PROVIDER_CLASSNAME;
171 $internal_identifier =
"internal_identifier";
173 $string_core =
"$class_name|$internal_identifier";
174 $identification = $this->identification->fromSerializedIdentification($string_core);
178 $this->assertEquals(
$identification->getInternalIdentifier(), $internal_identifier);
184 $class_name = self::MOCKED_PROVIDER_CLASSNAME;
185 $internal_identifier =
"internal_identifier";
188 $string_plugin =
"xdemo|$class_name|$internal_identifier";
189 $identification = $this->identification->fromSerializedIdentification($string_plugin);
193 $this->assertEquals(
$identification->getInternalIdentifier(), $internal_identifier);
testUnserializingFailsSinceNobpbyCanhandleTheString()
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
testFactoryMustReturnCorrectTypeCore()
testFactoryMustReturnCorrectTypePlugin()
testUnserializingPlugin()
Class IdentificationFactory All elements in the GlobalScreen service must be identifiable for the sup...
const MOCKED_PROVIDER_CLASSNAME
Class IdentificationFactoryTest.