ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
IdentificationTest.php
Go to the documentation of this file.
1 <?php
2 
4 
10 use ilPlugin;
11 use Mockery;
14 
15 require_once('./libs/composer/vendor/autoload.php');
16 
27 class IdentificationTest extends TestCase
28 {
30  const MOCKED_PROVIDER_CLASSNAME = 'Mockery_1_ILIAS_GlobalScreen_Provider_Provider';
38  private $provider_mock;
42  private $plugin_mock;
46  private $identification;
47 
48 
52  protected function setUp()
53  {
54  parent::setUp();
55 
56  $this->plugin_mock = Mockery::mock(ilPlugin::class);
57 
58  $this->provider_mock = Mockery::mock(Provider::class);
59  $this->provider_mock->shouldReceive('getProviderNameForPresentation')->andReturn('Provider')->byDefault();
60 
61  $this->provider_factory = Mockery::mock(ProviderFactoryInterface::class);
62  $this->provider_factory->shouldReceive('getProviderByClassName')->with(self::MOCKED_PROVIDER_CLASSNAME)->andReturn($this->provider_mock);
63  $this->provider_factory->shouldReceive('isInstanceCreationPossible')->andReturn(true);
64  $this->provider_factory->shouldReceive('isRegistered')->andReturn(true);
65 
66  $this->identification = new IdentificationFactory($this->provider_factory);
67  }
68 
69 
71  {
72  $string = str_repeat("x", SerializerInterface::MAX_LENGTH - strlen(self::MOCKED_PROVIDER_CLASSNAME) - strlen(CoreSerializer::DIVIDER) + 1);
73  $this->expectException(\LogicException::class);
74  $this->identification->core($this->provider_mock)->identifier($string);
75  }
76 
77 
79  {
80  $string = str_repeat("x", SerializerInterface::MAX_LENGTH - strlen(self::MOCKED_PROVIDER_CLASSNAME) - strlen(CoreSerializer::DIVIDER));
81  $this->identification->core($this->provider_mock)->identifier($string);
82  }
83 }