ILIAS  trunk Revision v11.0_alpha-1761-g6dbbfa7b760
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
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 ()
 

Protected Attributes

 $provider_factory
 
 $provider_mock
 
 $plugin_mock
 
IdentificationFactory $identification
 

Detailed Description

Member Function Documentation

◆ setUp()

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

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.

References $r, and ILIAS\UI\examples\Symbol\Glyph\Sort\sort().

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->assertEquals(
101  [
102  0 => '__construct',
103  1 => 'core',
104  2 => 'fromSerializedIdentification',
105  3 => 'plugin',
106  4 => 'tool'
107  ],
108  $methods
109  );
110  }
sort()
description: > Example for rendering a Sort Glyph.
Definition: sort.php:41
$r
+ 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.

References ILIAS\GlobalScreen\Identification\IdentificationFactory\fromSerializedIdentification().

167  : void
168  {
169  $class_name = self::MOCKED_PROVIDER_CLASSNAME;
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->assertEquals($identification->getClassName(), $class_name);
177  $this->assertEquals($identification->getInternalIdentifier(), $internal_identifier);
178  }
+ Here is the call graph for this function:

◆ testFactoryMustReturnCorrectTypePlugin()

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

Definition at line 181 of file IdentificationFactoryTestTBD.php.

References ILIAS\GlobalScreen\Identification\IdentificationFactory\fromSerializedIdentification().

181  : void
182  {
183  $class_name = self::MOCKED_PROVIDER_CLASSNAME;
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->assertEquals($identification->getClassName(), $class_name);
192  $this->assertEquals($identification->getInternalIdentifier(), $internal_identifier);
193  }
+ Here is the call graph for this function:

◆ testPlugin()

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

Definition at line 120 of file IdentificationFactoryTestTBD.php.

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

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  }

◆ testSerializingCore()

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

Definition at line 130 of file IdentificationFactoryTestTBD.php.

References ILIAS\GlobalScreen\Identification\IdentificationFactory\core().

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.
+ Here is the call graph for this function:

◆ testUnserializingCore()

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

Definition at line 138 of file IdentificationFactoryTestTBD.php.

References ILIAS\GlobalScreen\Identification\IdentificationFactory\core(), and ILIAS\GlobalScreen\Identification\IdentificationFactory\fromSerializedIdentification().

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  }
core(Provider $provider)
Returns a IdentificationProvider for core components, only a Provider is needed.
+ 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.

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

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...
+ Here is the call graph for this function:

Field Documentation

◆ $identification

IdentificationFactory ILIAS\GlobalScreen\MainMenu\IdentificationFactoryTest::$identification
protected

Definition at line 67 of file IdentificationFactoryTestTBD.php.

◆ $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

◆ MOCKED_PROVIDER_CLASSNAME

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

Definition at line 54 of file IdentificationFactoryTestTBD.php.


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