ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
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

Member Function Documentation

◆ setUp()

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

@inheritDoc

Definition at line 73 of file IdentificationFactoryTestTBD.php.

73 : void
74 {
75 parent::setUp();
76
77 $this->plugin_mock = Mockery::mock(ilPlugin::class);
78
79 $this->provider_mock = Mockery::mock(Provider::class);
80 $this->provider_mock->shouldReceive('getProviderNameForPresentation')->andReturn('Provider')->byDefault();
81
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);
86
87 $this->identification = new IdentificationFactory($this->provider_factory);
88 }

◆ testAvailableMethods()

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

Definition at line 91 of file IdentificationFactoryTestTBD.php.

91 : void
92 {
93 $r = new ReflectionClass($this->identification);
94
95 $methods = [];
96 foreach ($r->getMethods(ReflectionMethod::IS_PUBLIC) as $method) {
97 $methods[] = $method->getName();
98 }
99 sort($methods);
100 $this->assertSame(
101 [
102 0 => '__construct',
103 1 => 'core',
104 2 => 'fromSerializedIdentification',
105 3 => 'plugin',
106 4 => 'tool'
107 ],
108 $methods
109 );
110 }

References ILIAS\UI\examples\Symbol\Glyph\Sort\sort().

+ Here is the call graph for this function:

◆ testCore()

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

Definition at line 113 of file IdentificationFactoryTestTBD.php.

113 : void
114 {
115 $this->assertInstanceOf(IdentificationProviderInterface::class, $this->identification->core($this->provider_mock));
116 $this->assertInstanceOf(IdentificationInterface::class, $this->identification->core($this->provider_mock)->identifier('dummy'));
117 }

◆ testFactoryMustReturnCorrectTypeCore()

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

Definition at line 167 of file IdentificationFactoryTestTBD.php.

167 : void
168 {
170 $internal_identifier = "internal_identifier";
171
172 $string_core = "$class_name|$internal_identifier";
173 $identification = $this->identification->fromSerializedIdentification($string_core);
174
175 $this->assertInstanceOf(CoreIdentification::class, $identification);
176 $this->assertSame($identification->getClassName(), $class_name);
177 $this->assertSame($identification->getInternalIdentifier(), $internal_identifier);
178 }

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 181 of file IdentificationFactoryTestTBD.php.

181 : void
182 {
184 $internal_identifier = "internal_identifier";
185
186 // $this->markTestSkipped('I currently have absolutely no idea why this test does not work since this seems to be identical zo the test testUnserializingCore :(');
187 $string_plugin = "xdemo|$class_name|$internal_identifier";
188 $identification = $this->identification->fromSerializedIdentification($string_plugin);
189
190 $this->assertInstanceOf(PluginIdentification::class, $identification);
191 $this->assertSame($identification->getClassName(), $class_name);
192 $this->assertSame($identification->getInternalIdentifier(), $internal_identifier);
193 }

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 120 of file IdentificationFactoryTestTBD.php.

120 : void
121 {
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);
125 $identification = $identification_provider->identifier('dummy');
126 $this->assertInstanceOf(IdentificationInterface::class, $identification);
127 }

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

◆ testSerializingCore()

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

Definition at line 130 of file IdentificationFactoryTestTBD.php.

130 : void
131 {
132 $identification = $this->identification->core($this->provider_mock)->identifier('dummy');
133 $this->assertInstanceOf(Serializable::class, $identification);
134 $this->assertEquals($identification->serialize(), $this->provider_mock::class . "|dummy");
135 }
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 138 of file IdentificationFactoryTestTBD.php.

138 : void
139 {
140 $identification = $this->identification->core($this->provider_mock)->identifier('dummy');
141 $serialized_identification = $identification->serialize();
142
143 $new_identification = $this->identification->fromSerializedIdentification($serialized_identification);
144 $this->assertEquals($identification, $new_identification);
145 }

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 159 of file IdentificationFactoryTestTBD.php.

159 : void
160 {
161 $this->expectException(InvalidArgumentException::class);
162 $this->expectExceptionMessage("Nobody can handle serialized identification 'ThisStringWillNobodyHandle'.");
163 $this->identification->fromSerializedIdentification("ThisStringWillNobodyHandle");
164 }

◆ testUnserializingPlugin()

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

Definition at line 148 of file IdentificationFactoryTestTBD.php.

148 : void
149 {
150 $this->plugin_mock->shouldReceive('getId')->once()->andReturn('xdemo');
151 $identification = $this->identification->plugin($this->plugin_mock->getId(), $this->provider_mock)->identifier('dummy');
152 $serialized_identification = $identification->serialize();
153 $this->provider_mock->shouldReceive('getProviderNameForPresentation')->andReturn('Provider');
154 $new_identification = $this->identification->fromSerializedIdentification($serialized_identification);
155 $this->assertEquals($identification, $new_identification);
156 }
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 66 of file IdentificationFactoryTestTBD.php.

◆ $provider_factory

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

Definition at line 58 of file IdentificationFactoryTestTBD.php.

◆ $provider_mock

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

Definition at line 62 of file IdentificationFactoryTestTBD.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: