1 <?php declare(strict_types=1);
17 $db = $this->getMockbuilder(ilDBInterface::class)->getMock();
24 $template->setTitle(
'phpunit');
25 $template->setSubject(
'FooBar');
26 $template->setMessage(
'FooBar');
27 $template->setLang(
'de');
28 $template->setContext(
'4711');
29 $template->setAsDefault(
true);
31 $db->expects($this->once())->method(
'nextId')->willReturn($templateId);
32 $db->expects($this->once())->method(
'insert');
34 $repository->store($template);
36 $this->assertEquals($templateId, $template->getTplId());
49 $db = $this->getMockbuilder(ilDBInterface::class)->getMock();
53 $db->expects($this->once())->method(
'update');
55 $repository->store($template);
67 $db = $this->getMockbuilder(ilDBInterface::class)->getMock();
71 $db->expects($this->once())->method(
'manipulate');
73 $repository->deleteByIds([$template->
getTplId()]);
81 $db = $this->getMockbuilder(ilDBInterface::class)->getMock();
82 $statement = $this->getMockbuilder(ilDBStatement::class)->getMock();
87 $emptyTemplate->setTplId($templateId);
89 $db->expects($this->once())->method(
'queryF')->willReturn($statement);
90 $db->expects($this->once())->method(
'numRows')->willReturn(1);
91 $db->expects($this->once())->method(
'fetchAssoc')->willReturn($emptyTemplate->toArray());
94 $template = $repository->findById(4711);
96 $this->assertEquals($templateId, $template->getTplId());
104 $this->expectException(OutOfBoundsException::class);
106 $db = $this->getMockbuilder(ilDBInterface::class)->getMock();
107 $statement = $this->getMockbuilder(ilDBStatement::class)->getMock();
109 $db->expects($this->once())->method(
'queryF')->willReturn($statement);
110 $db->expects($this->once())->method(
'numRows')->willReturn(0);
111 $db->expects($this->never())->method(
'fetchAssoc');
114 $repository->findById(4711);
testEntityCanBeDeleted(ilMailTemplate $template)
testEntityCanBeModified
testExceptionIsRaisedIfNoTemplateCanBeFoundById()
Class ilMailTemplateRepository.
testTemplateCanBeFoundById()
testEntityCanBeModified(ilMailTemplate $template)
testEntityCanBeSaved
Class ilMailTemplateRepository.