Browse Source

remove expectedException from annotation

master
Anton Grebnev 13 years ago
parent
commit
650f311b2b
  1. 14
      tests/model/MongoDriverTest.php
  2. 18
      tests/model/MongoStatementTest.php
  3. 20
      tests/model/MySQLiStatementTest.php

14
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)));
}
}

18
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));
}

20
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')

Loading…
Cancel
Save