Commits

Greg Aker committed c5412ca

Moving tests/codeigniter/helpers/Array_helper_test.php to be lower cased.

Adding html_helper_test.php as well.

  • Participants
  • Parent commits 4129c32
  • Branches unit_tests

Comments (0)

Files changed (5)

File tests/Bootstrap.php

 require_once $dir.'/lib/common.php';
 require_once $dir.'/lib/ci_testcase.php';
 
+
+// Omit files in the PEAR & PHP Paths from ending up in the coverage report
+PHP_CodeCoverage_Filter::getInstance()->addDirectoryToBlacklist(PEAR_INSTALL_DIR);	
+PHP_CodeCoverage_Filter::getInstance()->addDirectoryToBlacklist(PHP_LIBDIR);	
+
+// Omit Tests from the coverage reports.
+// PHP_CodeCoverage_Filter::getInstance()
+
 unset($dir);

File tests/codeigniter/helpers/Array_helper_test.php

-<?php
-
-// OLD TEST FORMAT: DO NOT COPY
-
-require_once(BASEPATH.'helpers/array_helper.php');
-
-class Array_helper_test extends PHPUnit_Framework_TestCase
-{
-	public function setUp()
-	{
-		$this->my_array = array(
-			'foo'		=> 'bar',
-			'sally'		=> 'jim',
-			'maggie'	=> 'bessie',
-			'herb'		=> 'cook'
-		);
-	}
-	
-	// ------------------------------------------------------------------------
-	
-	public function testElementWithExistingItem()
-	{	
-		$this->assertEquals(FALSE, element('testing', $this->my_array));
-		
-		$this->assertEquals('not set', element('testing', $this->my_array, 'not set'));
-		
-		$this->assertEquals('bar', element('foo', $this->my_array));
-	}
-	
-	// ------------------------------------------------------------------------	
-
-	public function testRandomElement()
-	{
-		// Send a string, not an array to random_element
-		$this->assertEquals('my string', random_element('my string'));
-		
-		// Test sending an array
-		$this->assertEquals(TRUE, in_array(random_element($this->my_array), $this->my_array));
-	}
-
-	// ------------------------------------------------------------------------	
-	
-	public function testElements()
-	{
-		$this->assertEquals(TRUE, is_array(elements('test', $this->my_array)));
-		$this->assertEquals(TRUE, is_array(elements('foo', $this->my_array)));
-	}
-
-}

File tests/codeigniter/helpers/array_helper_test.php

+<?php
+
+// OLD TEST FORMAT: DO NOT COPY
+
+require_once(BASEPATH.'helpers/array_helper.php');
+
+class Array_helper_test extends PHPUnit_Framework_TestCase
+{
+	public function setUp()
+	{
+		$this->my_array = array(
+			'foo'		=> 'bar',
+			'sally'		=> 'jim',
+			'maggie'	=> 'bessie',
+			'herb'		=> 'cook'
+		);
+	}
+	
+	// ------------------------------------------------------------------------
+	
+	public function testElementWithExistingItem()
+	{	
+		$this->assertEquals(FALSE, element('testing', $this->my_array));
+		
+		$this->assertEquals('not set', element('testing', $this->my_array, 'not set'));
+		
+		$this->assertEquals('bar', element('foo', $this->my_array));
+	}
+	
+	// ------------------------------------------------------------------------	
+
+	public function testRandomElement()
+	{
+		// Send a string, not an array to random_element
+		$this->assertEquals('my string', random_element('my string'));
+		
+		// Test sending an array
+		$this->assertEquals(TRUE, in_array(random_element($this->my_array), $this->my_array));
+	}
+
+	// ------------------------------------------------------------------------	
+	
+	public function testElements()
+	{
+		$this->assertEquals(TRUE, is_array(elements('test', $this->my_array)));
+		$this->assertEquals(TRUE, is_array(elements('foo', $this->my_array)));
+	}
+
+}

File tests/codeigniter/helpers/html_helper_test.php

+<?php
+
+require_once(BASEPATH.'helpers/html_helper.php');
+
+class Html_helper_test extends PHPUnit_Framework_TestCase
+{
+	public function testHeading()
+	{
+		$this->assertEquals('<h1>foobar</h1>', heading('foobar'));
+	}
+
+	// ------------------------------------------------------------------------
+	
+	public function testUl()
+	{
+		$expect = <<<EOH
+<ul>
+  <li>foo</li>
+  <li>bar</li>
+</ul>
+
+EOH;
+
+		$expect = ltrim($expect);
+
+		$list = array('foo', 'bar');
+		
+		$this->assertEquals($expect, ul($list));
+
+
+		$expect = <<<EOH
+<ul class="test">
+  <li>foo</li>
+  <li>bar</li>
+</ul>
+
+EOH;
+
+		$expect = ltrim($expect);
+
+		$list = array('foo', 'bar');
+
+		$this->assertEquals($expect, ul($list, ' class="test"'));
+
+		$this->assertEquals($expect, ul($list, array('class' => 'test')));
+	}
+	
+	// ------------------------------------------------------------------------
+
+	public function testNBS()
+	{
+		$this->assertEquals('&nbsp;&nbsp;&nbsp;', nbs(3));
+	}
+
+	// ------------------------------------------------------------------------
+	
+	public function testMeta()
+	{
+		$this->assertEquals("<meta name=\"test\" content=\"foo\" />\n", meta('test', 'foo'));
+		
+		$expect = "<meta name=\"foo\" content=\"\" />\n";
+		
+		$this->assertEquals($expect, meta(array('name' => 'foo')));
+		
+	}
+	
+}

File tests/phpunit.xml

 <?xml version="1.0" encoding="UTF-8"?>
 
 <phpunit 
-	bootstrap="Bootstrap.php"
+	bootstrap="./Bootstrap.php"
 	colors="true">
 	<testsuites>
 		<testsuite name="CodeIgniter Core Test Suite">
 			<file>codeigniter/Setup_test.php</file>
 			<directory suffix="test.php">codeigniter/core</directory>
-			
+			<directory suffix="test.php">codeigniter/helpers</directory>
 			<!-- We'll worry about these later ...
 			<directory suffix="test.php">codeigniter/libraries</directory>
 			<directory suffix="test.php">codeigniter/helpers</directory>
 			-->
+			
 		</testsuite>
 	</testsuites>
 </phpunit>