ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
ilMailTemplateRepositoryTest Class Reference

Class ilMailTemplateRepository. More...

+ Inheritance diagram for ilMailTemplateRepositoryTest:
+ Collaboration diagram for ilMailTemplateRepositoryTest:

Public Member Functions

 testEntityCanBeSaved ()
 
 testEntityCanBeModified (\ilMailTemplate $template)
 testEntityCanBeSaved More...
 
 testEntityCanBeDeleted (\ilMailTemplate $template)
 testEntityCanBeModified More...
 
 testTemplateCanBeFoundById ()
 
 testExceptionIsRaisedIfNoTemplateCanBeFoundById ()
 

Protected Member Functions

 setUp ()
 
- Protected Member Functions inherited from ilMailBaseTest
 setUp ()
 
 setGlobalVariable ($name, $value)
 
 assertException ($exception_class)
 

Detailed Description

Class ilMailTemplateRepository.

Definition at line 7 of file ilMailTemplateRepositoryTest.php.

Member Function Documentation

◆ setUp()

ilMailTemplateRepositoryTest::setUp ( )
protected

Definition at line 12 of file ilMailTemplateRepositoryTest.php.

13  {
14  parent::setUp();
15  }

◆ testEntityCanBeDeleted()

ilMailTemplateRepositoryTest::testEntityCanBeDeleted ( \ilMailTemplate  $template)

testEntityCanBeModified

Parameters
\ilMailTemplate$template

Definition at line 68 of file ilMailTemplateRepositoryTest.php.

References ilMailTemplate\getTplId(), and Sabre\Event\once().

69  {
70  $db = $this->getMockbuilder(\ilDBInterface::class)->getMock();
71 
72  $repository = new \ilMailTemplateRepository($db);
73 
74  $db->expects($this->once())->method('manipulate');
75 
76  $repository->deleteByIds([$template->getTplId()]);
77  }
$template
once($eventName, callable $callBack, $priority=100)
Subscribe to an event exactly once.
+ Here is the call graph for this function:

◆ testEntityCanBeModified()

ilMailTemplateRepositoryTest::testEntityCanBeModified ( \ilMailTemplate  $template)

testEntityCanBeSaved

Parameters
\ilMailTemplate$template
Returns

Definition at line 51 of file ilMailTemplateRepositoryTest.php.

References $template, and Sabre\Event\once().

52  {
53  $db = $this->getMockbuilder(\ilDBInterface::class)->getMock();
54 
55  $repository = new \ilMailTemplateRepository($db);
56 
57  $db->expects($this->once())->method('update');
58 
59  $repository->store($template);
60 
61  return $template;
62  }
$template
Class ilMailTemplate.
once($eventName, callable $callBack, $priority=100)
Subscribe to an event exactly once.
+ Here is the call graph for this function:

◆ testEntityCanBeSaved()

ilMailTemplateRepositoryTest::testEntityCanBeSaved ( )
Returns

Definition at line 20 of file ilMailTemplateRepositoryTest.php.

References $template, and Sabre\Event\once().

21  {
22  $db = $this->getMockbuilder(\ilDBInterface::class)->getMock();
23 
24  $repository = new \ilMailTemplateRepository($db);
25 
26  $templateId = 666;
27 
28  $template = new \ilMailTemplate();
29  $template->setTitle('phpunit');
30  $template->setSubject('FooBar');
31  $template->setMessage('FooBar');
32  $template->setLang('de');
33  $template->setContext('4711');
34  $template->setAsDefault(true);
35 
36  $db->expects($this->once())->method('nextId')->willReturn($templateId);
37  $db->expects($this->once())->method('insert');
38 
39  $repository->store($template);
40 
41  $this->assertEquals($templateId, $template->getTplId());
42 
43  return $template;
44  }
$template
Class ilMailTemplate.
once($eventName, callable $callBack, $priority=100)
Subscribe to an event exactly once.
+ Here is the call graph for this function:

◆ testExceptionIsRaisedIfNoTemplateCanBeFoundById()

ilMailTemplateRepositoryTest::testExceptionIsRaisedIfNoTemplateCanBeFoundById ( )

Definition at line 105 of file ilMailTemplateRepositoryTest.php.

References ilMailBaseTest\assertException(), and Sabre\Event\once().

106  {
107  $this->assertException(\OutOfBoundsException::class);
108 
109  $db = $this->getMockbuilder(\ilDBInterface::class)->getMock();
110  $statement = $this->getMockbuilder(\ilDBStatement::class)->getMock();
111 
112  $db->expects($this->once())->method('queryF')->willReturn($statement);
113  $db->expects($this->once())->method('numRows')->willReturn(0);
114  $db->expects($this->never())->method('fetchAssoc');
115 
116  $repository = new \ilMailTemplateRepository($db);
117  $repository->findById(4711);
118  }
assertException($exception_class)
once($eventName, callable $callBack, $priority=100)
Subscribe to an event exactly once.
+ Here is the call graph for this function:

◆ testTemplateCanBeFoundById()

ilMailTemplateRepositoryTest::testTemplateCanBeFoundById ( )

Definition at line 82 of file ilMailTemplateRepositoryTest.php.

References $template, and Sabre\Event\once().

83  {
84  $db = $this->getMockbuilder(\ilDBInterface::class)->getMock();
85  $statement = $this->getMockbuilder(\ilDBStatement::class)->getMock();
86 
87  $templateId = 666;
88 
89  $emptyTemplate = new \ilMailTemplate();
90  $emptyTemplate->setTplId($templateId);
91 
92  $db->expects($this->once())->method('queryF')->willReturn($statement);
93  $db->expects($this->once())->method('numRows')->willReturn(1);
94  $db->expects($this->once())->method('fetchAssoc')->willReturn($emptyTemplate->toArray());
95 
96  $repository = new \ilMailTemplateRepository($db);
97  $template = $repository->findById(4711);
98 
99  $this->assertEquals($templateId, $template->getTplId());
100  }
$template
once($eventName, callable $callBack, $priority=100)
Subscribe to an event exactly once.
+ Here is the call graph for this function:

The documentation for this class was generated from the following file: