19declare(strict_types=1);
27 $repo = $this->getMockBuilder(ilMailTemplateRepository::class)->disableOriginalConstructor()->getMock();
30 $template->setTplId(1);
31 $template->setAsDefault(
false);
32 $template->setContext(
'phpunit');
34 $other_template = clone $template;
35 $other_template->setTplId(2);
36 $other_template->setAsDefault(
false);
38 $yet_another_template = clone $template;
39 $yet_another_template->setTplId(3);
40 $yet_another_template->setAsDefault(
true);
45 $yet_another_template,
48 $repo->expects($this->once())->method(
'findByContextId')->with($template->getContext())->willReturn($all);
49 $repo->expects($this->exactly(count($all)))->method(
'store');
50 $template_engine_factory = $this->getMockBuilder(TemplateEngineFactoryInterface::class)->getMock();
53 $service->setAsContextDefault($template);
55 $this->assertTrue($template->isDefault());
56 $this->assertFalse($other_template->isDefault());
57 $this->assertFalse($yet_another_template->isDefault());
62 $repo = $this->getMockBuilder(ilMailTemplateRepository::class)->disableOriginalConstructor()->getMock();
65 $template->setTplId(1);
66 $template->setAsDefault(
true);
67 $template->setContext(
'phpunit');
69 $repo->expects($this->once())->method(
'store')->with($template);
70 $template_engine_factory = $this->getMockBuilder(TemplateEngineFactoryInterface::class)->getMock();
73 $service->unsetAsContextDefault($template);
75 $this->assertFalse($template->isDefault());
testDefaultTemplateCanBeSetByContext()
testDefaultTemplateForContextCanBeUnset()
Factory interface for creating template engine instances.