Browse Source

Modified tests Mongo, Mysqli, Redis with checking work Profiler (with PROFILER_DETAILS).

master
Alexander Demidov 13 years ago
parent
commit
e59e270476
  1. 54
      tests/model/MongoStatementTest.php
  2. 1
      tests/model/MySQLiStatementTest.php
  3. 5
      tests/redis/RedisManagerTest.php

54
tests/model/MongoStatementTest.php

@ -51,7 +51,7 @@ class MongoStatementTest extends PHPUnit_Framework_TestCase
->getMock();
$this->request = $this->getMockBuilder('MongoDbCommandMock')
->disableOriginalConstructor()
->setMethods(array('execute', 'bindParam', 'getInsertId'))
->setMethods(array('execute', 'bindParam', 'getInsertId', '__toString'))
->getMock();
$this->stmt = new MongoStatement($this->driver, $this->request);
}
@ -63,7 +63,7 @@ class MongoStatementTest extends PHPUnit_Framework_TestCase
*/
public function testAffectedNumRowsNoResult()
{
Config::set('DEBUG', false);
Config::set('PROFILER_DETAILS', false);
$this->assertFalse($this->stmt->affectedRows());
$this->assertFalse($this->stmt->numRows());
@ -82,7 +82,7 @@ class MongoStatementTest extends PHPUnit_Framework_TestCase
*/
public function testAffectedNumRows()
{
Config::set('DEBUG', false);
Config::set('PROFILER_DETAILS', false);
$this->setDriverGetConnectionMethod();
$this->request
->expects($this->once())
@ -98,7 +98,7 @@ class MongoStatementTest extends PHPUnit_Framework_TestCase
*/
public function testGetInsertId()
{
Config::set('DEBUG', false);
Config::set('PROFILER_DETAILS', false);
$this->setDriverGetConnectionMethod();
$this->request = $this->getMockBuilder('InsertMongoCommand')
@ -127,7 +127,7 @@ class MongoStatementTest extends PHPUnit_Framework_TestCase
*/
public function testExecute()
{
Config::set('DEBUG', false);
Config::set('PROFILER_DETAILS', false);
$this->setDriverGetConnectionMethod()->setRequestExecuteMethod();
$this->assertTrue($this->stmt->execute());
@ -139,7 +139,7 @@ class MongoStatementTest extends PHPUnit_Framework_TestCase
*/
public function testExecuteNoResult()
{
Config::set('DEBUG', false);
Config::set('PROFILER_DETAILS', false);
$this->setDriverGetConnectionMethod();
$this->request
->expects($this->any())
@ -155,7 +155,7 @@ class MongoStatementTest extends PHPUnit_Framework_TestCase
*/
public function testExecuteNoConnection()
{
Config::set('DEBUG', false);
Config::set('PROFILER_DETAILS', false);
$this->driver
->expects($this->any())
->method('getConnection')
@ -170,10 +170,12 @@ class MongoStatementTest extends PHPUnit_Framework_TestCase
*/
public function testExecuteWithDebug()
{
Config::set('DEBUG', true);
Config::set('PROFILER', true);
Config::set('PROFILER_DETAILS', true);
$this->setDriverGetConnectionMethod()->setRequestExecuteMethod();
$this->assertTrue($this->stmt->execute());
$this->assertEquals(10, $this->stmt->numRows());
$this->assertContains('Queries: 1', Profiler::getInstance()->getCli());
}
/**
@ -182,7 +184,8 @@ class MongoStatementTest extends PHPUnit_Framework_TestCase
*/
public function testBindParam()
{
Config::set('DEBUG', true);
Config::set('PROFILER', true);
Config::set('PROFILER_DETAILS', true);
$this->request
->expects($this->once())
@ -203,7 +206,8 @@ class MongoStatementTest extends PHPUnit_Framework_TestCase
*/
public function testFetch()
{
Config::set('DEBUG', true);
Config::set('PROFILER', true);
Config::set('PROFILER_DETAILS', true);
$this->assertFalse($this->stmt->fetch());
$this->setDriverGetConnectionMethod()->setRequestForFetch();
@ -220,7 +224,8 @@ class MongoStatementTest extends PHPUnit_Framework_TestCase
*/
public function testFetchWithInitialArray()
{
Config::set('DEBUG', true);
Config::set('PROFILER', true);
Config::set('PROFILER_DETAILS', true);
$this->assertFalse($this->stmt->fetch());
$this->setDriverGetConnectionMethod();
@ -239,7 +244,8 @@ class MongoStatementTest extends PHPUnit_Framework_TestCase
*/
public function testFetchAssocFromCursor()
{
Config::set('DEBUG', true);
Config::set('PROFILER', true);
Config::set('PROFILER_DETAILS', true);
$this->assertFalse($this->stmt->fetch());
$this->setDriverGetConnectionMethod()->setRequestForFetch();
@ -256,7 +262,8 @@ class MongoStatementTest extends PHPUnit_Framework_TestCase
*/
public function testFetchAssocFromArray()
{
Config::set('DEBUG', true);
Config::set('PROFILER', true);
Config::set('PROFILER_DETAILS', true);
$this->assertFalse($this->stmt->fetch());
$this->setDriverGetConnectionMethod();
@ -276,7 +283,8 @@ class MongoStatementTest extends PHPUnit_Framework_TestCase
*/
public function testFetchWrongMode()
{
Config::set('DEBUG', true);
Config::set('PROFILER', true);
Config::set('PROFILER_DETAILS', true);
$this->assertFalse($this->stmt->fetch());
$this->setDriverGetConnectionMethod();
@ -296,7 +304,8 @@ class MongoStatementTest extends PHPUnit_Framework_TestCase
*/
public function testSkipOrderLimit()
{
Config::set('DEBUG', true);
Config::set('PROFILER', true);
Config::set('PROFILER_DETAILS', true);
$this->setDriverGetConnectionMethod()->setRequestForFetch();
$this->stmt->execute();
@ -314,7 +323,8 @@ class MongoStatementTest extends PHPUnit_Framework_TestCase
*/
public function testCount()
{
Config::set('DEBUG', true);
Config::set('PROFILER', true);
Config::set('PROFILER_DETAILS', true);
$this->setDriverGetConnectionMethod()->setRequestForFetch();
$this->stmt->execute();
@ -329,7 +339,8 @@ class MongoStatementTest extends PHPUnit_Framework_TestCase
*/
public function testCountException()
{
Config::set('DEBUG', true);
Config::set('PROFILER', true);
Config::set('PROFILER_DETAILS', true);
$this->setDriverGetConnectionMethod();
$this->request
->expects($this->once())
@ -347,7 +358,8 @@ class MongoStatementTest extends PHPUnit_Framework_TestCase
*/
public function testOrderException()
{
Config::set('DEBUG', true);
Config::set('PROFILER', true);
Config::set('PROFILER_DETAILS', true);
$this->setDriverGetConnectionMethod();
$this->request
->expects($this->once())
@ -365,7 +377,8 @@ class MongoStatementTest extends PHPUnit_Framework_TestCase
*/
public function testSkipException()
{
Config::set('DEBUG', true);
Config::set('PROFILER', true);
Config::set('PROFILER_DETAILS', true);
$this->setDriverGetConnectionMethod();
$this->request
->expects($this->once())
@ -383,7 +396,8 @@ class MongoStatementTest extends PHPUnit_Framework_TestCase
*/
public function testLimitException()
{
Config::set('DEBUG', true);
Config::set('PROFILER', true);
Config::set('PROFILER_DETAILS', true);
$this->setDriverGetConnectionMethod();
$this->request
->expects($this->once())

1
tests/model/MySQLiStatementTest.php

@ -211,6 +211,7 @@ class MySQLiStatementTest extends PHPUnit_Framework_TestCase
$this->setDriverGetConnectionMethod();
$this->stmt->execute(array('place' => 'place_val', 'new' => 'new_val'));
$this->assertSame('OBJECT', $this->stmt->fetch());
$this->assertContains('Queries: 1', Profiler::getInstance()->getCli());
}
/**

5
tests/redis/RedisManagerTest.php

@ -1,4 +1,4 @@
<?php
<?php
/*
* @copyright NetMonsters <team@netmonsters.ru>
@ -107,7 +107,8 @@ class RedisManagerTest extends PHPUnit_Framework_TestCase
*/
public function testConnectWithDebug()
{
Config::set('DEBUG', true);
Config::set('PROFILER', true);
Config::set('PROFILER_DETAILS', true);
$this->getMock('RedisDebug');
Config::set('Redis', array('new' => array('host' => true, 'port' => 2023, 'database' => true)));

Loading…
Cancel
Save