ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
IdentificationTest.php
Go to the documentation of this file.
1<?php
2
4
10use ilPlugin;
11use Mockery;
12use Mockery\Adapter\Phpunit\MockeryPHPUnitIntegration;
13use PHPUnit\Framework\TestCase;
14
15require_once('./libs/composer/vendor/autoload.php');
16
27class IdentificationTest extends TestCase
28{
29 use MockeryPHPUnitIntegration;
30 const MOCKED_PROVIDER_CLASSNAME = 'Mockery_1_ILIAS_GlobalScreen_Provider_Provider';
42 private $plugin_mock;
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}
An exception for terminatinating execution or to throw for unit testing.