PHP Classes

File: tests/Fakerino/Test/Core/Template/TwigTemplateTest.php

Recommend this page to a friend!
  Classes of Nicola Pietroluongo  >  Fakerino  >  tests/Fakerino/Test/Core/Template/TwigTemplateTest.php  >  Download  
File: tests/Fakerino/Test/Core/Template/TwigTemplateTest.php
Role: Unit test script
Content type: text/plain
Description: Unit test script
Class: Fakerino
Generate fake names and other types of fake data
Author: By
Last change:
Date: 6 years ago
Size: 1,829 bytes
 

Contents

Class file image Download
<?php
/**
 * This file is part of the Fakerino package.
 *
 * (c) Nicola Pietroluongo <nik.longstone@gmail.com>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Fakerino\Core\Test\Template;

use
Fakerino\Core\Template\TwigTemplate;

class
TwigTemplateTest extends \PHPUnit_Framework_TestCase
{
    public function
setUp()
    {
       
$this->templateFile = __DIR__ . '/../../Fixtures/template.html';
       
$this->template = new TwigTemplate();
    }

    public function
testLoadTemplateString()
    {
       
$this->assertTrue($this->template->loadTemplate('Hello {{ nameFemale }}'));
    }

    public function
testLoadTemplateFile()
    {
       
$this->assertTrue($this->template->loadTemplate($this->templateFile));
    }

    public function
testGetVariablesFile()
    {
       
$this->template->loadTemplate($this->templateFile);
       
$templateVars = $this->template->getVariables();

       
$this->assertNotEmpty($templateVars);
    }

    public function
testGetVariablesString()
    {
       
$this->template->loadTemplate('Hello {{ nameFemale }}');
       
$templateVars = $this->template->getVariables();

       
$this->assertNotEmpty($templateVars);
    }

    public function
testRenderStringTemplate()
    {
       
$data = array('nameFemale' => 'TEST');
       
$this->template->loadTemplate('Hello {{ nameFemale }}');
       
$result = $this->template->render($data);

       
$this->assertContains($data['nameFemale'], $result);
    }

    public function
testRenderFileTemplate()
    {
       
$data = array('surname' => 'TEST');
       
$this->template->loadTemplate($this->templateFile);
       
$result = $this->template->render($data);

       
$this->assertContains($data['surname'], $result);
    }
}

For more information send a message to info at phpclasses dot org.