From 1c69f425351a1cd03d572d605836f54c427567ce Mon Sep 17 00:00:00 2001 From: sasa Date: Wed, 20 Oct 2010 17:16:36 +0200 Subject: [PATCH 1/2] refactored zend\test for exceptions milestone --- src/PHPUnit/Constraint/Exception/ConstraintException.php | 2 +- src/PHPUnit/Db/DataSet/QueryTable.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/PHPUnit/Constraint/Exception/ConstraintException.php b/src/PHPUnit/Constraint/Exception/ConstraintException.php index 7b584c9d99..d0bbac01af 100644 --- a/src/PHPUnit/Constraint/Exception/ConstraintException.php +++ b/src/PHPUnit/Constraint/Exception/ConstraintException.php @@ -37,6 +37,6 @@ */ class ConstraintException extends \PHPUnit_Framework_ExpectationFailedException - implements \Zend\Test\PHPUnit\Contraint\Exception + implements \Zend\Test\PHPUnit\Constraint\Exception { } diff --git a/src/PHPUnit/Db/DataSet/QueryTable.php b/src/PHPUnit/Db/DataSet/QueryTable.php index dd0d85aba7..473666055c 100644 --- a/src/PHPUnit/Db/DataSet/QueryTable.php +++ b/src/PHPUnit/Db/DataSet/QueryTable.php @@ -51,7 +51,7 @@ class QueryTable extends \PHPUnit_Extensions_Database_DataSet_QueryTable public function __construct($tableName, $query, \PHPUnit_Extensions_Database_DB_IDatabaseConnection $databaseConnection) { if( !($databaseConnection instanceof \Zend\Test\PHPUnit\Db\Connection) ) { - throw new \Zend\Test\PHPUnit\Db\ExceptionInvalidArgumentException( + throw new \Zend\Test\PHPUnit\Db\Exception\InvalidArgumentException( "Zend_Test_PHPUnit_Db_DataSet_QueryTable only works with Zend_Test_PHPUnit_Db_Connection connections-" ); } From 8e65f177f9e887a281cc4e3fc12db25d440d37ef Mon Sep 17 00:00:00 2001 From: sasa Date: Wed, 20 Oct 2010 17:35:41 +0200 Subject: [PATCH 2/2] refactored Zend\Test for exceptions milestone unit tests added --- src/PHPUnit/Db/DataSet/QueryDataSet.php | 2 +- src/PHPUnit/Db/DataSet/QueryTable.php | 2 +- test/PHPUnit/ControllerTestCaseTest.php | 56 +++++++++---------- test/PHPUnit/Db/DataSet/DbRowsetTest.php | 2 +- .../PHPUnit/Db/DataSet/DbTableDataSetTest.php | 2 +- test/PHPUnit/Db/DataSet/QueryDataSetTest.php | 2 +- test/PHPUnit/Db/DataSet/QueryTableTest.php | 2 +- test/PHPUnit/Db/Operation/DeleteAllTest.php | 2 +- test/PHPUnit/Db/Operation/InsertTest.php | 2 +- test/PHPUnit/Db/Operation/TruncateTest.php | 2 +- test/PHPUnit/Db/SimpleTesterTest.php | 2 +- 11 files changed, 38 insertions(+), 38 deletions(-) diff --git a/src/PHPUnit/Db/DataSet/QueryDataSet.php b/src/PHPUnit/Db/DataSet/QueryDataSet.php index beaeb388a3..93e2522c06 100644 --- a/src/PHPUnit/Db/DataSet/QueryDataSet.php +++ b/src/PHPUnit/Db/DataSet/QueryDataSet.php @@ -51,7 +51,7 @@ public function __construct(\PHPUnit_Extensions_Database_DB_IDatabaseConnection { if( !($databaseConnection instanceof \Zend\Test\PHPUnit\Db\Connection) ) { throw new \Zend\Test\PHPUnit\Db\Exception\InvalidArgumentException( - "Zend_Test_PHPUnit_Db_DataSet_QueryDataSet only works with Zend_Test_PHPUnit_Db_Connection connections-" + "Zend\Test\PHPUnit\Db\DataSet\QueryDataSet only works with Zend\Test\PHPUnit\Db\Connection connections-" ); } $this->databaseConnection = $databaseConnection; diff --git a/src/PHPUnit/Db/DataSet/QueryTable.php b/src/PHPUnit/Db/DataSet/QueryTable.php index 473666055c..d56480716f 100644 --- a/src/PHPUnit/Db/DataSet/QueryTable.php +++ b/src/PHPUnit/Db/DataSet/QueryTable.php @@ -52,7 +52,7 @@ public function __construct($tableName, $query, \PHPUnit_Extensions_Database_DB_ { if( !($databaseConnection instanceof \Zend\Test\PHPUnit\Db\Connection) ) { throw new \Zend\Test\PHPUnit\Db\Exception\InvalidArgumentException( - "Zend_Test_PHPUnit_Db_DataSet_QueryTable only works with Zend_Test_PHPUnit_Db_Connection connections-" + "Zend\Test\PHPUnit\Db\DataSet\QueryTable only works with Zend\Test\PHPUnit\Db\Connection connections-" ); } parent::__construct($tableName, $query, $databaseConnection); diff --git a/test/PHPUnit/ControllerTestCaseTest.php b/test/PHPUnit/ControllerTestCaseTest.php index 7e1de8c788..2158e7f16e 100644 --- a/test/PHPUnit/ControllerTestCaseTest.php +++ b/test/PHPUnit/ControllerTestCaseTest.php @@ -311,52 +311,52 @@ public function testAssertQueryShouldThrowExceptionsForInValidResponseContent() try { $this->testCase->assertNotQuery('div#foo legend.bar'); $this->fail('Invalid assertions should throw exceptions'); - } catch (Constraint\Exception $e) { + } catch (Constraint\Exception\ConstraintException $e) { } try { $this->testCase->assertQuery('div#foo legend.bogus'); $this->fail('Invalid assertions should throw exceptions'); - } catch (Constraint\Exception $e) { + } catch (Constraint\Exception\ConstraintException $e) { } try { $this->testCase->assertNotQueryContentContains('legend.bat', 'La di da'); $this->fail('Invalid assertions should throw exceptions'); - } catch (Constraint\Exception $e) { + } catch (Constraint\Exception\ConstraintException $e) { } try { $this->testCase->assertQueryContentContains('legend.bat', 'La do da'); $this->fail('Invalid assertions should throw exceptions'); - } catch (Constraint\Exception $e) { + } catch (Constraint\Exception\ConstraintException $e) { } try { $this->testCase->assertNotQueryContentRegex('legend.bat', '/d[a|i]/i'); $this->fail('Invalid assertions should throw exceptions'); - } catch (Constraint\Exception $e) { + } catch (Constraint\Exception\ConstraintException $e) { } try { $this->testCase->assertQueryContentRegex('legend.bat', '/d[o|e]/i'); $this->fail('Invalid assertions should throw exceptions'); - } catch (Constraint\Exception $e) { + } catch (Constraint\Exception\ConstraintException $e) { } try { $this->testCase->assertQueryCountMin('div#foo legend.bar', 3); $this->fail('Invalid assertions should throw exceptions'); - } catch (Constraint\Exception $e) { + } catch (Constraint\Exception\ConstraintException $e) { } try { $this->testCase->assertQueryCount('div#foo legend.bar', 1); $this->fail('Invalid assertions should throw exceptions'); - } catch (Constraint\Exception $e) { + } catch (Constraint\Exception\ConstraintException $e) { } try { $this->testCase->assertQueryCountMin('div#foo legend.bar', 3); $this->fail('Invalid assertions should throw exceptions'); - } catch (Constraint\Exception $e) { + } catch (Constraint\Exception\ConstraintException $e) { } try { $this->testCase->assertQueryCountMax('div#foo legend.bar', 1); $this->fail('Invalid assertions should throw exceptions'); - } catch (Constraint\Exception $e) { + } catch (Constraint\Exception\ConstraintException $e) { } } @@ -385,52 +385,52 @@ public function testAssertXpathShouldThrowExceptionsForInValidResponseContent() try { $this->testCase->assertNotXpath("//div[@id='foo']//legend[contains(@class, 'bar')]"); $this->fail("Invalid assertions should throw exceptions; assertion against //div[@id='foo']//legend[contains(@class, 'bar')] failed"); - } catch (Constraint\Exception $e) { + } catch (Constraint\Exception\ConstraintException $e) { } try { $this->testCase->assertXpath("//div[@id='foo']//legend[contains(@class, 'bogus')]"); $this->fail("Invalid assertions should throw exceptions; assertion against //div[@id='foo']//legend[contains(@class, 'bogus')] failed"); - } catch (Constraint\Exception $e) { + } catch (Constraint\Exception\ConstraintException $e) { } try { $this->testCase->assertNotXpathContentContains("//legend[contains(@class, 'bat')]", "La di da"); $this->fail("Invalid assertions should throw exceptions; assertion against //legend[contains(@class, 'bat')] failed"); - } catch (Constraint\Exception $e) { + } catch (Constraint\Exception\ConstraintException $e) { } try { $this->testCase->assertXpathContentContains("//legend[contains(@class, 'bat')]", 'La do da'); $this->fail("Invalid assertions should throw exceptions; assertion against //legend[contains(@class, 'bat')] failed"); - } catch (Constraint\Exception $e) { + } catch (Constraint\Exception\ConstraintException $e) { } try { $this->testCase->assertNotXpathContentRegex("//legend[contains(@class, 'bat')]", '/d[a|i]/i'); $this->fail("Invalid assertions should throw exceptions; assertion against //legend[contains(@class, 'bat')] failed"); - } catch (Constraint\Exception $e) { + } catch (Constraint\Exception\ConstraintException $e) { } try { $this->testCase->assertXpathContentRegex("//legend[contains(@class, 'bat')]", '/d[o|e]/i'); $this->fail("Invalid assertions should throw exceptions; assertion against //legend[contains(@class, 'bat')] failed"); - } catch (Constraint\Exception $e) { + } catch (Constraint\Exception\ConstraintException $e) { } try { $this->testCase->assertXpathCountMin("//div[@id='foo']//legend[contains(@class, 'bar')]", 3); $this->fail("Invalid assertions should throw exceptions; assertion against //div[@id='foo']//legend[contains(@class, 'bar')] failed"); - } catch (Constraint\Exception $e) { + } catch (Constraint\Exception\ConstraintException $e) { } try { $this->testCase->assertXpathCount("//div[@id='foo']//legend[contains(@class, 'bar')]", 1); $this->fail("Invalid assertions should throw exceptions; assertion against //div[@id='foo']//legend[contains(@class, 'bar')] failed"); - } catch (Constraint\Exception $e) { + } catch (Constraint\Exception\ConstraintException $e) { } try { $this->testCase->assertXpathCountMin("//div[@id='foo']//legend[contains(@class, 'bar')]", 3); $this->fail("Invalid assertions should throw exceptions; assertion against //div[@id='foo']//legend[contains(@class, 'bar')] failed"); - } catch (Constraint\Exception $e) { + } catch (Constraint\Exception\ConstraintException $e) { } try { $this->testCase->assertXpathCountMax("//div[@id='foo']//legend[contains(@class, 'bar')]", 1); $this->fail("Invalid assertions should throw exceptions; assertion against //div[@id='foo']//legend[contains(@class, 'bar')] failed"); - } catch (Constraint\Exception $e) { + } catch (Constraint\Exception\ConstraintException $e) { } } @@ -469,49 +469,49 @@ public function testHeaderAssertionShouldThrowExceptionForInvalidComparison() try { $this->testCase->assertResponseCode(500); $this->fail(); - } catch (Constraint\Exception $e) { + } catch (Constraint\Exception\ConstraintException $e) { $this->assertContains('Failed', $e->getMessage()); } try { $this->testCase->assertNotResponseCode(200); $this->fail(); - } catch (Constraint\Exception $e) { + } catch (Constraint\Exception\ConstraintException $e) { $this->assertContains('Failed', $e->getMessage()); } try { $this->testCase->assertNotHeader('Content-Type'); $this->fail(); - } catch (Constraint\Exception $e) { + } catch (Constraint\Exception\ConstraintException $e) { $this->assertContains('Failed', $e->getMessage()); } try { $this->testCase->assertHeader('X-Bogus'); $this->fail(); - } catch (Constraint\Exception $e) { + } catch (Constraint\Exception\ConstraintException $e) { $this->assertContains('Failed', $e->getMessage()); } try { $this->testCase->assertNotHeaderContains('Content-Type', 'my-foo'); $this->fail(); - } catch (Constraint\Exception $e) { + } catch (Constraint\Exception\ConstraintException $e) { $this->assertContains('Failed', $e->getMessage()); } try { $this->testCase->assertHeaderContains('Content-Type', 'my-bar'); $this->fail(); - } catch (Constraint\Exception $e) { + } catch (Constraint\Exception\ConstraintException $e) { $this->assertContains('Failed', $e->getMessage()); } try { $this->testCase->assertNotHeaderRegex('Content-Type', '#^[a-z-]+/[a-z-]+$#i'); $this->fail(); - } catch (Constraint\Exception $e) { + } catch (Constraint\Exception\ConstraintException $e) { $this->assertContains('Failed', $e->getMessage()); } try { $this->testCase->assertHeaderRegex('Content-Type', '#^\d+#i'); $this->fail(); - } catch (Constraint\Exception $e) { + } catch (Constraint\Exception\ConstraintException $e) { $this->assertContains('Failed', $e->getMessage()); } } diff --git a/test/PHPUnit/Db/DataSet/DbRowsetTest.php b/test/PHPUnit/Db/DataSet/DbRowsetTest.php index f562be7d39..4b4cc9c6f6 100644 --- a/test/PHPUnit/Db/DataSet/DbRowsetTest.php +++ b/test/PHPUnit/Db/DataSet/DbRowsetTest.php @@ -66,7 +66,7 @@ public function testRowsetGetSpecificRow() public function testRowset_ConstructWithDisconnectedRowset_NoTableName_ThrowsException() { - $this->setExpectedException("Zend\Test\PHPUnit\Db\Exception"); + $this->setExpectedException("Zend\Test\PHPUnit\Db\Exception\InvalidArgumentException"); $rowset = $this->getMock('Zend\Db\Table\AbstractRowset', array(), array(), '', false); $rowset->expects($this->once()) diff --git a/test/PHPUnit/Db/DataSet/DbTableDataSetTest.php b/test/PHPUnit/Db/DataSet/DbTableDataSetTest.php index e282b7422e..18c5fd867d 100644 --- a/test/PHPUnit/Db/DataSet/DbTableDataSetTest.php +++ b/test/PHPUnit/Db/DataSet/DbTableDataSetTest.php @@ -68,7 +68,7 @@ public function testAddTableCreatesDbTableInstance() public function testGetUnknownTableThrowsException() { - $this->setExpectedException('InvalidArgumentException'); + $this->setExpectedException('\Zend\Test\PHPUnit\Db\Exception\InvalidArgumentException'); $dataSet = new DataSet\DbTableDataSet(); $dataSet->getTable('unknown'); } diff --git a/test/PHPUnit/Db/DataSet/QueryDataSetTest.php b/test/PHPUnit/Db/DataSet/QueryDataSetTest.php index 30d81c76f4..823ca2eb2e 100644 --- a/test/PHPUnit/Db/DataSet/QueryDataSetTest.php +++ b/test/PHPUnit/Db/DataSet/QueryDataSetTest.php @@ -39,7 +39,7 @@ class QueryDataSetTest extends DataSetTestCase public function testCreateQueryDataSetWithoutZendDbAdapterThrowsException() { $connectionMock = $this->getMock('PHPUnit_Extensions_Database_DB_IDatabaseConnection'); - $this->setExpectedException('Zend\Test\PHPUnit\Db\Exception'); + $this->setExpectedException('Zend\Test\PHPUnit\Db\Exception\InvalidArgumentException'); $queryDataSet = new DataSet\QueryDataSet($connectionMock); } diff --git a/test/PHPUnit/Db/DataSet/QueryTableTest.php b/test/PHPUnit/Db/DataSet/QueryTableTest.php index 649c860e40..93f83d5a02 100644 --- a/test/PHPUnit/Db/DataSet/QueryTableTest.php +++ b/test/PHPUnit/Db/DataSet/QueryTableTest.php @@ -41,7 +41,7 @@ public function testCreateQueryTableWithoutZendDbConnectionThrowsException() { $connectionMock = $this->getMock('PHPUnit_Extensions_Database_DB_IDatabaseConnection'); - $this->setExpectedException('Zend\Test\PHPUnit\Db\Exception'); + $this->setExpectedException('Zend\Test\PHPUnit\Db\Exception\InvalidArgumentException'); $queryTable = new DataSet\QueryTable("foo", "SELECT * FROM foo", $connectionMock); } diff --git a/test/PHPUnit/Db/Operation/DeleteAllTest.php b/test/PHPUnit/Db/Operation/DeleteAllTest.php index 220399687f..df1e19b520 100644 --- a/test/PHPUnit/Db/Operation/DeleteAllTest.php +++ b/test/PHPUnit/Db/Operation/DeleteAllTest.php @@ -78,7 +78,7 @@ public function testDeleteQueryErrorTransformsException() public function testInvalidConnectionGivenThrowsException() { - $this->setExpectedException("Zend\Test\PHPUnit\Db\Exception"); + $this->setExpectedException("Zend\Test\PHPUnit\Db\Exception\InvalidArgumentException"); $dataSet = $this->getMock('PHPUnit_Extensions_Database_DataSet_IDataSet'); $connection = $this->getMock('PHPUnit_Extensions_Database_DB_IDatabaseConnection'); diff --git a/test/PHPUnit/Db/Operation/InsertTest.php b/test/PHPUnit/Db/Operation/InsertTest.php index 0bccbf7106..438484a31d 100644 --- a/test/PHPUnit/Db/Operation/InsertTest.php +++ b/test/PHPUnit/Db/Operation/InsertTest.php @@ -78,7 +78,7 @@ public function testInsertExceptionIsTransformed() public function testInvalidConnectionGivenThrowsException() { - $this->setExpectedException("Zend\Test\PHPUnit\Db\Exception"); + $this->setExpectedException("Zend\Test\PHPUnit\Db\Exception\InvalidArgumentException"); $dataSet = $this->getMock('PHPUnit_Extensions_Database_DataSet_IDataSet'); $connection = $this->getMock('PHPUnit_Extensions_Database_DB_IDatabaseConnection'); diff --git a/test/PHPUnit/Db/Operation/TruncateTest.php b/test/PHPUnit/Db/Operation/TruncateTest.php index 5f09173885..5c1ae6a0de 100644 --- a/test/PHPUnit/Db/Operation/TruncateTest.php +++ b/test/PHPUnit/Db/Operation/TruncateTest.php @@ -82,7 +82,7 @@ public function testTruncateTableInvalidQueryTransformsException() public function testInvalidConnectionGivenThrowsException() { - $this->setExpectedException("Zend\Test\PHPUnit\Db\Exception"); + $this->setExpectedException("Zend\Test\PHPUnit\Db\Exception\InvalidArgumentException"); $dataSet = $this->getMock('PHPUnit_Extensions_Database_DataSet_IDataSet'); $connection = $this->getMock('PHPUnit_Extensions_Database_DB_IDatabaseConnection'); diff --git a/test/PHPUnit/Db/SimpleTesterTest.php b/test/PHPUnit/Db/SimpleTesterTest.php index 7a176e3b1c..d71c7d44eb 100644 --- a/test/PHPUnit/Db/SimpleTesterTest.php +++ b/test/PHPUnit/Db/SimpleTesterTest.php @@ -73,7 +73,7 @@ public function testSetupDatabase() public function testInvalidConnectionGivenThrowsException() { - $this->setExpectedException('Zend\Test\PHPUnit\Db\Exception'); + $this->setExpectedException('Zend\Test\PHPUnit\Db\Exception\InvalidArgumentException'); $connection = $this->getMock('PHPUnit_Extensions_Database_DB_IDatabaseConnection');