ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
DefaultMappingsTest.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
25use ILIAS\UI\Factory as UIFactory;
30use ilRbacReview;
32use ILIAS\UI\Factory as UI;
33use ilLanguage;
35use PHPUnit\Framework\TestCase;
38
39require_once __DIR__ . '/ContainerMock.php';
40
41class DefaultMappingsTest extends TestCase
42{
43 use ContainerMock;
44
45 public function testConstruct(): void
46 {
47 $this->assertInstanceOf(DefaultMappings::class, new DefaultMappings('foo', $this->mock(Container::class)));
48 }
49
50 public function testConditionDefinitions(): void
51 {
52 $container = $this->mockTree(Container::class, [
53 'ui' => [
54 'factory' => $this->mock(UI::class),
55 'mainTemplate' => $this->mock(ilGlobalTemplateInterface::class),
56 ],
57 'language' => $this->mockMethod(ilLanguage::class, 'getInstalledLanguages', [], []),
58 'rbac' => $this->mockMethod(RBACServices::class, 'review', [], $this->mock(ilRbacReview::class)),
59 ]);
60 $container->method('offsetGet')->with('ilObjDataCache')->willReturn($this->mock(ilObjectDataCache::class));
61
62 $instance = new DefaultMappings('foo', $container);
63 $result = $instance->conditionDefinitions();
64 $definitions = $result->choices();
65 $this->assertSame('usr_country', $result->defaultSelection());
66 $this->assertSame(3, count($definitions));
67 $this->assertInstanceOf(RoleDefinition::class, $definitions['usr_global_role']);
68 $this->assertInstanceOf(UserLanguageDefinition::class, $definitions['usr_language']);
69 $this->assertInstanceOf(UserCountryDefinition::class, $definitions['usr_country']);
70 }
71
72 public function testContentAsComponent(): void
73 {
74 $legacy = $this->mock(Legacy\Content::class);
75 $legacy_factory = $this->mock(Legacy\Factory::class);
76 $legacy_factory
77 ->expects($this->once())
78 ->method('content')
79 ->willReturn($legacy);
80
81 $container = $this->mockTree(Container::class, [
82 'ui' => ['factory' => $this->mockMethod(UIFactory::class, 'legacy', [], $legacy_factory)],
83 ]);
84
85 $instance = new DefaultMappings('foo', $container);
86 $map = $instance->contentAsComponent();
87 $this->assertSame(['html'], array_keys($map));
88 $this->assertSame($legacy, $map['html']($this->mockTree(DocumentContent::class, ['value' => 'bar'])));
89 }
90}
Customizing of pimple-DIC for ILIAS.
Definition: Container.php:36
Provides fluid interface to RBAC services.
Builds a Color from either hex- or rgb values.
Definition: Factory.php:31
language handling
class ilObjectDataCache
class ilRbacReview Contains Review functions of core Rbac.
$container
@noRector
Definition: wac.php:37