21 require_once(
'./libs/composer/vendor/autoload.php');
55 protected function setUp(): void
59 $this->plugin_mock = Mockery::mock(ilPlugin::class);
61 $this->provider_mock = Mockery::mock(Provider::class);
62 $this->provider_mock->shouldReceive(
'getProviderNameForPresentation')->andReturn(
'Provider')->byDefault();
64 $this->provider_factory = Mockery::mock(ProviderFactory::class);
65 $this->provider_factory->shouldReceive(
'getProviderByClassName')->with(self::MOCKED_PROVIDER_CLASSNAME)->andReturn($this->provider_mock);
66 $this->provider_factory->shouldReceive(
'isInstanceCreationPossible')->andReturn(
true);
67 $this->provider_factory->shouldReceive(
'isRegistered')->andReturn(
true);
78 foreach ($r->getMethods(ReflectionMethod::IS_PUBLIC) as $method) {
79 $methods[] = $method->getName();
86 2 =>
'fromSerializedIdentification',
97 $this->assertInstanceOf(IdentificationProviderInterface::class, $this->identification->core($this->provider_mock));
98 $this->assertInstanceOf(IdentificationInterface::class, $this->identification->core($this->provider_mock)->identifier(
'dummy'));
104 $this->plugin_mock->shouldReceive(
'getId')->once()->andReturn(
'xdemo');
105 $identification_provider = $this->identification->plugin($this->plugin_mock->getId(),
$this->provider_mock);
106 $this->assertInstanceOf(IdentificationProviderInterface::class, $identification_provider);
107 $identification = $identification_provider->identifier(
'dummy');
108 $this->assertInstanceOf(IdentificationInterface::class, $identification);
114 $identification = $this->identification->
core($this->provider_mock)->identifier(
'dummy');
115 $this->assertInstanceOf(Serializable::class, $identification);
116 $this->assertEquals($identification->serialize(), get_class($this->provider_mock) .
"|dummy");
122 $identification = $this->identification->
core($this->provider_mock)->identifier(
'dummy');
123 $serialized_identification = $identification->serialize();
126 $this->assertEquals($identification, $new_identification);
132 $this->plugin_mock->shouldReceive(
'getId')->once()->andReturn(
'xdemo');
134 $serialized_identification = $identification->serialize();
135 $this->provider_mock->shouldReceive(
'getProviderNameForPresentation')->andReturn(
'Provider');
137 $this->assertEquals($identification, $new_identification);
143 $this->expectException(InvalidArgumentException::class);
144 $this->expectExceptionMessage(
"Nobody can handle serialized identification 'ThisStringWillNobodyHandle'.");
145 $this->identification->fromSerializedIdentification(
"ThisStringWillNobodyHandle");
151 $class_name = self::MOCKED_PROVIDER_CLASSNAME;
152 $internal_identifier =
"internal_identifier";
154 $string_core =
"$class_name|$internal_identifier";
157 $this->assertInstanceOf(CoreIdentification::class, $identification);
158 $this->assertEquals($identification->getClassName(), $class_name);
159 $this->assertEquals($identification->getInternalIdentifier(), $internal_identifier);
165 $class_name = self::MOCKED_PROVIDER_CLASSNAME;
166 $internal_identifier =
"internal_identifier";
169 $string_plugin =
"xdemo|$class_name|$internal_identifier";
172 $this->assertInstanceOf(PluginIdentification::class, $identification);
173 $this->assertEquals($identification->getClassName(), $class_name);
174 $this->assertEquals($identification->getInternalIdentifier(), $internal_identifier);
plugin(string $plugin_id, Provider $provider)
Returns a IdentificationProvider for ILIAS-Plugins which takes care of the plugin_id for further iden...
testUnserializingFailsSinceNobpbyCanhandleTheString()
IdentificationFactory $identification
fromSerializedIdentification($serialized_string)
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...
core(Provider $provider)
Returns a IdentificationProvider for core components, only a Provider is needed.
const MOCKED_PROVIDER_CLASSNAME
Class IdentificationFactoryTest.