Exemplo n.º 1
0
 /**
  * Test render method.
  */
 public function testRender()
 {
     $templateDir = $this->makeTempDir('templates');
     $filename = 'test-template.php';
     $template = $templateDir . DIRECTORY_SEPARATOR . $filename;
     $this->fs->touch($template);
     file_put_contents($template, '123**<?php echo $this->someParameter ?>');
     $template = new Template($templateDir);
     $content = $template->render($filename, array('someParameter' => 321));
     $this->assertEquals('123**321', $content, sprintf('Failed to render template, expected %s found %s', '123**321', $content));
 }
Exemplo n.º 2
0
 /**
  * Generates some configurations files for testing purposes.
  *
  * @param string $file
  * @param int    $countOfBuilders
  */
 protected function generateRepoConfigFile($file, $countOfBuilders)
 {
     file_put_contents($file, $this->configTemplates->render('config2.php', array('count' => $countOfBuilders)));
 }
Exemplo n.º 3
0
 /**
  * @param Event                 $event
  * @param string                $recipient
  * @param string                $from
  * @param array|CommandResult[] $resultCommands
  */
 private function sendEmail(Event $event, $recipient, $from, array $resultCommands)
 {
     $headers = array('MIME-Version: 1.0', 'Content-type: text/html; charset=utf-8', 'From: ' . $from);
     $subject = $event->getRepositoryName() . '(' . $event->getBranchName() . ')';
     $template = new Template(__DIR__ . '/templates/', $this->logger);
     $message = $template->render('mail.php', array('subject' => $subject, 'event' => $event, 'resultCommands' => $resultCommands));
     $this->logger->info('Send email to ' . $recipient . ' subject ' . $subject);
     $this->logger->debug('Text of email: ' . $message);
     if (!mail($recipient, $subject, $message, implode($headers, "\r\n"))) {
         $this->logger->error('Cannot send email to ' . $recipient);
     }
 }