21use PHPUnit\Framework\Attributes\BackupGlobals;
22use PHPUnit\Framework\Attributes\BackupStaticProperties;
23use PHPUnit\Framework\Attributes\PreserveGlobalState;
24use PHPUnit\Framework\Attributes\RunTestsInSeparateProcesses;
33use InvalidArgumentException;
35use PHPUnit\Framework\TestCase;
40require_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);
93 $r =
new ReflectionClass($this->identification);
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);
126 $this->assertInstanceOf(IdentificationInterface::class,
$identification);
134 $this->assertEquals(
$identification->serialize(), $this->provider_mock::class .
"|dummy");
150 $this->plugin_mock->shouldReceive(
'getId')->once()->andReturn(
'xdemo');
151 $identification = $this->identification->
plugin($this->plugin_mock->getId(), $this->provider_mock)->identifier(
'dummy');
153 $this->provider_mock->shouldReceive(
'getProviderNameForPresentation')->andReturn(
'Provider');
161 $this->expectException(InvalidArgumentException::class);
162 $this->expectExceptionMessage(
"Nobody can handle serialized identification 'ThisStringWillNobodyHandle'.");
163 $this->identification->fromSerializedIdentification(
"ThisStringWillNobodyHandle");
170 $internal_identifier =
"internal_identifier";
172 $string_core =
"$class_name|$internal_identifier";
177 $this->assertSame(
$identification->getInternalIdentifier(), $internal_identifier);
184 $internal_identifier =
"internal_identifier";
187 $string_plugin =
"xdemo|$class_name|$internal_identifier";
192 $this->assertSame(
$identification->getInternalIdentifier(), $internal_identifier);
Class CoreIdentification.
Class IdentificationFactory All elements in the GlobalScreen service must be identifiable for the sup...
fromSerializedIdentification($serialized_string)
plugin(string $plugin_id, Provider $provider)
Returns a IdentificationProvider for ILIAS-Plugins which takes care of the plugin_id for further iden...
core(Provider $provider)
Returns a IdentificationProvider for core components, only a Provider is needed.
Class PluginIdentification.
Class IdentificationFactoryTest.
const MOCKED_PROVIDER_CLASSNAME
testUnserializingFailsSinceNobpbyCanhandleTheString()
testFactoryMustReturnCorrectTypeCore()
testUnserializingPlugin()
testFactoryMustReturnCorrectTypePlugin()
IdentificationFactory $identification
Interface IdentificationInterface.
Class IdentificationProviderInterface.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...