/** * Tests publish - existing template. */ public function testPublishExistingTemplate() { $manager = new MandrillTemplateManager(); $manager->setHtml('<p>Read this now!</p>'); $service = $this->getMock('Mandrill_Templates', array(), array(), '', false); $service->expects($this->once())->method('getList')->will($this->returnValue(array(array('name' => 'my fav template')))); $service->expects($this->once())->method('update')->with($this->equalTo('my fav template'), $this->equalTo('*****@*****.**'), $this->equalTo('Mr C'), $this->equalTo('Amazing subject...'), $this->equalTo('<p>Read this now!</p>'), $this->equalTo(''), $this->equalTo(true)); $service->expects($this->never())->method('add'); $manager->setMandrillTemplatesService($service); $manager->publish('my_key', 'my fav template', '*****@*****.**', 'Mr C', 'Amazing subject...', true); }
$config = array_merge($config, $templateSpecificConfig); if (isset($config["additionalIncludes"])) { $config["includes"] = array_merge($config["includes"], $config["additionalIncludes"]); unset($config["additionalIncludes"]); } if (isset($config["additionalCss"])) { $config["css"] = array_merge($config["css"], $config["additionalCss"]); unset($config["additionalCss"]); } // publish status $publishStatus = $argv[3]; if ($publishStatus != 'live' && $publishStatus != 'draft') { echo 'third arg must be either live or draft'; exit; } // template name suffix $suffix = count($argv) > 4 ? $argv[4] : ''; // preparing final partials(includes) and css list $includes = array_map(function ($item) { global $config; return file_get_contents($config["includeBaseDir"] . $item); }, $config["includes"]); $css = array_map(function ($item) { global $config; return file_get_contents($config["cssBaseDir"] . $item); }, $config["css"]); $manager->generate($template, $includes, $config, $css); $manager->save('output.html'); // we are not actually required to save before publishing to mandrill $manager->publish($config['mandrillApiKey'], $config['templateName'] . $suffix, $config['fromEmail'], $config['fromName'], $config['subject'], $publishStatus == 'live');