From 3d27acfebaab966297e0da57b94560a42ffe9f46 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20=C4=8Ciha=C5=99?= Date: Wed, 18 Jul 2012 15:48:00 +0200 Subject: [PATCH 1/2] Various coding style improvements --- test/classes/PMA_Error_test.php | 36 +++++++++++++++++++++++---------- 1 file changed, 25 insertions(+), 11 deletions(-) diff --git a/test/classes/PMA_Error_test.php b/test/classes/PMA_Error_test.php index 65abd7033f..37bb64e722 100644 --- a/test/classes/PMA_Error_test.php +++ b/test/classes/PMA_Error_test.php @@ -29,7 +29,10 @@ class PMA_Error_test extends PHPUnit_Framework_TestCase */ protected function setUp() { - $this->object = $this->getMockForAbstractClass('PMA_Error', array('2', 'Compile Error', 'error.txt', 15)); + $this->object = $this->getMockForAbstractClass( + 'PMA_Error', + array('2', 'Compile Error', 'error.txt', 15) + ); } /** @@ -47,7 +50,8 @@ class PMA_Error_test extends PHPUnit_Framework_TestCase /** * Test for setBacktrace */ - public function testSetBacktrace(){ + public function testSetBacktrace() + { $this->object->setBacktrace(array('bt1','bt2')); $this->assertEquals(array('bt1','bt2'), $this->object->getBacktrace()); } @@ -55,7 +59,8 @@ class PMA_Error_test extends PHPUnit_Framework_TestCase /** * Test for setLine */ - public function testSetLine(){ + public function testSetLine() + { $this->object->setLine(15); $this->assertEquals(15, $this->object->getLine()); } @@ -63,7 +68,8 @@ class PMA_Error_test extends PHPUnit_Framework_TestCase /** * Test for setFile */ - public function testSetFile(){ + public function testSetFile() + { $this->object->setFile('./pma.txt'); $this->assertStringStartsWith('./../../', $this->object->getFile()); } @@ -71,35 +77,43 @@ class PMA_Error_test extends PHPUnit_Framework_TestCase /** * Test for getHash */ - public function testGetHash(){ - $this->assertEquals(1, preg_match('/^([a-z0-9]*)$/', $this->object->getHash())); + public function testGetHash() + { + $this->assertEquals( + 1, + preg_match('/^([a-z0-9]*)$/', $this->object->getHash()) + ); } /** * Test for getBacktraceDisplay */ - public function testGetBacktraceDisplay(){ - $this->assertTrue((strpos($this->object->getBacktraceDisplay(),'/usr/share/php/PHPUnit/Framework/TestCase.php#751: PHPUnit_Framework_TestResult->run(object)
') !== false)); + public function testGetBacktraceDisplay() + { + $this->assertTrue((strpos($this->object->getBacktraceDisplay(), '/usr/share/php/PHPUnit/Framework/TestCase.php#751: PHPUnit_Framework_TestResult->run(object)
') !== false)); } /** * Test for getDisplay */ - public function testGetDisplay(){ + public function testGetDisplay() + { $this->assertTrue((strpos($this->object->getDisplay(),'
Warning') !== false)); } /** * Test for getHtmlTitle */ - public function testGetHtmlTitle(){ + public function testGetHtmlTitle() + { $this->assertEquals('Warning: Compile Error', $this->object->getHtmlTitle()); } /** * Test for getTitle */ - public function testGetTitle(){ + public function testGetTitle() + { $this->assertEquals('Warning: Compile Error', $this->object->getTitle()); } } From 88728c9ab785c3648ad7b994ae287595d39c6640 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20=C4=8Ciha=C5=99?= Date: Wed, 18 Jul 2012 15:49:59 +0200 Subject: [PATCH 2/2] Use assertContains instead of unreadabale assertTrue(strpos() !== false) --- test/classes/PMA_Error_test.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/test/classes/PMA_Error_test.php b/test/classes/PMA_Error_test.php index 37bb64e722..9e4ca23dc9 100644 --- a/test/classes/PMA_Error_test.php +++ b/test/classes/PMA_Error_test.php @@ -90,7 +90,10 @@ class PMA_Error_test extends PHPUnit_Framework_TestCase */ public function testGetBacktraceDisplay() { - $this->assertTrue((strpos($this->object->getBacktraceDisplay(), '/usr/share/php/PHPUnit/Framework/TestCase.php#751: PHPUnit_Framework_TestResult->run(object)
') !== false)); + $this->assertContains( + 'PHPUnit/Framework/TestCase.php#751: PHPUnit_Framework_TestResult->run(object)
', + $this->object->getBacktraceDisplay() + ); } /** @@ -98,7 +101,10 @@ class PMA_Error_test extends PHPUnit_Framework_TestCase */ public function testGetDisplay() { - $this->assertTrue((strpos($this->object->getDisplay(),'
Warning') !== false)); + $this->assertContains( + '
Warning', + $this->object->getDisplay() + ); } /**