ILIAS  trunk Revision v11.0_alpha-1702-gfd3ecb7f852
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
ilApiUserCertificateRepositoryTest.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
25 {
26  private \ilDBInterface&\PHPUnit\Framework\MockObject\MockObject $database;
27  private \ilCtrlInterface&\PHPUnit\Framework\MockObject\MockObject $controller;
28 
29  protected function setUp(): void
30  {
31  $this->database = $this->createMock(ilDBInterface::class);
32  $this->controller = $this->createMock(ilCtrlInterface::class);
33  }
34 
35  public function testGetUserData(): void
36  {
37  $filter = new \ILIAS\Certificate\API\Filter\UserDataFilter();
38 
39  $this->database
40  ->method('fetchAssoc')
41  ->willReturnOnConsecutiveCalls(
42  [
43  'id' => 5,
44  'title' => 'test',
45  'obj_id' => 100,
46  'ref_id' => 5000,
47  'acquired_timestamp' => 1_234_567_890,
48  'usr_id' => 2000,
49  'firstname' => 'ilyas',
50  'lastname' => 'homer',
51  'login' => 'breakdanceMcFunkyPants',
52  'email' => 'ilyas@ilias.de',
53  'second_email' => 'breakdance@funky.de'
54  ],
55  [
56  'id' => 5,
57  'title' => 'test',
58  'obj_id' => 100,
59  'ref_id' => 6000,
60  'acquired_timestamp' => 1_234_567_890,
61  'usr_id' => 2000,
62  'firstname' => 'ilyas',
63  'lastname' => 'homer',
64  'login' => 'breakdanceMcFunkyPants',
65  'email' => 'ilyas@ilias.de',
66  'second_email' => 'breakdance@funky.de'
67  ],
68  null
69  );
70 
71  $this->controller->method('getLinkTargetByClass')->willReturn('somewhere.php?goto=4');
72 
73  $repository = new \ILIAS\Certificate\API\Repository\UserDataRepository(
74  $this->database,
75  $this->controller,
76  'no title given'
77  );
78 
80  $userData = $repository->getUserData($filter, ['something']);
81 
83  $object = $userData[5];
84  $this->assertSame('test', $object->getObjectTitle());
85  $this->assertSame(5, $object->getCertificateId());
86  $this->assertSame(100, $object->getObjectId());
87  $this->assertSame([5000, 6000], $object->getObjectRefIds());
88  $this->assertSame(1_234_567_890, $object->getIssuedOnTimestamp());
89  $this->assertSame(2000, $object->getUserId());
90  $this->assertSame('ilyas', $object->getUserFirstName());
91  $this->assertSame('homer', $object->getUserLastName());
92  $this->assertSame('breakdanceMcFunkyPants', $object->getUserLogin());
93  $this->assertSame('ilyas@ilias.de', $object->getUserEmail());
94  $this->assertSame('breakdance@funky.de', $object->getUserSecondEmail());
95  $this->assertSame('somewhere.php?goto=4', $object->getDownloadLink());
96  }
97 }
ilDBInterface &PHPUnit Framework MockObject MockObject $database
ilCtrlInterface &PHPUnit Framework MockObject MockObject $controller
Class ilCertificateBaseTestCase.
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null