ILIAS  trunk Revision v11.0_alpha-1689-g66c127b4ae8
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
UserCountryTest.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
22 
31 use ilObjUser;
32 
33 require_once __DIR__ . '/../ContainerMock.php';
34 
35 class 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 }