ILIAS  trunk Revision v11.0_alpha-1702-gfd3ecb7f852
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
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 ()
 

Additional Inherited Members

- Protected Member Functions inherited from ilMailBaseTestCase
 brutallyTrimHTML (string $html)
 
 setUp ()
 
 tearDown ()
 
 setGlobalVariable (string $name, $value)
 

Detailed Description

Member Function Documentation

◆ testEntityCanBeDeleted()

ilMailTemplateRepositoryTest::testEntityCanBeDeleted ( ilMailTemplate  $template)

testEntityCanBeModified

Exceptions
ReflectionException

Definition at line 77 of file ilMailTemplateRepositoryTest.php.

References ilMailTemplate\getTplId().

77  : void
78  {
79  $db = $this->getMockBuilder(ilDBInterface::class)->getMock();
80 
81  $repository = new ilMailTemplateRepository($db);
82 
83  $db->expects($this->once())->method('manipulate');
84 
85  $repository->deleteByIds([$template->getTplId()]);
86  }
+ Here is the call graph for this function:

◆ testEntityCanBeModified()

ilMailTemplateRepositoryTest::testEntityCanBeModified ( ilMailTemplate  $template)

testEntityCanBeSaved

Exceptions
ReflectionException

Definition at line 60 of file ilMailTemplateRepositoryTest.php.

61  {
62  $db = $this->getMockBuilder(ilDBInterface::class)->getMock();
63 
64  $repository = new ilMailTemplateRepository($db);
65 
66  $db->expects($this->once())->method('update');
67 
68  $repository->store($template);
69 
70  return $template;
71  }
Class ilMailTemplate.

◆ testEntityCanBeSaved()

ilMailTemplateRepositoryTest::testEntityCanBeSaved ( )
Exceptions
ReflectionException

Definition at line 30 of file ilMailTemplateRepositoryTest.php.

31  {
32  $db = $this->getMockBuilder(ilDBInterface::class)->getMock();
33 
34  $repository = new ilMailTemplateRepository($db);
35 
36  $templateId = 666;
37 
38  $template = new ilMailTemplate();
39  $template->setTitle('phpunit');
40  $template->setSubject('FooBar');
41  $template->setMessage('FooBar');
42  $template->setLang('de');
43  $template->setContext('4711');
44  $template->setAsDefault(true);
45 
46  $db->expects($this->once())->method('nextId')->willReturn($templateId);
47  $db->expects($this->once())->method('insert');
48 
49  $repository->store($template);
50 
51  $this->assertSame($templateId, $template->getTplId());
52 
53  return $template;
54  }
Class ilMailTemplate.

◆ testExceptionIsRaisedIfNoTemplateCanBeFoundById()

ilMailTemplateRepositoryTest::testExceptionIsRaisedIfNoTemplateCanBeFoundById ( )
Exceptions
ReflectionException

Definition at line 114 of file ilMailTemplateRepositoryTest.php.

114  : void
115  {
116  $this->expectException(OutOfBoundsException::class);
117 
118  $db = $this->getMockBuilder(ilDBInterface::class)->getMock();
119  $statement = $this->getMockBuilder(ilDBStatement::class)->getMock();
120 
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');
124 
125  $repository = new ilMailTemplateRepository($db);
126  $repository->findById(4711);
127  }

◆ testTemplateCanBeFoundById()

ilMailTemplateRepositoryTest::testTemplateCanBeFoundById ( )
Exceptions
ReflectionException

Definition at line 91 of file ilMailTemplateRepositoryTest.php.

91  : void
92  {
93  $db = $this->getMockBuilder(ilDBInterface::class)->getMock();
94  $statement = $this->getMockBuilder(ilDBStatement::class)->getMock();
95 
96  $templateId = 666;
97 
98  $emptyTemplate = new ilMailTemplate();
99  $emptyTemplate->setTplId($templateId);
100 
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());
104 
105  $repository = new ilMailTemplateRepository($db);
106  $template = $repository->findById(4711);
107 
108  $this->assertSame($templateId, $template->getTplId());
109  }
Class ilMailTemplate.

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