ILIAS  release_7 Revision v7.30-3-g800a261c036
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
 
 $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 49 of file IdentificationFactoryTest.php.

Member Function Documentation

◆ setUp()

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

@inheritDoc

Definition at line 74 of file IdentificationFactoryTest.php.

74 : void
75 {
76 parent::setUp();
77
78 $this->plugin_mock = Mockery::mock(ilPlugin::class);
79
80 $this->provider_mock = Mockery::mock(Provider::class);
81 $this->provider_mock->shouldReceive('getProviderNameForPresentation')->andReturn('Provider')->byDefault();
82
83 $this->provider_factory = Mockery::mock(ProviderFactory::class);
84 $this->provider_factory->shouldReceive('getProviderByClassName')->with(self::MOCKED_PROVIDER_CLASSNAME)->andReturn($this->provider_mock);
85 $this->provider_factory->shouldReceive('isInstanceCreationPossible')->andReturn(true);
86 $this->provider_factory->shouldReceive('isRegistered')->andReturn(true);
87
88 $this->identification = new IdentificationFactory($this->provider_factory);
89 }

◆ testAvailableMethods()

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

Definition at line 92 of file IdentificationFactoryTest.php.

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

◆ testCore()

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

Definition at line 114 of file IdentificationFactoryTest.php.

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

◆ testFactoryMustReturnCorrectTypeCore()

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

Definition at line 168 of file IdentificationFactoryTest.php.

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

References ILIAS\GlobalScreen\MainMenu\IdentificationFactoryTest\$identification, and ILIAS\GlobalScreen\MainMenu\IdentificationFactoryTest\MOCKED_PROVIDER_CLASSNAME.

◆ testFactoryMustReturnCorrectTypePlugin()

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

Definition at line 182 of file IdentificationFactoryTest.php.

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

References ILIAS\GlobalScreen\MainMenu\IdentificationFactoryTest\$identification, and ILIAS\GlobalScreen\MainMenu\IdentificationFactoryTest\MOCKED_PROVIDER_CLASSNAME.

◆ testPlugin()

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

Definition at line 121 of file IdentificationFactoryTest.php.

121 : void
122 {
123 $this->plugin_mock->shouldReceive('getId')->once()->andReturn('xdemo');
124 $identification_provider = $this->identification->plugin($this->plugin_mock->getId(), $this->provider_mock);
125 $this->assertInstanceOf(IdentificationProviderInterface::class, $identification_provider);
126 $identification = $identification_provider->identifier('dummy');
127 $this->assertInstanceOf(IdentificationInterface::class, $identification);
128 }

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

◆ testSerializingCore()

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

Definition at line 131 of file IdentificationFactoryTest.php.

131 : void
132 {
133 $identification = $this->identification->core($this->provider_mock)->identifier('dummy');
134 $this->assertInstanceOf(Serializable::class, $identification);
135 $this->assertEquals($identification->serialize(), get_class($this->provider_mock) . "|dummy");
136 }

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

◆ testUnserializingCore()

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

Definition at line 139 of file IdentificationFactoryTest.php.

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

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

◆ testUnserializingFailsSinceNobpbyCanhandleTheString()

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

Definition at line 160 of file IdentificationFactoryTest.php.

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

◆ testUnserializingPlugin()

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

Definition at line 149 of file IdentificationFactoryTest.php.

149 : void
150 {
151 $this->plugin_mock->shouldReceive('getId')->once()->andReturn('xdemo');
152 $identification = $this->identification->plugin($this->plugin_mock->getId(), $this->provider_mock)->identifier('dummy');
153 $serialized_identification = $identification->serialize();
154 $this->provider_mock->shouldReceive('getProviderNameForPresentation')->andReturn('Provider');
155 $new_identification = $this->identification->fromSerializedIdentification($serialized_identification);
156 $this->assertEquals($identification, $new_identification);
157 }

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

Field Documentation

◆ $identification

◆ $plugin_mock

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

Definition at line 64 of file IdentificationFactoryTest.php.

◆ $provider_factory

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

Definition at line 56 of file IdentificationFactoryTest.php.

◆ $provider_mock

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

Definition at line 60 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: