22 require_once(
'./libs/composer/vendor/autoload.php');
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(ProviderFactoryInterface::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',
100 $this->assertInstanceOf(IdentificationProviderInterface::class, $this->identification->core($this->provider_mock));
101 $this->assertInstanceOf(IdentificationInterface::class, $this->identification->core($this->provider_mock)->identifier(
'dummy'));
107 $this->plugin_mock->shouldReceive(
'getId')->once()->andReturn(
'xdemo');
108 $identification_provider = $this->identification->plugin($this->plugin_mock, $this->provider_mock);
109 $this->assertInstanceOf(IdentificationProviderInterface::class, $identification_provider);
111 $this->assertInstanceOf(IdentificationInterface::class,
$identification);
117 $identification = $this->identification->core($this->provider_mock)->identifier(
'dummy');
119 $this->assertEquals(
$identification->serialize(), get_class($this->provider_mock) .
"|dummy");
125 $identification = $this->identification->core($this->provider_mock)->identifier(
'dummy');
128 $new_identification = $this->identification->fromSerializedIdentification($serialized_identification);
135 $this->plugin_mock->shouldReceive(
'getId')->once()->andReturn(
'xdemo');
136 $identification = $this->identification->plugin($this->plugin_mock, $this->provider_mock)->identifier(
'dummy');
138 $this->provider_mock->shouldReceive(
'getProviderNameForPresentation')->andReturn(
'Provider');
139 $new_identification = $this->identification->fromSerializedIdentification($serialized_identification);
146 $this->expectException(InvalidArgumentException::class);
147 $this->expectExceptionMessage(
"Nobody can handle serialized identification 'ThisStringWillNobodyHandle'.");
148 $this->identification->fromSerializedIdentification(
"ThisStringWillNobodyHandle");
154 $class_name = self::MOCKED_PROVIDER_CLASSNAME;
155 $internal_identifier =
"internal_identifier";
157 $string_core =
"{$class_name}|{$internal_identifier}";
158 $identification = $this->identification->fromSerializedIdentification($string_core);
162 $this->assertEquals(
$identification->getInternalIdentifier(), $internal_identifier);
168 $class_name = self::MOCKED_PROVIDER_CLASSNAME;
169 $internal_identifier =
"internal_identifier";
172 $string_plugin =
"xdemo|{$class_name}|{$internal_identifier}";
173 $identification = $this->identification->fromSerializedIdentification($string_plugin);
177 $this->assertEquals(
$identification->getInternalIdentifier(), $internal_identifier);
testUnserializingFailsSinceNobpbyCanhandleTheString()
testFactoryMustReturnCorrectTypeCore()
testFactoryMustReturnCorrectTypePlugin()
testUnserializingPlugin()
Class IdentificationFactory.
const MOCKED_PROVIDER_CLASSNAME
Class IdentificationFactoryTest.