13use InvalidArgumentException;
15use Mockery\Adapter\Phpunit\MockeryPHPUnitIntegration;
16use PHPUnit\Framework\TestCase;
21require_once(
'./libs/composer/vendor/autoload.php');
35 use MockeryPHPUnitIntegration;
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);
75 $r =
new ReflectionClass($this->identification);
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);
108 $this->assertInstanceOf(IdentificationInterface::class,
$identification);
116 $this->assertEquals(
$identification->serialize(), get_class($this->provider_mock) .
"|dummy");
132 $this->plugin_mock->shouldReceive(
'getId')->once()->andReturn(
'xdemo');
133 $identification = $this->identification->
plugin($this->plugin_mock->getId(), $this->provider_mock)->identifier(
'dummy');
135 $this->provider_mock->shouldReceive(
'getProviderNameForPresentation')->andReturn(
'Provider');
143 $this->expectException(InvalidArgumentException::class);
144 $this->expectExceptionMessage(
"Nobody can handle serialized identification 'ThisStringWillNobodyHandle'.");
145 $this->identification->fromSerializedIdentification(
"ThisStringWillNobodyHandle");
152 $internal_identifier =
"internal_identifier";
154 $string_core =
"$class_name|$internal_identifier";
159 $this->assertEquals(
$identification->getInternalIdentifier(), $internal_identifier);
166 $internal_identifier =
"internal_identifier";
169 $string_plugin =
"xdemo|$class_name|$internal_identifier";
174 $this->assertEquals(
$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.
Interface ProviderFactory.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...