ILIAS  release_8 Revision v8.24
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;
61
62
66 protected function setUp(): void
67 {
68 parent::setUp();
69
70 $this->plugin_mock = Mockery::mock(ilPlugin::class);
71
72 $this->provider_mock = Mockery::mock(Provider::class);
73 $this->provider_mock->shouldReceive('getProviderNameForPresentation')->andReturn('Provider')->byDefault();
74
75 $this->provider_factory = Mockery::mock(ProviderFactory::class);
76 $this->provider_factory->shouldReceive('getProviderByClassName')->with(self::MOCKED_PROVIDER_CLASSNAME)->andReturn($this->provider_mock);
77 $this->provider_factory->shouldReceive('isInstanceCreationPossible')->andReturn(true);
78 $this->provider_factory->shouldReceive('isRegistered')->andReturn(true);
79
80 $this->identification = new IdentificationFactory($this->provider_factory);
81 }
82
83
85 {
86 $string = str_repeat("x", SerializerInterface::MAX_LENGTH - strlen(self::MOCKED_PROVIDER_CLASSNAME) - strlen(CoreSerializer::DIVIDER) + 1);
87 $this->expectException(LogicException::class);
88 $this->identification->core($this->provider_mock)->identifier($string);
89 }
90
91
93 {
94 $string = str_repeat("x", SerializerInterface::MAX_LENGTH - strlen(self::MOCKED_PROVIDER_CLASSNAME) - strlen(CoreSerializer::DIVIDER));
95 $this->identification->core($this->provider_mock)->identifier($string);
96 $this->assertTrue(true); // No Exception is thrown
97 }
98}
Class IdentificationFactory All elements in the GlobalScreen service must be identifiable for the sup...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...