Skip to content
This repository has been archived by the owner on May 8, 2021. It is now read-only.

Commit

Permalink
Adding unit tests for opt:for.
Browse files Browse the repository at this point in the history
  • Loading branch information
zyxist committed Oct 9, 2010
1 parent 358a65e commit e839451
Show file tree
Hide file tree
Showing 6 changed files with 85 additions and 32 deletions.
4 changes: 2 additions & 2 deletions tests/Package/Instruction/AllTests.php
Expand Up @@ -16,7 +16,7 @@
require_once('ContentTest.php');
require_once('DtdTest.php');
require_once('ExtendTest.php');
//require_once('ForTest.php');
require_once('ForTest.php');
//require_once('ForeachTest.php');
//require_once('GridTest.php');
require_once('IfTest.php');
Expand Down Expand Up @@ -58,7 +58,7 @@ public static function suite()
$suite->addTestSuite('Package_Instruction_ContentTest');
$suite->addTestSuite('Package_Instruction_DtdTest');
$suite->addTestSuite('Package_Instruction_ExtendTest');
//$suite->addTestSuite('Package_Instruction_ForTest');
$suite->addTestSuite('Package_Instruction_ForTest');
//$suite->addTestSuite('Package_Instruction_ForeachTest');
//$suite->addTestSuite('Package_Instruction_GridTest');
$suite->addTestSuite('Package_Instruction_IfTest');
Expand Down
56 changes: 56 additions & 0 deletions tests/Package/Instruction/ForTest.php
@@ -0,0 +1,56 @@
<?php
/**
* The tests for opt:load instruction.
*
* @author Tomasz "Zyx" Jędrzejewski
* @copyright Copyright (c) 2009 Invenzzia Group
* @license http://www.invenzzia.org/license/new-bsd New BSD License
*/

require_once('./Extra/TestFS.php');
require_once('./Extra/TestFSBase.php');

/**
* @covers Opt_Compiler_Class
* @covers Opt_Compiler_Format
* @covers Opt_Compiler_Processor
* @covers Opt_Instruction_Root
* @covers Opt_Instruction_Extend
* @runTestsInSeparateProcesses
*/
class Package_Instruction_ForTest extends Extra_TestFSBase
{

/**
* Configuration method.
* @param Opt_Class $tpl
*/
public function configure(Opt_Class $tpl)
{
$tpl->parser = 'Opt_Parser_Xml';
$tpl->register(Opt_Class::OPT_COMPONENT, 'opt:myComponent', 'Extra_Mock_Component');
$tpl->register(Opt_Class::OPT_BLOCK, 'opt:myBlock', 'Extra_Mock_Block');
} // end configure();

/**
* Provides the list of test cases.
* @return array
*/
public static function dataProvider()
{
return array(0 =>
array('For/for_basic.txt'),
array('For/for_separator_attr.txt'),
array('For/for_separator_tag.txt'),
);
} // end dataProvider();

/**
* @dataProvider dataProvider
* @runInSeparateProcess
*/
public function testInstructions($testCase)
{
return $this->_checkTest(dirname(__FILE__).'/Tests/'.$testCase);
} // end testInstructions();
} // end Package_Instruction_ForTest;
25 changes: 0 additions & 25 deletions tests/Package/Instruction/Tests/For/for_2.txt

This file was deleted.

Expand Up @@ -2,8 +2,7 @@ Test checks the basic iteration features.

>>>>templates/test.tpl
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!-- Print numbers from 0 to 9 -->
<opt:root>
<opt:root xmlns:opt="http://xml.invenzzia.org/opt">
<opt:for begin="@i is 0" while="@i lt 10" iterate="@i++">
{@i}::
</opt:for>
Expand Down
24 changes: 24 additions & 0 deletions tests/Package/Instruction/Tests/For/for_separator_attr.txt
@@ -0,0 +1,24 @@
Test checks the cooperation of opt:for and separators.

>>>>templates/test.tpl
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<opt:root xmlns:opt="http://xml.invenzzia.org/opt">
<opt:for begin="@i is 0" while="@i lt 10" iterate="@i++" separator="str:\::">
{@i}
</opt:for>
</opt:root>

>>>>expected.txt
OUTPUT

>>>>result.txt
0::
1::
2::
3::
4::
5::
6::
7::
8::
9
@@ -1,9 +1,8 @@
Test checks the basic iteration features.
Test checks the cooperation of opt:for and separators.

>>>>templates/test.tpl
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!-- Print numbers from 0 to 9 with attributed separator -->
<opt:root>
<opt:root xmlns:opt="http://xml.invenzzia.org/opt">
<opt:for begin="@i is 0" while="@i lt 10" iterate="@i++">
<opt:separator>::</opt:separator>
{@i}
Expand Down

0 comments on commit e839451

Please sign in to comment.