Permalink
Browse files

Parser test.

  • Loading branch information...
1 parent b4d93db commit a7f9b251b03f7fb17251951d3024cb11fc1f881f @gaker gaker committed Apr 21, 2011
Showing with 17 additions and 26 deletions.
  1. +16 −26 tests/codeigniter/libraries/Parser_test.php
  2. +1 −0 tests/phpunit.xml
@@ -2,24 +2,19 @@
// OLD TEST FORMAT: DO NOT COPY
-class Parser_test extends PHPUnit_Framework_TestCase
-{
- static $cls;
- protected $parser;
-
- public static function setUpBeforeClass()
- {
- $CI = get_instance();
- $CI->load->library('parser');
- self::$cls = get_class($CI->parser);
- }
+require BASEPATH.'libraries/Parser.php';
- // --------------------------------------------------------------------
+class Parser_test extends CI_TestCase
+{
public function setUp()
{
- $cls = self::$cls;
- $this->parser = new $cls;
+ $obj = new StdClass;
+ $obj->parser = new CI_Parser();
+
+ $this->ci_instance($obj);
+
+ $this->parser = $obj->parser;
}
// --------------------------------------------------------------------
@@ -61,23 +56,23 @@ public function testParseSimpleString()
}
// --------------------------------------------------------------------
-
+
public function testParse()
{
$this->_parse_no_template();
$this->_parse_var_pair();
$this->_mismatched_var_pair();
}
-
+
// --------------------------------------------------------------------
-
+
private function _parse_no_template()
{
$this->assertFalse($this->parser->parse_string('', '', TRUE));
}
-
+
// --------------------------------------------------------------------
-
+
private function _parse_var_pair()
{
$data = array(
@@ -95,9 +90,9 @@ private function _parse_var_pair()
$this->assertEquals($result, $this->parser->parse_string($template, $data, TRUE));
}
-
+
// --------------------------------------------------------------------
-
+
private function _mismatched_var_pair()
{
$data = array(
@@ -117,9 +112,4 @@ private function _mismatched_var_pair()
}
// --------------------------------------------------------------------
-
- // --------------------------------------------------------------------
-
- // --------------------------------------------------------------------
-
}
View
@@ -8,6 +8,7 @@
<file>codeigniter/Setup_test.php</file>
<directory suffix="test.php">codeigniter/core</directory>
<directory suffix="test.php">codeigniter/helpers</directory>
+ <directory suffix="test.php">codeigniter/libraries</directory>
<!-- We'll worry about these later ...
<directory suffix="test.php">codeigniter/libraries</directory>
<directory suffix="test.php">codeigniter/helpers</directory>

0 comments on commit a7f9b25

Please sign in to comment.