* @license PHP License * @package WB * @subpackage unittest */ /** * Unit Test * * * * @version 0.1.0 * @package WB * @subpackage unittest */ class TestCasePatTemplateBase extends UnitTestCase { /** * worker * @var patTemplate */ protected $_tmpl; /** * error reporting level * @var int */ protected $_oldErrorReportingLevel; /** * set up error reporting level */ public function __construct() { $this->_oldErrorReportingLevel = error_reporting( E_ALL ); $this->_tmpl = WBClass::create( 'patTemplate' ); } /** * set up error reporting level */ public function setUp() { error_reporting( E_ALL ); } /** * reset error reporting level */ public function tearDown() { error_reporting( $this->_oldErrorReportingLevel ); } /** * load class and start */ public function testInit() { $this->assertTrue( class_exists( 'patTemplate', false ) ); $this->assertIsA( $this->_tmpl, 'patTemplate' ); } /** * use special template "load.tmpl" * * */ public function testLoad() { $this->_tmpl->readTemplatesFromInput( 'test/load.tmpl' ); $this->assertEqual( $this->_tmpl->getParsedTemplate( 'load01' ), 'unittest' ); $this->assertEqual( $this->_tmpl->getParsedTemplate( 'load02' ), 'unittest' ); $this->assertEqual( $this->_tmpl->getParsedTemplate( 'load03' ), 'unit{THIS_VAR_IS_NOT_SET}test' ); } public function testModifierUrlencode() { $this->_tmpl->readTemplatesFromInput( 'test/modifier/urlencode.tmpl'); $globs = array( 'title_simple' => 'A simple title', 'title_chars' => 'Some funny chars !"§$%&()=?*öäü', 'title_slash' => 'With/out slashes /.' ); $this->_tmpl->addGlobalVars($globs); $this->assertEqual($this->_tmpl->getParsedTemplate('modifier_urlencode_01'), 'A+simple+title'); $this->assertEqual($this->_tmpl->getParsedTemplate('modifier_urlencode_02'), 'Some+funny+chars+%21%22%C2%A7%24%25%26%28%29%3D%3F%2A%C3%B6%C3%A4%C3%BC'); $this->assertEqual($this->_tmpl->getParsedTemplate('modifier_urlencode_03'), 'With%2Fout+slashes+%2F.'); $this->assertEqual($this->_tmpl->getParsedTemplate('modifier_urlencode_11'), 'A+simple+title'); $this->assertEqual($this->_tmpl->getParsedTemplate('modifier_urlencode_12'), 'Some+funny+chars+%21%22%C2%A7%24%25%26%28%29%3D%3F%2A%C3%B6%C3%A4%C3%BC'); $this->assertEqual($this->_tmpl->getParsedTemplate('modifier_urlencode_13'), 'WithXout+slashes+X.'); $this->assertEqual($this->_tmpl->getParsedTemplate('modifier_urlencode_21'), 'A+simple+title'); $this->assertEqual($this->_tmpl->getParsedTemplate('modifier_urlencode_22'), 'Some+funny+chars+%21%22%C2%A7%24%25%26%28%29%3D%3F%2A%C3%B6%C3%A4%C3%BC'); $this->assertEqual($this->_tmpl->getParsedTemplate('modifier_urlencode_23'), 'With+out+slashes++.'); } }