/** * {@inheritdoc} */ public function load($name, $type = MailTypes::TYPE_ALL) { $repo = $this->om->getRepository($this->class); $mail = $repo->findOneBy(array('name' => $name, 'enabled' => true, 'type' => MailUtil::getValidTypes($type))); if (null !== $mail) { return $mail; } throw new UnknownMailException($name, MailTypes::TYPE_ALL); }
/** * @dataProvider getTypes * * @param string $type The entry type * @param string[] $validTypes The valid types for entry */ public function testGetValidTypes($type, $validTypes) { $this->assertEquals($validTypes, MailUtil::getValidTypes($type)); }
/** * {@inheritdoc} */ public function supports(MailRenderedInterface $mailRendered) { $validTypes = MailUtil::getValidTypes($mailRendered->getTemplate()->getType()); return in_array(MailTypes::TYPE_SCREEN, $validTypes); }
public function testLoad() { $template = $this->getMockBuilder(Mail::class)->disableOriginalConstructor()->getMock(); $this->repo->expects($this->once())->method('findOneBy')->with(array('name' => 'test', 'enabled' => true, 'type' => MailUtil::getValidTypes(MailTypes::TYPE_ALL)))->will($this->returnValue($template)); $this->assertSame($template, $this->loader->load('test')); }