[Fusionforge-commits] r8606 - trunk/tests/unit/utils

Roland Mas lolando at libremir.placard.fr.eu.org
Mon Dec 21 17:32:30 CET 2009


Author: lolando
Date: 2009-12-21 17:32:30 +0100 (Mon, 21 Dec 2009)
New Revision: 8606

Modified:
   trunk/tests/unit/utils/DbUtilsTests.php
   trunk/tests/unit/utils/TextSanitizerTests.php
Log:
Swapped arguments in unit tests to the recommended [expected, actual] order

Modified: trunk/tests/unit/utils/DbUtilsTests.php
===================================================================
--- trunk/tests/unit/utils/DbUtilsTests.php	2009-12-21 16:22:30 UTC (rev 8605)
+++ trunk/tests/unit/utils/DbUtilsTests.php	2009-12-21 16:32:30 UTC (rev 8606)
@@ -1,7 +1,7 @@
 <?php
 
-require_once 'PHPUnit/Framework/TestCase.php';
-require_once dirname(__FILE__) . '/../../../gforge/common/include/database-pgsql.php';
+require_once 'PHPUnit/Framework/TestCase.php' ;
+require_once dirname(__FILE__) . '/../../../gforge/common/include/database-pgsql.php' ;
 
 /**
  * Simple tests for the utils library.
@@ -19,30 +19,30 @@
 	public function testConstructQPA()
 	{
 		$qpa = db_construct_qpa () ;
-		$this->assertEquals($qpa[0], '');
+		$this->assertEquals('', $qpa[0]) ;
 
 		$qpa = db_construct_qpa ($qpa, 'SELECT foo FROM bar') ;
-		$this->assertEquals($qpa[0], 'SELECT foo FROM bar');
-		$this->assertEquals(count($qpa[1]), 0);
-		$this->assertEquals($qpa[2], 0);
+		$this->assertEquals('SELECT foo FROM bar', $qpa[0]) ;
+		$this->assertEquals(0, count($qpa[1])) ;
+		$this->assertEquals(0, $qpa[2]) ;
 
 		$qpa = db_construct_qpa ($qpa, ' WHERE name = $1', array ('nrst')) ;
-		$this->assertEquals($qpa[0], 'SELECT foo FROM bar WHERE name = $1');
+		$this->assertEquals('SELECT foo FROM bar WHERE name = $1', $qpa[0]) ;
 
 		$qpa = db_construct_qpa ($qpa, ' AND mail = $1 AND addr LIKE $2', array ('auie at foobar',
 									'bépo')) ;
-		$this->assertEquals($qpa[0], 'SELECT foo FROM bar WHERE name = $1 AND mail = $2 AND addr LIKE $3');
+		$this->assertEquals('SELECT foo FROM bar WHERE name = $1 AND mail = $2 AND addr LIKE $3', $qpa[0]) ;
 
 		$qpa = db_construct_qpa ($qpa, ' AND quux = $1', array ('jldv')) ;
-		$this->assertEquals($qpa[0], 'SELECT foo FROM bar WHERE name = $1 AND mail = $2 AND addr LIKE $3 AND quux = $4');
-		$this->assertEquals($qpa[1], array ('nrst', 'auie at foobar', 'bépo', 'jldv')) ;
-		$this->assertEquals($qpa[2], 4) ;		
+		$this->assertEquals('SELECT foo FROM bar WHERE name = $1 AND mail = $2 AND addr LIKE $3 AND quux = $4', $qpa[0]) ;
+		$this->assertEquals(array ('nrst', 'auie at foobar', 'bépo', 'jldv'), $qpa[1]) ;
+		$this->assertEquals(4, $qpa[2]) ;
 
 		$qpa = db_construct_qpa ($qpa, ' AND long1 = $1 AND long2 = $2 AND long3 = $3 AND long4 = $4 AND long5 = $5 AND long6 = $6 AND long7 = $7 AND long8 = $8 AND long9 = $9 AND long10 = $10 AND long11 = $11 AND long12 = $12', array (1,2,3,4,5,6,7,8,9,10,11,12)) ;
-		$this->assertEquals($qpa[0], 'SELECT foo FROM bar WHERE name = $1 AND mail = $2 AND addr LIKE $3 AND quux = $4 AND long1 = $5 AND long2 = $6 AND long3 = $7 AND long4 = $8 AND long5 = $9 AND long6 = $10 AND long7 = $11 AND long8 = $12 AND long9 = $13 AND long10 = $14 AND long11 = $15 AND long12 = $16') ;
+		$this->assertEquals('SELECT foo FROM bar WHERE name = $1 AND mail = $2 AND addr LIKE $3 AND quux = $4 AND long1 = $5 AND long2 = $6 AND long3 = $7 AND long4 = $8 AND long5 = $9 AND long6 = $10 AND long7 = $11 AND long8 = $12 AND long9 = $13 AND long10 = $14 AND long11 = $15 AND long12 = $16', $qpa[0]) ;
 
-		$this->assertEquals($qpa[1], array ('nrst', 'auie at foobar', 'bépo', 'jldv', 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12)) ;
-		$this->assertEquals($qpa[2], 16) ;		
+		$this->assertEquals(array ('nrst', 'auie at foobar', 'bépo', 'jldv', 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12), $qpa[1]) ;
+		$this->assertEquals(16, $qpa[2]) ;
 
 	}
 }

Modified: trunk/tests/unit/utils/TextSanitizerTests.php
===================================================================
--- trunk/tests/unit/utils/TextSanitizerTests.php	2009-12-21 16:22:30 UTC (rev 8605)
+++ trunk/tests/unit/utils/TextSanitizerTests.php	2009-12-21 16:32:30 UTC (rev 8606)
@@ -26,8 +26,8 @@
 	 */
 	public function testPurifyOnValidHtmlCode()
 	{
-		$this->assertEquals($this->s->purify('<h1>A valid message</h1>'), '<h1>A valid message</h1>');
-		$this->assertEquals($this->s->purify('<h1>A <B>valid</B> message</h1>'), '<h1>A <b>valid</b> message</h1>');
+		$this->assertEquals('<h1>A valid message</h1>', $this->s->purify('<h1>A valid message</h1>'));
+		$this->assertEquals('<h1>A <b>valid</b> message</h1>', $this->s->purify('<h1>A <B>valid</B> message</h1>'));
 	}
 	
 	/**
@@ -35,8 +35,8 @@
 	 */
 	public function testPurifyOnInvalidHtmlCode()
 	{
-		$this->assertEquals($this->s->purify('<h1>Missing ending tag'), '<h1>Missing ending tag</h1>');
-		$this->assertEquals($this->s->purify('Invalid <toto> tag'), 'Invalid  tag');
+		$this->assertEquals('<h1>Missing ending tag</h1>', $this->s->purify('<h1>Missing ending tag'));
+		$this->assertEquals('Invalid  tag', $this->s->purify('Invalid <toto> tag'));
 	}
 	
 	/**
@@ -44,6 +44,6 @@
 	 */
 	public function testPurifyOnMaliciousHtmlCode()
 	{
-		$this->assertEquals($this->s->purify('Hacker <script>hello</script>'), 'Hacker ');
+		$this->assertEquals('Hacker ', $this->s->purify('Hacker <script>hello</script>'));
 	}
 }




More information about the Fusionforge-commits mailing list