ILIAS  release_8 Revision v8.24
ILIAS\GlobalScreen\MainMenu\IdentificationFactoryTest Class Reference

Class IdentificationFactoryTest. More...

+ Inheritance diagram for ILIAS\GlobalScreen\MainMenu\IdentificationFactoryTest:
+ Collaboration diagram for ILIAS\GlobalScreen\MainMenu\IdentificationFactoryTest:

Public Member Functions

 testAvailableMethods ()
 
 testCore ()
 
 testPlugin ()
 
 testSerializingCore ()
 
 testUnserializingCore ()
 
 testUnserializingPlugin ()
 
 testUnserializingFailsSinceNobpbyCanhandleTheString ()
 
 testFactoryMustReturnCorrectTypeCore ()
 
 testFactoryMustReturnCorrectTypePlugin ()
 

Data Fields

const MOCKED_PROVIDER_CLASSNAME = 'Mockery_1_ILIAS_GlobalScreen_Provider_Provider'
 

Protected Member Functions

 setUp ()
 @inheritDoc More...
 

Protected Attributes

 $provider_factory
 
 $provider_mock
 
 $plugin_mock
 
IdentificationFactory $identification
 

Detailed Description

Class IdentificationFactoryTest.

Author
Fabian Schmid fs@st.nosp@m.uder.nosp@m.-raim.nosp@m.ann..nosp@m.ch

@runTestsInSeparateProcesses @preserveGlobalState disabled @backupGlobals disabled @backupStaticAttributes disabled

Definition at line 33 of file IdentificationFactoryTest.php.

Member Function Documentation

◆ setUp()

ILIAS\GlobalScreen\MainMenu\IdentificationFactoryTest::setUp ( )
protected

@inheritDoc

Definition at line 55 of file IdentificationFactoryTest.php.

55 : void
56 {
57 parent::setUp();
58
59 $this->plugin_mock = Mockery::mock(ilPlugin::class);
60
61 $this->provider_mock = Mockery::mock(Provider::class);
62 $this->provider_mock->shouldReceive('getProviderNameForPresentation')->andReturn('Provider')->byDefault();
63
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);
68
69 $this->identification = new IdentificationFactory($this->provider_factory);
70 }

◆ testAvailableMethods()

ILIAS\GlobalScreen\MainMenu\IdentificationFactoryTest::testAvailableMethods ( )

Definition at line 73 of file IdentificationFactoryTest.php.

73 : void
74 {
75 $r = new ReflectionClass($this->identification);
76
77 $methods = [];
78 foreach ($r->getMethods(ReflectionMethod::IS_PUBLIC) as $method) {
79 $methods[] = $method->getName();
80 }
81 sort($methods);
82 $this->assertEquals(
83 [
84 0 => '__construct',
85 1 => 'core',
86 2 => 'fromSerializedIdentification',
87 3 => 'plugin',
88 4 => 'tool'
89 ],
90 $methods
91 );
92 }

◆ testCore()

ILIAS\GlobalScreen\MainMenu\IdentificationFactoryTest::testCore ( )

Definition at line 95 of file IdentificationFactoryTest.php.

95 : void
96 {
97 $this->assertInstanceOf(IdentificationProviderInterface::class, $this->identification->core($this->provider_mock));
98 $this->assertInstanceOf(IdentificationInterface::class, $this->identification->core($this->provider_mock)->identifier('dummy'));
99 }

◆ testFactoryMustReturnCorrectTypeCore()

ILIAS\GlobalScreen\MainMenu\IdentificationFactoryTest::testFactoryMustReturnCorrectTypeCore ( )

Definition at line 149 of file IdentificationFactoryTest.php.

149 : void
150 {
152 $internal_identifier = "internal_identifier";
153
154 $string_core = "$class_name|$internal_identifier";
155 $identification = $this->identification->fromSerializedIdentification($string_core);
156
157 $this->assertInstanceOf(CoreIdentification::class, $identification);
158 $this->assertEquals($identification->getClassName(), $class_name);
159 $this->assertEquals($identification->getInternalIdentifier(), $internal_identifier);
160 }

References ILIAS\GlobalScreen\MainMenu\IdentificationFactoryTest\$identification, ILIAS\GlobalScreen\Identification\IdentificationFactory\fromSerializedIdentification(), and ILIAS\GlobalScreen\MainMenu\IdentificationFactoryTest\MOCKED_PROVIDER_CLASSNAME.

+ Here is the call graph for this function:

◆ testFactoryMustReturnCorrectTypePlugin()

ILIAS\GlobalScreen\MainMenu\IdentificationFactoryTest::testFactoryMustReturnCorrectTypePlugin ( )

Definition at line 163 of file IdentificationFactoryTest.php.

163 : void
164 {
166 $internal_identifier = "internal_identifier";
167
168 // $this->markTestSkipped('I currently have absolutely no idea why this test does not work since this seems to be identical zo the test testUnserializingCore :(');
169 $string_plugin = "xdemo|$class_name|$internal_identifier";
170 $identification = $this->identification->fromSerializedIdentification($string_plugin);
171
172 $this->assertInstanceOf(PluginIdentification::class, $identification);
173 $this->assertEquals($identification->getClassName(), $class_name);
174 $this->assertEquals($identification->getInternalIdentifier(), $internal_identifier);
175 }

