19 declare(strict_types=1);
40 $this->expectException(CouldNotFindPageMetrics::class);
42 $database = $this->getMockBuilder(ilDBInterface::class)->getMock();
43 $database->method(
'fetchAssoc')->willReturn(
null);
45 $repo =
new PageMetricsRepositoryImp($database);
46 $repo->findBy(1, 1,
'de');
51 $readingTimeInMinutes = 4711;
54 $contentPageId = 1337;
56 $database = $this->getMockBuilder(ilDBInterface::class)->getMock();
57 $database->method(
'fetchAssoc')->willReturn(
59 'content_page_id' => $contentPageId,
62 'reading_time' => $readingTimeInMinutes
66 $repo =
new PageMetricsRepositoryImp($database);
67 $pageMetrics = $repo->findBy($contentPageId, $pageId, $language);
69 $this->assertSame($readingTimeInMinutes, $pageMetrics->readingTime()->minutes());
70 $this->assertSame($language, $pageMetrics->language());
71 $this->assertSame($contentPageId, $pageMetrics->contentPageId());
72 $this->assertSame($pageId, $pageMetrics->pageId());
77 $database = $this->getMockBuilder(ilDBInterface::class)->getMock();
79 $pageMetrics = $this->getMockBuilder(PageMetrics::class)->disableOriginalConstructor()->getMock();
80 $pageMetrics->expects($this->once())->method(
'contentPageId');
81 $pageMetrics->expects($this->once())->method(
'pageId');
82 $pageMetrics->expects($this->once())->method(
'language');
83 $pageMetrics->expects($this->once())->method(
'readingTime');
85 $repo =
new PageMetricsRepositoryImp($database);
86 $repo->store($pageMetrics);
91 $database = $this->getMockBuilder(ilDBInterface::class)->getMock();
93 $pageMetrics = $this->getMockBuilder(PageMetrics::class)->disableOriginalConstructor()->getMock();
94 $pageMetrics->expects($this->once())->method(
'contentPageId');
95 $pageMetrics->expects($this->once())->method(
'pageId');
96 $pageMetrics->expects($this->once())->method(
'language');
98 $repo =
new PageMetricsRepositoryImp($database);
99 $repo->delete($pageMetrics);
104 $getPageMetrics =
new GetPageMetricsCommand(1337,
'de');
105 $this->assertSame(
'de', $getPageMetrics->getLanguage());
106 $this->assertSame(1337, $getPageMetrics->getContentPageId());
108 $storePageMetrics =
new StorePageMetricsCommand(1337,
'de');
109 $this->assertSame(
'de', $storePageMetrics->getLanguage());
110 $this->assertSame(1337, $storePageMetrics->getContentPageId());
115 $page = $this->getMockBuilder(ilContentPagePage::class)->disableOriginalConstructor()->getMock();
117 $pageUpdated =
new PageUpdatedEvent($page);
118 $this->assertSame($page, $pageUpdated->page());
123 $readingTimeInMinutes = 4711;
126 $contentPageId = 1337;
128 $readingTime =
new PageReadingTime($readingTimeInMinutes);
130 $pageMetrics = $this->getMockBuilder(PageMetrics::class)->disableOriginalConstructor()->getMock();
131 $pageMetrics->method(
'contentPageId')->willReturn($contentPageId);
132 $pageMetrics->method(
'pageId')->willReturn($pageId);
133 $pageMetrics->method(
'language')->willReturn($language);
134 $pageMetrics->method(
'readingTime')->willReturn($readingTime);
136 $repo = $this->getMockBuilder(PageMetricsRepository::class)->getMock();
137 $repo->expects($this->once())->method(
'findBy')->with($contentPageId, $pageId, $language)->willReturn($pageMetrics);
143 $this->getMockBuilder(\ilLanguage::class)->disableOriginalConstructor()->getMock(),
147 $receivedPageMetrics =
$service->get(
new GetPageMetricsCommand($contentPageId, $language));
148 $this->assertSame($pageMetrics, $receivedPageMetrics);
testCommandsWorkAsExpected()
testPropertiesAreAccessedWhenDeletingPageMetrics()
Interface Observer Contains several chained tasks and infos about them.
testPageMetricsCanBeRetrievedFromService()
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
testPropertiesAreAccessedWhenStoringPageMetrics()
testPageMetricsCouldBeRetrievedFromRepository()
testEventsWorkAsExpected()
testRepositoryThrowsExceptionWhenPageMetricsShouldBeRetrievedButNoPageMetricsExist()