From 1c3833e9d2c72dfcbaaba8fa3b5f547a9a76e3a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20=C4=8Ciha=C5=99?= Date: Thu, 23 Aug 2012 09:54:59 +0200 Subject: [PATCH] Use RegExp based matchingi nstead of exact html --- test/libraries/PMA_operations_test.php | 87 ++++++++------------------ 1 file changed, 27 insertions(+), 60 deletions(-) diff --git a/test/libraries/PMA_operations_test.php b/test/libraries/PMA_operations_test.php index e521e4b0ba..758b5449fc 100644 --- a/test/libraries/PMA_operations_test.php +++ b/test/libraries/PMA_operations_test.php @@ -53,8 +53,8 @@ class PMA_operations_test extends PHPUnit_Framework_TestCase $_SESSION[' PMA_token '] = 'token'; $GLOBALS['cfg']['PropertiesIconic'] = true; - $this->assertEquals( - '
Database comment:
', + $this->assertRegExp( + '/.*db_operations.php(.|[\n])*Database comment.*name="comment"([\n]|.)*/m', PMA_getHtmlForDatabaseComment("pma") ); } @@ -66,9 +66,8 @@ class PMA_operations_test extends PHPUnit_Framework_TestCase $_REQUEST['db_collation'] = 'db1'; $GLOBALS['cfg']['PropertiesIconic'] = true; - $this->assertEquals( - '
-
Rename database to:
', + $this->assertRegExp( + '/.*db_operations.php(.|[\n])*db_rename([\n]|.)*Rename database to.*/m', PMA_getHtmlForRenameDatabase("pma") ); } @@ -79,8 +78,8 @@ class PMA_operations_test extends PHPUnit_Framework_TestCase public function testPMA_getHtmlForDropDatabaseLink(){ $GLOBALS['cfg']['PropertiesIconic'] = true; - $this->assertEquals( - '
Remove database
', + $this->assertRegExp( + '/.*DROP.DATABASE.*db_operations.php.*Drop the database.*/', PMA_getHtmlForDropDatabaseLink("pma") ); } @@ -92,16 +91,8 @@ class PMA_operations_test extends PHPUnit_Framework_TestCase $_REQUEST['db_collation'] = 'db1'; $GLOBALS['cfg']['PropertiesIconic'] = true; - $this->assertEquals( - '
- -
Copy database to:
-
- -
- -
-



', + $this->assertRegExp( + '/.*db_operations.php(.|[\n])*db_copy([\n]|.)*Copy database to.*/m', PMA_getHtmlForCopyDatabase("pma") ); } @@ -113,14 +104,8 @@ class PMA_operations_test extends PHPUnit_Framework_TestCase $_REQUEST['db_collation'] = 'db1'; $GLOBALS['cfg']['PropertiesIconic'] = true; - $this->assertEquals( - '
- - -
-
-
-', + $this->assertRegExp( + '/.*db_operations.php(.|[\n])*select_db_collation([\n]|.)*Collation.*/m', PMA_getHtmlForChangeDatabaseCharset("pma", "bookmark") ); } @@ -131,8 +116,8 @@ class PMA_operations_test extends PHPUnit_Framework_TestCase public function testPMA_getHtmlForExportRelationalSchemaView(){ $GLOBALS['cfg']['PropertiesIconic'] = true; - $this->assertEquals( - '
Edit or export relational schema
', + $this->assertRegExp( + '/.*schema_edit.php.*Edit or export relational schema<.*/', PMA_getHtmlForExportRelationalSchemaView("id=001&name=pma") ); } @@ -142,10 +127,8 @@ class PMA_operations_test extends PHPUnit_Framework_TestCase */ public function testPMA_getHtmlForOrderTheTable(){ - $this->assertEquals( - '
Alter table order by (singly)
', + $this->assertRegExp( + '/.*tbl_operations.php(.|[\n])*Alter table order by([\n]|.)*order_order.*/m', PMA_getHtmlForOrderTheTable(array(array('Field' => "column1"), array('Field' => "column2"))) ); } @@ -167,7 +150,7 @@ class PMA_operations_test extends PHPUnit_Framework_TestCase public function testPMA_getMaintainActionlink(){ $this->assertEquals( - '
  • postDocumentation
  • ', + '
  • post
  • ', PMA_getMaintainActionlink("post", array("name" => 'foo', "value" => 'bar'), array(), 'doclink') ); } @@ -177,9 +160,9 @@ class PMA_operations_test extends PHPUnit_Framework_TestCase */ public function testPMA_getHtmlForDeleteDataOrTable(){ - $this->assertEquals( - '
    Delete data or table
    ', - PMA_getHtmlForDeleteDataOrTable(array("truncate"), array("drop")) + $this->assertRegExp( + '/.*Delete data or table.*Empty the table.*Delete the table.*/m', + PMA_getHtmlForDeleteDataOrTable(array("truncate" => 'foo'), array("drop" => 'bar')) ); } @@ -188,9 +171,9 @@ class PMA_operations_test extends PHPUnit_Framework_TestCase */ public function testPMA_getDeleteDataOrTablelink(){ - $this->assertEquals( - PMA_getDeleteDataOrTablelink(array("param"), "TRUNCATE_TABLE", "/phpmyadmin", 001), - '
  • /phpmyadminDocumentation
  • ' + $this->assertRegExp( + '/.*TRUNCATE.TABLE.foo.*id_truncate.*Truncate table.*/m', + PMA_getDeleteDataOrTablelink(array("sql" => 'TRUNCATE TABLE foo'), "TRUNCATE_TABLE", "Truncate table", "id_truncate") ); } @@ -199,23 +182,9 @@ class PMA_operations_test extends PHPUnit_Framework_TestCase */ public function testPMA_getHtmlForPartitionMaintenance(){ - $this->assertEquals( - PMA_getHtmlForPartitionMaintenance(array("partition1", "partion2"), array("param1", "param2")), - '
    Partition maintenancePartition - - - - - - - - - - -Documentation
    Remove partitioning
    ' + $this->assertRegExp( + '/.*action="tbl_operations.php"(.|[\n])*ANALYZE([\n]|.)*REBUILD([\n]|.)*/m', + PMA_getHtmlForPartitionMaintenance(array("partition1", "partion2"), array("param1" => 'foo', "param2" => 'bar')) ); } @@ -224,11 +193,9 @@ class PMA_operations_test extends PHPUnit_Framework_TestCase */ public function testPMA_getHtmlForReferentialIntegrityCheck(){ - $this->assertEquals( - PMA_getHtmlForReferentialIntegrityCheck(array(array('foreign_table' => "foreign1", 'foreign_field' => "foreign2")), array("param1" => 'a', "param2" => 'b')), - '
    Check referential integrity:
    ' + $this->assertRegExp( + '/.*Check referential integrity.*href="sql.php(.|[\n])*/m', + PMA_getHtmlForReferentialIntegrityCheck(array(array('foreign_table' => "foreign1", 'foreign_field' => "foreign2")), array("param1" => 'a', "param2" => 'b')) ); }