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

Class ilMailTemplateServiceTest. More...

+ Inheritance diagram for ilMailTemplateServiceTest:
+ Collaboration diagram for ilMailTemplateServiceTest:

Public Member Functions

 testDefaultTemplateCanBeSetByContext ()
 
 testDefaultTemplateForContextCanBeUnset ()
 

Protected Member Functions

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

Detailed Description

Class ilMailTemplateServiceTest.

Definition at line 7 of file ilMailTemplateServiceTest.php.

Member Function Documentation

◆ setUp()

ilMailTemplateServiceTest::setUp ( )
protected

Definition at line 12 of file ilMailTemplateServiceTest.php.

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

◆ testDefaultTemplateCanBeSetByContext()

ilMailTemplateServiceTest::testDefaultTemplateCanBeSetByContext ( )

Definition at line 20 of file ilMailTemplateServiceTest.php.

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

21  {
22  $repo = $this->getMockbuilder(\ilMailTemplateRepository::class)->disableOriginalConstructor()->getMock();
23 
24  $template = new \ilMailTemplate();
25  $template->setTplId(1);
26  $template->setAsDefault(false);
27  $template->setContext('phpunit');
28 
29  $otherTemplate = clone $template;
30  $otherTemplate->setTplId(2);
31  $otherTemplate->setAsDefault(false);
32 
33  $yetAnotherTemplate = clone $template;
34  $yetAnotherTemplate->setTplId(3);
35  $yetAnotherTemplate->setAsDefault(true);
36 
37  $all = [
38  $template,
39  $otherTemplate,
40  $yetAnotherTemplate,
41  ];
42 
43  $repo->expects($this->once())->method('findByContextId')->with($template->getContext())->willReturn($all);
44  $repo->expects($this->exactly(count($all)))->method('store');
45  $service = new \ilMailTemplateService($repo);
46 
47  $service->setAsContextDefault($template);
48 
49  $this->assertTrue($template->isDefault());
50  $this->assertFalse($otherTemplate->isDefault());
51  $this->assertFalse($yetAnotherTemplate->isDefault());
52  }
$template
once($eventName, callable $callBack, $priority=100)
Subscribe to an event exactly once.
+ Here is the call graph for this function:

◆ testDefaultTemplateForContextCanBeUnset()

ilMailTemplateServiceTest::testDefaultTemplateForContextCanBeUnset ( )

Definition at line 57 of file ilMailTemplateServiceTest.php.

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

58  {
59  $repo = $this->getMockbuilder(\ilMailTemplateRepository::class)->disableOriginalConstructor()->getMock();
60 
61  $template = new \ilMailTemplate();
62  $template->setTplId(1);
63  $template->setAsDefault(true);
64  $template->setContext('phpunit');
65 
66  $repo->expects($this->once())->method('store')->with($template);
67  $service = new \ilMailTemplateService($repo);
68 
69  $service->unsetAsContextDefault($template);
70 
71  $this->assertFalse($template->isDefault());
72  }
$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: