ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
UserCountryTest.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
25use ILIAS\LegalDocuments\test\ContainerMock;
28use PHPUnit\Framework\TestCase;
30use ILIAS\UI\Factory as UIFactory;
31use ilObjUser;
32
33require_once __DIR__ . '/../ContainerMock.php';
34
35class UserCountryTest extends TestCase
36{
37 use ContainerMock;
38
39 public function testConstruct(): void
40 {
41 $this->assertInstanceOf(UserCountry::class, new UserCountry(
42 $this->mock(CriterionContent::class),
43 $this->mock(UserCountryDefinition::class),
44 $this->mock(UIFactory::class)
45 ));
46 }
47
48 public function testAsComponent(): void
49 {
50 $legacy = $this->mock(Legacy\Content::class);
51 $legacy_factory = $this->mock(Legacy\Factory::class);
52 $legacy_factory
53 ->expects($this->once())
54 ->method('content')
55 ->willReturn($legacy);
56
57 $instance = new UserCountry(
58 $this->mockTree(CriterionContent::class, ['arguments' => ['country' => 'foo']]),
59 $this->mock(UserCountryDefinition::class),
60 $this->mockTree(UIFactory::class, ['legacy' => $legacy_factory])
61 );
62
63 $this->assertSame($legacy, $instance->asComponent());
64 }
65
66 public function testEval(): void
67 {
68 $instance = new UserCountry(
69 $this->mockTree(CriterionContent::class, ['arguments' => ['country' => 'foo']]),
70 $this->mock(UserCountryDefinition::class),
71 $this->mock(UIFactory::class)
72 );
73
74 $this->assertTrue($instance->eval($this->mockTree(ilObjUser::class, ['getCountry' => 'foo'])));
75 }
76
77 public function testDefinition(): void
78 {
79 $definition = $this->mock(UserCountryDefinition::class);
80 $instance = new UserCountry(
81 $this->mock(CriterionContent::class),
82 $definition,
83 $this->mock(UIFactory::class)
84 );
85
86 $this->assertSame($definition, $instance->definition());
87 }
88
89 public function testKnownToNeverMatchWith(): void
90 {
91 $instance = new UserCountry(
92 $this->mock(CriterionContent::class),
93 $this->mock(UserCountryDefinition::class),
94 $this->mock(UIFactory::class)
95 );
96
97 $second = new UserCountry(
98 $this->mock(CriterionContent::class),
99 $this->mock(UserCountryDefinition::class),
100 $this->mock(UIFactory::class)
101 );
102
103 $this->assertTrue($instance->knownToNeverMatchWith($second));
104 $this->assertFalse($instance->knownToNeverMatchWith($this->mock(Condition::class)));
105 }
106}
Builds a Color from either hex- or rgb values.
Definition: Factory.php:31
User class.