ILIAS  release_7 Revision v7.30-3-g800a261c036
All Data Structures Namespaces Files Functions Variables Modules Pages
IdentificationTest.php
Go to the documentation of this file.
1 <?php
2 
20 
26 use ilPlugin;
27 use Mockery;
30 use LogicException;
31 
32 require_once('./libs/composer/vendor/autoload.php');
33 
45 {
47  public const MOCKED_PROVIDER_CLASSNAME = 'Mockery_1_ILIAS_GlobalScreen_Provider_Provider';
55  private $provider_mock;
59  private $plugin_mock;
63  private $identification;
64 
65 
69  protected function setUp() : void
70  {
71  parent::setUp();
72 
73  $this->plugin_mock = Mockery::mock(ilPlugin::class);
74 
75  $this->provider_mock = Mockery::mock(Provider::class);
76  $this->provider_mock->shouldReceive('getProviderNameForPresentation')->andReturn('Provider')->byDefault();
77 
78  $this->provider_factory = Mockery::mock(ProviderFactory::class);
79  $this->provider_factory->shouldReceive('getProviderByClassName')->with(self::MOCKED_PROVIDER_CLASSNAME)->andReturn($this->provider_mock);
80  $this->provider_factory->shouldReceive('isInstanceCreationPossible')->andReturn(true);
81  $this->provider_factory->shouldReceive('isRegistered')->andReturn(true);
82 
83  $this->identification = new IdentificationFactory($this->provider_factory);
84  }
85 
86 
88  {
89  $string = str_repeat("x", SerializerInterface::MAX_LENGTH - strlen(self::MOCKED_PROVIDER_CLASSNAME) - strlen(CoreSerializer::DIVIDER) + 1);
90  $this->expectException(LogicException::class);
91  $this->identification->core($this->provider_mock)->identifier($string);
92  }
93 
94 
96  {
97  $string = str_repeat("x", SerializerInterface::MAX_LENGTH - strlen(self::MOCKED_PROVIDER_CLASSNAME) - strlen(CoreSerializer::DIVIDER));
98  $this->identification->core($this->provider_mock)->identifier($string);
99  $this->assertTrue(true); // No Exception is thrown
100  }
101 }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Class IdentificationFactory All elements in the GlobalScreen service must be identifiable for the sup...