19 declare(strict_types=1);
32 $db = $this->getMockBuilder(ilDBInterface::class)->getMock();
39 $template->setTitle(
'phpunit');
40 $template->setSubject(
'FooBar');
41 $template->setMessage(
'FooBar');
42 $template->setLang(
'de');
43 $template->setContext(
'4711');
44 $template->setAsDefault(
true);
46 $db->expects($this->once())->method(
'nextId')->willReturn($templateId);
47 $db->expects($this->once())->method(
'insert');
49 $repository->store($template);
51 $this->assertSame($templateId, $template->getTplId());
62 $db = $this->getMockBuilder(ilDBInterface::class)->getMock();
66 $db->expects($this->once())->method(
'update');
68 $repository->store($template);
79 $db = $this->getMockBuilder(ilDBInterface::class)->getMock();
83 $db->expects($this->once())->method(
'manipulate');
85 $repository->deleteByIds([$template->
getTplId()]);
93 $db = $this->getMockBuilder(ilDBInterface::class)->getMock();
94 $statement = $this->getMockBuilder(ilDBStatement::class)->getMock();
99 $emptyTemplate->setTplId($templateId);
101 $db->expects($this->once())->method(
'queryF')->willReturn($statement);
102 $db->expects($this->once())->method(
'numRows')->willReturn(1);
103 $db->expects($this->once())->method(
'fetchAssoc')->willReturn($emptyTemplate->toArray());
106 $template = $repository->findById(4711);
108 $this->assertSame($templateId, $template->getTplId());
116 $this->expectException(OutOfBoundsException::class);
118 $db = $this->getMockBuilder(ilDBInterface::class)->getMock();
119 $statement = $this->getMockBuilder(ilDBStatement::class)->getMock();
121 $db->expects($this->once())->method(
'queryF')->willReturn($statement);
122 $db->expects($this->once())->method(
'numRows')->willReturn(0);
123 $db->expects($this->never())->method(
'fetchAssoc');
126 $repository->findById(4711);
testEntityCanBeDeleted(ilMailTemplate $template)
testEntityCanBeModified
testExceptionIsRaisedIfNoTemplateCanBeFoundById()
Class ilMailTemplateRepository.
testTemplateCanBeFoundById()
testEntityCanBeModified(ilMailTemplate $template)
testEntityCanBeSaved