ILIAS  release_7 Revision v7.30-3-g800a261c036
IdentificationTest.php
Go to the documentation of this file.
1<?php
2
20
26use ilPlugin;
27use Mockery;
28use Mockery\Adapter\Phpunit\MockeryPHPUnitIntegration;
29use PHPUnit\Framework\TestCase;
30use LogicException;
31
32require_once('./libs/composer/vendor/autoload.php');
33
44class IdentificationTest extends TestCase
45{
46 use MockeryPHPUnitIntegration;
47 public const MOCKED_PROVIDER_CLASSNAME = 'Mockery_1_ILIAS_GlobalScreen_Provider_Provider';
59 private $plugin_mock;
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}
An exception for terminatinating execution or to throw for unit testing.
Class IdentificationFactory All elements in the GlobalScreen service must be identifiable for the sup...
Abstract Class ilPlugin.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...