19 declare(strict_types=1);
27 $db = $this->getMockBuilder(ilDBInterface::class)->getMock();
34 $template->setTitle(
'phpunit');
35 $template->setSubject(
'FooBar');
36 $template->setMessage(
'FooBar');
37 $template->setLang(
'de');
38 $template->setContext(
'4711');
39 $template->setAsDefault(
true);
41 $db->expects($this->once())->method(
'nextId')->willReturn($template_id);
42 $db->expects($this->once())->method(
'insert');
44 $repository->store($template);
46 $this->assertSame($template_id, $template->getTplId());
51 #[Depends('testEntityCanBeSaved')] 54 $db = $this->getMockBuilder(ilDBInterface::class)->getMock();
58 $db->expects($this->once())->method(
'update');
60 $repository->store($template);
65 #[Depends('testEntityCanBeModified')] 68 $db = $this->getMockBuilder(ilDBInterface::class)->getMock();
72 $db->expects($this->once())->method(
'manipulate');
74 $repository->deleteByIds([$template->
getTplId()]);
79 $db = $this->getMockBuilder(ilDBInterface::class)->getMock();
80 $statement = $this->getMockBuilder(ilDBStatement::class)->getMock();
85 $empty_template->setTplId($template_id);
87 $db->expects($this->once())->method(
'queryF')->willReturn($statement);
88 $db->expects($this->once())->method(
'numRows')->willReturn(1);
89 $db->expects($this->once())->method(
'fetchAssoc')->willReturn($empty_template->toArray());
92 $template = $repository->findById(4711);
94 $this->assertSame($template_id, $template->getTplId());
99 $this->expectException(OutOfBoundsException::class);
101 $db = $this->getMockBuilder(ilDBInterface::class)->getMock();
102 $statement = $this->getMockBuilder(ilDBStatement::class)->getMock();
104 $db->expects($this->once())->method(
'queryF')->willReturn($statement);
105 $db->expects($this->once())->method(
'numRows')->willReturn(0);
106 $db->expects($this->never())->method(
'fetchAssoc');
109 $repository->findById(4711);
testEntityCanBeDeleted(ilMailTemplate $template)
testExceptionIsRaisedIfNoTemplateCanBeFoundById()
testTemplateCanBeFoundById()
testEntityCanBeModified(ilMailTemplate $template)