PHP Classes

File: tests/errorTest.php

Recommend this page to a friend!
  Classes of Cesar D. Rodas   Haanga   tests/errorTest.php   Download  
File: tests/errorTest.php
Role: Unit test script
Content type: text/plain
Description: Test common errors
Class: Haanga
Template engine to process Django style templates
Author: By
Last change: Test Haanga with PHP7.2
Date: 4 years ago
Size: 792 bytes
 

Contents

Class file image Download
<?php

use PHPUnit\Framework\TestCase;

/**
 * @runTestsInSeparateProcess
 */
class errorTest extends TestCase
{
   
/**
     * @dataProvider tplProvider
     *
     */
   
public function testInvalidTemplates($tpl)
    {
       
Haanga_Compiler::setOption('allow_exec', FALSE);
        try {
           
Haanga::Load($tpl);
           
$this->assertTrue(FALSE);
        } Catch (
Haanga_Compiler_Exception $e) {
           
$i = preg_match("/in.*:[0-9]+/", $e->getMessage());
           
$this->assertEquals(1, $i);
        }
    }

    public static function
tplProvider()
    {
       
$datas = array();
        foreach (
glob(__DIR__ . "/err_templates/*.tpl") as $err_file) {
           
$datas[] = array(substr($err_file, strlen(__DIR__)));
        }

        return
$datas;
    }

}