40 require_once(
'./vendor/composer/vendor/autoload.php');
47 #[BackupGlobals(false)] 48 #[BackupStaticProperties(false)] 49 #[PreserveGlobalState(false)] 50 #[RunTestsInSeparateProcesses] 73 protected function setUp(): void
77 $this->plugin_mock = Mockery::mock(ilPlugin::class);
79 $this->provider_mock = Mockery::mock(Provider::class);
80 $this->provider_mock->shouldReceive(
'getProviderNameForPresentation')->andReturn(
'Provider')->byDefault();
82 $this->provider_factory = Mockery::mock(ProviderFactory::class);
83 $this->provider_factory->shouldReceive(
'getProviderByClassName')->with(self::MOCKED_PROVIDER_CLASSNAME)->andReturn($this->provider_mock);
84 $this->provider_factory->shouldReceive(
'isInstanceCreationPossible')->andReturn(
true);
85 $this->provider_factory->shouldReceive(
'isRegistered')->andReturn(
true);
96 foreach (
$r->getMethods(ReflectionMethod::IS_PUBLIC) as $method) {
97 $methods[] = $method->getName();
104 2 =>
'fromSerializedIdentification',
115 $this->assertInstanceOf(IdentificationProviderInterface::class, $this->identification->core($this->provider_mock));
116 $this->assertInstanceOf(IdentificationInterface::class, $this->identification->core($this->provider_mock)->identifier(
'dummy'));
122 $this->plugin_mock->shouldReceive(
'getId')->once()->andReturn(
'xdemo');
123 $identification_provider = $this->identification->plugin($this->plugin_mock->getId(),
$this->provider_mock);
124 $this->assertInstanceOf(IdentificationProviderInterface::class, $identification_provider);
125 $identification = $identification_provider->identifier(
'dummy');
126 $this->assertInstanceOf(IdentificationInterface::class, $identification);
132 $identification = $this->identification->
core($this->provider_mock)->identifier(
'dummy');
133 $this->assertInstanceOf(Serializable::class, $identification);
134 $this->assertEquals($identification->serialize(), $this->provider_mock::class .
"|dummy");
140 $identification = $this->identification->
core($this->provider_mock)->identifier(
'dummy');
141 $serialized_identification = $identification->serialize();
144 $this->assertEquals($identification, $new_identification);
150 $this->plugin_mock->shouldReceive(
'getId')->once()->andReturn(
'xdemo');
152 $serialized_identification = $identification->serialize();
153 $this->provider_mock->shouldReceive(
'getProviderNameForPresentation')->andReturn(
'Provider');
155 $this->assertEquals($identification, $new_identification);
161 $this->expectException(InvalidArgumentException::class);
162 $this->expectExceptionMessage(
"Nobody can handle serialized identification 'ThisStringWillNobodyHandle'.");
163 $this->identification->fromSerializedIdentification(
"ThisStringWillNobodyHandle");
169 $class_name = self::MOCKED_PROVIDER_CLASSNAME;
170 $internal_identifier =
"internal_identifier";
172 $string_core =
"$class_name|$internal_identifier";
175 $this->assertInstanceOf(CoreIdentification::class, $identification);
176 $this->assertEquals($identification->getClassName(), $class_name);
177 $this->assertEquals($identification->getInternalIdentifier(), $internal_identifier);
183 $class_name = self::MOCKED_PROVIDER_CLASSNAME;
184 $internal_identifier =
"internal_identifier";
187 $string_plugin =
"xdemo|$class_name|$internal_identifier";
190 $this->assertInstanceOf(PluginIdentification::class, $identification);
191 $this->assertEquals($identification->getClassName(), $class_name);
192 $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)
sort()
description: > Example for rendering a Sort Glyph.
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.