From 650f311b2b09382fe2783409612cc98a78532cae Mon Sep 17 00:00:00 2001 From: Anton Grebnev Date: Tue, 6 Dec 2011 16:22:04 +0400 Subject: [PATCH] remove expectedException from annotation --- tests/model/MongoDriverTest.php | 14 ++------------ tests/model/MongoStatementTest.php | 18 ++++++------------ tests/model/MySQLiStatementTest.php | 20 +++++++------------- 3 files changed, 15 insertions(+), 37 deletions(-) diff --git a/tests/model/MongoDriverTest.php b/tests/model/MongoDriverTest.php index a027f1b..4a102e7 100644 --- a/tests/model/MongoDriverTest.php +++ b/tests/model/MongoDriverTest.php @@ -72,25 +72,18 @@ class MongoDriverTest extends PHPUnit_Framework_TestCase } } - /** - * @expectedException GeneralException - * @expectedExceptionMessage Configuration must have a "hostname". - */ public function testGetConnectionNoHostname() { unset($this->conf['hostname']); + $this->setExpectedException('GeneralException', 'Configuration must have a "hostname"'); $mongo = new MongoDriver($this->conf); - $mongo->getConnection(); } - /** - * @expectedException MongoConnectionException - * @expectedExceptionMessage Couldn't authenticate with database - */ public function testGetConnectionWrongPassword() { $this->conf['password'] = 'nopass'; $mongo = new MongoDriver($this->conf); + $this->setExpectedException('MongoConnectionException', 'Couldn\'t authenticate with database'); $this->assertInstanceOf('MongoDB', $mongo->getConnection()); } @@ -323,8 +316,5 @@ class MongoDriverTest extends PHPUnit_Framework_TestCase $mongo = new MongoDriver($this->conf); $result = $mongo->command('items', array('distinct' =>'items', 'key' => 'name')); $this->assertEquals(4, count($result->fetch(DB::FETCH_ASSOC))); - - - } } \ No newline at end of file diff --git a/tests/model/MongoStatementTest.php b/tests/model/MongoStatementTest.php index a09a324..e18c5d6 100644 --- a/tests/model/MongoStatementTest.php +++ b/tests/model/MongoStatementTest.php @@ -137,8 +137,6 @@ class MongoStatementTest extends PHPUnit_Framework_TestCase /** * @runInSeparateProcess - * @expectedException GeneralException - * @expectedExceptionMessage MongoDB request error. */ public function testExecuteNoResult() { @@ -150,13 +148,12 @@ class MongoStatementTest extends PHPUnit_Framework_TestCase ->expects($this->any()) ->method('execute') ->will($this->returnValue(false)); + $this->setExpectedException('GeneralException', 'MongoDB request error.'); $this->stmt->execute(); } /** * @runInSeparateProcess - * @expectedException GeneralException - * @expectedExceptionMessage No connection to MongoDB server. */ public function testExecuteNoConnection() { @@ -167,6 +164,7 @@ class MongoStatementTest extends PHPUnit_Framework_TestCase ->expects($this->any()) ->method('getConnection') ->will($this->returnValue(false)); + $this->setExpectedException('GeneralException', 'No connection to MongoDB server.'); $this->stmt->execute(); } @@ -284,8 +282,6 @@ class MongoStatementTest extends PHPUnit_Framework_TestCase /** * @runInSeparateProcess - * @expectedException GeneralException - * @expectedExceptionMessage Invalid fetch mode "222" specified */ public function testFetchWrongMode() { @@ -301,6 +297,7 @@ class MongoStatementTest extends PHPUnit_Framework_TestCase ->will($this->returnValue(array('some' => 'val'))); $this->stmt->execute(); + $this->setExpectedException('GeneralException', 'Invalid fetch mode "222" specified'); $this->stmt->fetch(222); } @@ -325,8 +322,6 @@ class MongoStatementTest extends PHPUnit_Framework_TestCase /** * @runInSeparateProcess - * @expectedException GeneralException - * @expectedExceptionMessage MongoStatement error. Impossible order results of opened cursor */ public function testOrderException() { @@ -340,13 +335,12 @@ class MongoStatementTest extends PHPUnit_Framework_TestCase ->will($this->returnValue(array('some' => 'val'))); $this->stmt->execute(); + $this->setExpectedException('GeneralException', 'MongoStatement error. Impossible order results of opened cursor'); $this->stmt->order(array('id' => 1)); } /** * @runInSeparateProcess - * @expectedException GeneralException - * @expectedExceptionMessage MongoStatement error. Impossible skip results of opened cursor */ public function testSkipException() { @@ -360,13 +354,12 @@ class MongoStatementTest extends PHPUnit_Framework_TestCase ->will($this->returnValue(array('some' => 'val'))); $this->stmt->execute(); + $this->setExpectedException('GeneralException', 'MongoStatement error. Impossible skip results of opened cursor'); $this->stmt->skip(array('id' => 1)); } /** * @runInSeparateProcess - * @expectedException GeneralException - * @expectedExceptionMessage MongoStatement error. Impossible limit results of opened cursor */ public function testLimitException() { @@ -380,6 +373,7 @@ class MongoStatementTest extends PHPUnit_Framework_TestCase ->will($this->returnValue(array('some' => 'val'))); $this->stmt->execute(); + $this->setExpectedException('GeneralException', 'MongoStatement error. Impossible limit results of opened cursor'); $this->stmt->limit(array('id' => 1)); } diff --git a/tests/model/MySQLiStatementTest.php b/tests/model/MySQLiStatementTest.php index 9d7c4bc..83dfc96 100644 --- a/tests/model/MySQLiStatementTest.php +++ b/tests/model/MySQLiStatementTest.php @@ -62,23 +62,17 @@ class MySQLiStatementTest extends PHPUnit_Framework_TestCase $this->assertTrue($this->stmt->bindParam('place', $val)); } - /** - * @expectedException GeneralException - * @expectedExceptionMessage Placeholder must be an integer or string - */ public function testBindParamExceptionParam() { $val = 1; + $this->setExpectedException('GeneralException', 'Placeholder must be an integer or string'); $this->stmt->bindParam(array(), $val); } - /** - * @expectedException GeneralException - * @expectedExceptionMessage Objects excepts DbExpr not allowed. - */ public function testBindParamExceptionWrongObject() { $val = $this->getMock('NotDbExpr'); + $this->setExpectedException('GeneralException', 'Objects excepts DbExpr not allowed.'); $this->stmt->bindParam('paa', $val); } @@ -98,7 +92,7 @@ class MySQLiStatementTest extends PHPUnit_Framework_TestCase ->will($this->returnCallback(array($this, 'driverQuote'))); $this->setDriverGetConnectionMethod(); - + $result = $this->stmt->execute(array('place' => 'place_val', 'new' => 'new_val')); $this->assertTrue($result); } @@ -112,7 +106,7 @@ class MySQLiStatementTest extends PHPUnit_Framework_TestCase define('DEBUG', false); } $this->setDriverGetConnectionMethod(); - + $this->sql = 'PLAIN SQL'; $result = $this->stmt->execute(array()); $this->assertTrue($result); @@ -214,7 +208,7 @@ class MySQLiStatementTest extends PHPUnit_Framework_TestCase ->expects($this->any()) ->method('getConnection') ->will($this->returnValue($mysqliMock)); - + $this->stmt->execute(array('place' => 'place_val', 'new' => 'new_val')); $this->assertSame(array('pair' => 'value'), $this->stmt->fetchPairs()); } @@ -302,7 +296,7 @@ class MySQLiStatementTest extends PHPUnit_Framework_TestCase $this->stmt->execute(array('place' => 'place_val', 'new' => 'new_val')); $this->setExpectedException('GeneralException'); - + $this->stmt->fetch(324); } @@ -336,7 +330,7 @@ class MySQLiStatementTest extends PHPUnit_Framework_TestCase ->method('query') ->with($this->anything()) ->will($this->returnValue($resultMock)); - + $this->driver ->expects($this->any()) ->method('getConnection')