ILIAS  trunk Revision v13.0_alpha-62-g3b72d83f2e5
IdentificationTest.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 PHPUnit\Framework\TestCase;
31use LogicException;
32
33require_once('./vendor/composer/vendor/autoload.php');
34
40#[BackupGlobals(false)]
41#[BackupStaticProperties(false)]
42#[PreserveGlobalState(false)]
43#[RunTestsInSeparateProcesses]
44class IdentificationTest extends TestCase
45{
47 private string $provider_class_name;
49
50
54 protected function setUp(): void
55 {
57
58 $this->provider_mock = $this->createStub(Provider::class);
59 $this->provider_mock->method('getProviderNameForPresentation')->willReturn('Provider');
60 $this->provider_class_name = $this->provider_mock::class;
61
62 $provider_factory = $this->createStub(ProviderFactory::class);
63 $provider_factory->method('getProviderByClassName')->willReturnMap([
64 [$this->provider_class_name, $this->provider_mock],
65 ]);
66 $provider_factory->method('isInstanceCreationPossible')->willReturn(true);
67 $provider_factory->method('isRegistered')->willReturn(true);
68
69 $this->identification = new IdentificationFactory($provider_factory);
70 }
71
72
74 {
75 $string = str_repeat("x", SerializerInterface::MAX_LENGTH - strlen($this->provider_class_name) - strlen(CoreSerializer::DIVIDER) + 1);
76 $this->expectException(LogicException::class);
77 $this->identification->core($this->provider_mock)->identifier($string);
78 }
79
80
82 {
83 $string = str_repeat("x", SerializerInterface::MAX_LENGTH - strlen($this->provider_class_name) - strlen(CoreSerializer::DIVIDER));
84 $identification = $this->identification->core($this->provider_mock)->identifier($string);
85 $this->assertSame(SerializerInterface::MAX_LENGTH, strlen($identification->serialize()));
86 }
87}
Class IdentificationFactory All elements in the GlobalScreen service must be identifiable for the sup...
core(Provider $provider)
Returns a IdentificationProvider for core components, only a Provider is needed.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...