References ILIAS\GlobalScreen\MainMenu\IdentificationFactoryTest\$identification, ILIAS\GlobalScreen\Identification\IdentificationFactory\fromSerializedIdentification(), and ILIAS\GlobalScreen\MainMenu\IdentificationFactoryTest\MOCKED_PROVIDER_CLASSNAME.

+ Here is the call graph for this function:

◆ testPlugin()

ILIAS\GlobalScreen\MainMenu\IdentificationFactoryTest::testPlugin ( )

Definition at line 102 of file IdentificationFactoryTest.php.

102 : void
103 {
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);
107 $identification = $identification_provider->identifier('dummy');
108 $this->assertInstanceOf(IdentificationInterface::class, $identification);
109 }

References ILIAS\GlobalScreen\MainMenu\IdentificationFactoryTest\$identification.

◆ testSerializingCore()

ILIAS\GlobalScreen\MainMenu\IdentificationFactoryTest::testSerializingCore ( )

Definition at line 112 of file IdentificationFactoryTest.php.

112 : void
113 {
114 $identification = $this->identification->core($this->provider_mock)->identifier('dummy');
115 $this->assertInstanceOf(Serializable::class, $identification);
116 $this->assertEquals($identification->serialize(), get_class($this->provider_mock) . "|dummy");
117 }
core(Provider $provider)
Returns a IdentificationProvider for core components, only a Provider is needed.

References ILIAS\GlobalScreen\MainMenu\IdentificationFactoryTest\$identification, and ILIAS\GlobalScreen\Identification\IdentificationFactory\core().

+ Here is the call graph for this function:

◆ testUnserializingCore()

ILIAS\GlobalScreen\MainMenu\IdentificationFactoryTest::testUnserializingCore ( )

Definition at line 120 of file IdentificationFactoryTest.php.

120 : void
121 {
122 $identification = $this->identification->core($this->provider_mock)->identifier('dummy');
123 $serialized_identification = $identification->serialize();
124
125 $new_identification = $this->identification->fromSerializedIdentification($serialized_identification);
126 $this->assertEquals($identification, $new_identification);
127 }

References ILIAS\GlobalScreen\MainMenu\IdentificationFactoryTest\$identification, ILIAS\GlobalScreen\Identification\IdentificationFactory\core(), and ILIAS\GlobalScreen\Identification\IdentificationFactory\fromSerializedIdentification().

+ Here is the call graph for this function:

◆ testUnserializingFailsSinceNobpbyCanhandleTheString()

ILIAS\GlobalScreen\MainMenu\IdentificationFactoryTest::testUnserializingFailsSinceNobpbyCanhandleTheString ( )

Definition at line 141 of file IdentificationFactoryTest.php.

141 : void
142 {
143 $this->expectException(InvalidArgumentException::class);
144 $this->expectExceptionMessage("Nobody can handle serialized identification 'ThisStringWillNobodyHandle'.");
145 $this->identification->fromSerializedIdentification("ThisStringWillNobodyHandle");
146 }

◆ testUnserializingPlugin()

ILIAS\GlobalScreen\MainMenu\IdentificationFactoryTest::testUnserializingPlugin ( )

Definition at line 130 of file IdentificationFactoryTest.php.

130 : void
131 {
132 $this->plugin_mock->shouldReceive('getId')->once()->andReturn('xdemo');
133 $identification = $this->identification->plugin($this->plugin_mock->getId(), $this->provider_mock)->identifier('dummy');
134 $serialized_identification = $identification->serialize();
135 $this->provider_mock->shouldReceive('getProviderNameForPresentation')->andReturn('Provider');
136 $new_identification = $this->identification->fromSerializedIdentification($serialized_identification);
137 $this->assertEquals($identification, $new_identification);
138 }
plugin(string $plugin_id, Provider $provider)
Returns a IdentificationProvider for ILIAS-Plugins which takes care of the plugin_id for further iden...

References ILIAS\GlobalScreen\MainMenu\IdentificationFactoryTest\$identification, ILIAS\GlobalScreen\Identification\IdentificationFactory\fromSerializedIdentification(), and ILIAS\GlobalScreen\Identification\IdentificationFactory\plugin().

+ Here is the call graph for this function:

Field Documentation

◆ $identification

◆ $plugin_mock

ILIAS\GlobalScreen\MainMenu\IdentificationFactoryTest::$plugin_mock
protected

Definition at line 48 of file IdentificationFactoryTest.php.

◆ $provider_factory

ILIAS\GlobalScreen\MainMenu\IdentificationFactoryTest::$provider_factory
protected

Definition at line 40 of file IdentificationFactoryTest.php.

◆ $provider_mock

ILIAS\GlobalScreen\MainMenu\IdentificationFactoryTest::$provider_mock
protected

Definition at line 44 of file IdentificationFactoryTest.php.

◆ MOCKED_PROVIDER_CLASSNAME

const ILIAS\GlobalScreen\MainMenu\IdentificationFactoryTest::MOCKED_PROVIDER_CLASSNAME = 'Mockery_1_ILIAS_GlobalScreen_Provider_Provider'

The documentation for this class was generated from the following file: