ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
IdentificationTestTBD.php
Go to the documentation of this file.
1<?php
2
20
21use PHPUnit\Framework\Attributes\BackupGlobals;
22use PHPUnit\Framework\Attributes\BackupStaticProperties;
23use PHPUnit\Framework\Attributes\PreserveGlobalState;
24use PHPUnit\Framework\Attributes\RunTestsInSeparateProcesses;
30use ilPlugin;
31use Mockery;
32use Mockery\Adapter\Phpunit\MockeryPHPUnitIntegration;
33use PHPUnit\Framework\TestCase;
34use LogicException;
35
36require_once('./vendor/composer/vendor/autoload.php');
37
43#[BackupGlobals(false)]
44#[BackupStaticProperties(false)]
45#[PreserveGlobalState(false)]
46#[RunTestsInSeparateProcesses]
47class IdentificationTest extends TestCase
48{
49 use MockeryPHPUnitIntegration;
50 public const MOCKED_PROVIDER_CLASSNAME = 'Mockery_1_ILIAS_GlobalScreen_Provider_Provider';
56
57
61 protected function setUp(): void
62 {
63 parent::setUp();
64
65 $plugin_mock = Mockery::mock(ilPlugin::class);
66
67 $this->provider_mock = Mockery::mock(Provider::class);
68 $this->provider_mock->shouldReceive('getProviderNameForPresentation')->andReturn('Provider')->byDefault();
69
70 $provider_factory = Mockery::mock(ProviderFactory::class);
71 $provider_factory->shouldReceive('getProviderByClassName')->with(self::MOCKED_PROVIDER_CLASSNAME)->andReturn($this->provider_mock);
72 $provider_factory->shouldReceive('isInstanceCreationPossible')->andReturn(true);
73 $provider_factory->shouldReceive('isRegistered')->andReturn(true);
74
75 $this->identification = new IdentificationFactory($provider_factory);
76 }
77
78
80 {
81 $string = str_repeat("x", SerializerInterface::MAX_LENGTH - strlen(self::MOCKED_PROVIDER_CLASSNAME) - strlen(CoreSerializer::DIVIDER) + 1);
82 $this->expectException(LogicException::class);
83 $this->identification->core($this->provider_mock)->identifier($string);
84 }
85
86
88 {
89 $string = str_repeat("x", SerializerInterface::MAX_LENGTH - strlen(self::MOCKED_PROVIDER_CLASSNAME) - strlen(CoreSerializer::DIVIDER));
90 $this->identification->core($this->provider_mock)->identifier($string);
91 $this->assertTrue(true); // No Exception is thrown
92 }
93}
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...