ILIAS  release_8 Revision v8.24
ilAwarenessUserProviderContactRequestsTest.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
23use PHPUnit\Framework\MockObject\MockObject;
24
26{
30 private $user;
31
35 private $language;
36
37 public function testConstruct(): void
38 {
39 $this->assertInstanceOf(Contacts::class, $this->create());
40 }
41
42 public function testGetProviderId(): void
43 {
44 $this->assertSame('contact_approved', $this->create()->getProviderId());
45 }
46
47 public function testGetTitle(): void
48 {
49 $this->expectTranslation('getTitle', 'contact_awrn_req_contacts');
50 }
51
52 public function testGetInfo(): void
53 {
54 $this->expectTranslation('getInfo', 'contact_awrn_req_contacts_info');
55 }
56
57 public function testGetInitialUserSet(): void
58 {
59 $instance = $this->create();
60
61 $this->user->expects(self::once())->method('isAnonymous')->willReturn(true);
62
63 $this->assertEquals([], $instance->getInitialUserSet());
64 }
65
66 public function testIsHighlighted(): void
67 {
68 $this->assertTrue($this->create()->isHighlighted());
69 }
70
71 private function expectTranslation(string $method, string $languageKey): void
72 {
73 $expected = 'translated: ' . $languageKey;
74
75 $instance = $this->create();
76
77 $this->language->expects(self::once())->method('loadLanguageModule')->with('contact');
78 $this->language->expects(self::once())->method('txt')->with($languageKey)->willReturn($expected);
79
80 $this->assertSame($expected, $instance->$method());
81 }
82
83 private function create(): Contacts
84 {
85 $this->user = $this->getMockBuilder(ilObjUser::class)->disableOriginalConstructor()->getMock();
86 $this->language = $this->getMockBuilder(ilLanguage::class)->disableOriginalConstructor()->getMock();
87
88 $container = $this->getMockBuilder(Container::class)->disableOriginalConstructor()->getMock();
89 $container->expects(self::once())->method('user')->willReturn($this->user);
90 $container->expects(self::once())->method('language')->willReturn($this->language);
91
92 return new Contacts($container);
93 }
94}
Customizing of pimple-DIC for ILIAS.
Definition: Container.php:32
$container
@noRector
Definition: wac.php:14