move code up one directory
[atutor.git] / include / unit_tests / ContentOutputUtilsTest.php
1 <?php
2 /****************************************************************/
3 /* ATutor                                                       */
4 /****************************************************************/
5 /* Copyright (c) 2002-2010                                      */
6 /* Inclusive Design Institute                                   */
7 /* http://atutor.ca                                             */
8 /*                                                              */
9 /* This program is free software. You can redistribute it and/or*/
10 /* modify it under the terms of the GNU General Public License  */
11 /* as published by the Free Software Foundation.                */
12 /****************************************************************/
13 // $Id: $
14
15 /**
16  * Tests utility functions for the infusion builder.
17  */
18 require_once ('../classes/ContentOutputUtils.class.php');
19
20 class TestContentOutputUtils extends UnitTestCase
21 {
22
23     private $testString = "<p>This is some text.</p>
24     <p>[code]</p>
25     <p>alert('1');</p>
26     <p>alert('2');</p>
27     <p>[/code]</p>";
28     
29     private $expectedResult = "<p>This is some text.</p>
30     <p>[code]alert('1');alert('2');[/code]</p>";      
31      
32     /**
33      * Tests testStripPTags
34      */
35     function testStripPTags1()
36     {
37         $utils = new ContentOutputUtils();
38         $actualResult = $utils->stripPtags($this->testString);
39         $actualLength = strlen($actualResult);
40         $expectedLength = strlen($this->expectedResult);
41         $this->assertEqual($expectedLength, $actualLength);
42         $maxLength = max($expectedLength, $actualLength);
43         for ($i = 0; $i < $maxLength; $i++) {
44             $this->assertEqual($this->expectedResult[$i], $actualResult[$i], "i is ". $i." chars are ".$this->expectedResult[$i]." and ".$actualResult[$i]);
45         }
46         $this->assertEqual($this->expectedResult, $actualResult);
47     }
48 }
49 ?>