22 require_once(
'./libs/composer/vendor/autoload.php');
59 protected function setUp() : void
63 $this->plugin_mock = Mockery::mock(ilPlugin::class);
65 $this->provider_mock = Mockery::mock(Provider::class);
66 $this->provider_mock->shouldReceive(
'getProviderNameForPresentation')->andReturn(
'Provider')->byDefault();
68 $this->provider_factory = Mockery::mock(ProviderFactory::class);
69 $this->provider_factory->shouldReceive(
'getProviderByClassName')->with(self::MOCKED_PROVIDER_CLASSNAME)->andReturn($this->provider_mock);
70 $this->provider_factory->shouldReceive(
'isInstanceCreationPossible')->andReturn(
true);
71 $this->provider_factory->shouldReceive(
'isRegistered')->andReturn(
true);
82 foreach ($r->getMethods(ReflectionMethod::IS_PUBLIC) as $method) {
83 $methods[] = $method->getName();
91 2 =>
'fromSerializedIdentification',
101 $this->assertInstanceOf(IdentificationProviderInterface::class, $this->identification->core($this->provider_mock));
102 $this->assertInstanceOf(IdentificationInterface::class, $this->identification->core($this->provider_mock)->identifier(
'dummy'));
108 $this->plugin_mock->shouldReceive(
'getId')->once()->andReturn(
'xdemo');
109 $identification_provider = $this->identification->plugin($this->plugin_mock->getId(),
$this->provider_mock);
110 $this->assertInstanceOf(IdentificationProviderInterface::class, $identification_provider);
112 $this->assertInstanceOf(IdentificationInterface::class,
$identification);
118 $identification = $this->identification->core($this->provider_mock)->identifier(
'dummy');
120 $this->assertEquals(
$identification->serialize(), get_class($this->provider_mock) .
"|dummy");
126 $identification = $this->identification->core($this->provider_mock)->identifier(
'dummy');
129 $new_identification = $this->identification->fromSerializedIdentification($serialized_identification);
136 $this->plugin_mock->shouldReceive(
'getId')->once()->andReturn(
'xdemo');
139 $this->provider_mock->shouldReceive(
'getProviderNameForPresentation')->andReturn(
'Provider');
140 $new_identification = $this->identification->fromSerializedIdentification($serialized_identification);
147 $this->expectException(InvalidArgumentException::class);
148 $this->expectExceptionMessage(
"Nobody can handle serialized identification 'ThisStringWillNobodyHandle'.");
149 $this->identification->fromSerializedIdentification(
"ThisStringWillNobodyHandle");
155 $class_name = self::MOCKED_PROVIDER_CLASSNAME;
156 $internal_identifier =
"internal_identifier";
158 $string_core =
"{$class_name}|{$internal_identifier}";
159 $identification = $this->identification->fromSerializedIdentification($string_core);
163 $this->assertEquals(
$identification->getInternalIdentifier(), $internal_identifier);
169 $class_name = self::MOCKED_PROVIDER_CLASSNAME;
170 $internal_identifier =
"internal_identifier";
173 $string_plugin =
"xdemo|{$class_name}|{$internal_identifier}";
174 $identification = $this->identification->fromSerializedIdentification($string_plugin);
178 $this->assertEquals(
$identification->getInternalIdentifier(), $internal_identifier);
testUnserializingFailsSinceNobpbyCanhandleTheString()
testFactoryMustReturnCorrectTypeCore()
testFactoryMustReturnCorrectTypePlugin()
testUnserializingPlugin()
Class IdentificationFactory.
const MOCKED_PROVIDER_CLASSNAME
Class IdentificationFactoryTest.