ILIAS  trunk Revision v11.0_alpha-2662-g519ff7d528f
IdentificationTestTBD.php
Go to the documentation of this file.
1 <?php
2 
20 
30 use ilPlugin;
31 use Mockery;
34 use LogicException;
35 
36 require_once('./vendor/composer/vendor/autoload.php');
37 
43 #[BackupGlobals(false)]
44 #[BackupStaticProperties(false)]
45 #[PreserveGlobalState(false)]
46 #[RunTestsInSeparateProcesses]
47 class IdentificationTest extends TestCase
48 {
50  public const MOCKED_PROVIDER_CLASSNAME = 'Mockery_1_ILIAS_GlobalScreen_Provider_Provider';
54  private $provider_mock;
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 }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Class IdentificationFactory All elements in the GlobalScreen service must be identifiable for the sup...