Modified tests Mongo, Mysqli, Redis with checking work Profiler (with PROFILER_DETAILS).
This commit is contained in:
		| @ -51,7 +51,7 @@ class MongoStatementTest extends PHPUnit_Framework_TestCase | |||||||
|                     ->getMock(); |                     ->getMock(); | ||||||
|             $this->request = $this->getMockBuilder('MongoDbCommandMock') |             $this->request = $this->getMockBuilder('MongoDbCommandMock') | ||||||
|                     ->disableOriginalConstructor() |                     ->disableOriginalConstructor() | ||||||
|                     ->setMethods(array('execute', 'bindParam', 'getInsertId')) |                     ->setMethods(array('execute', 'bindParam', 'getInsertId', '__toString')) | ||||||
|                     ->getMock(); |                     ->getMock(); | ||||||
|             $this->stmt = new MongoStatement($this->driver, $this->request); |             $this->stmt = new MongoStatement($this->driver, $this->request); | ||||||
|         } |         } | ||||||
| @ -63,7 +63,7 @@ class MongoStatementTest extends PHPUnit_Framework_TestCase | |||||||
|      */ |      */ | ||||||
|     public function testAffectedNumRowsNoResult() |     public function testAffectedNumRowsNoResult() | ||||||
|     { |     { | ||||||
|         Config::set('DEBUG', false); |         Config::set('PROFILER_DETAILS', false); | ||||||
|         $this->assertFalse($this->stmt->affectedRows()); |         $this->assertFalse($this->stmt->affectedRows()); | ||||||
|         $this->assertFalse($this->stmt->numRows()); |         $this->assertFalse($this->stmt->numRows()); | ||||||
|  |  | ||||||
| @ -82,7 +82,7 @@ class MongoStatementTest extends PHPUnit_Framework_TestCase | |||||||
|      */ |      */ | ||||||
|     public function testAffectedNumRows() |     public function testAffectedNumRows() | ||||||
|     { |     { | ||||||
|         Config::set('DEBUG', false); |         Config::set('PROFILER_DETAILS', false); | ||||||
|         $this->setDriverGetConnectionMethod(); |         $this->setDriverGetConnectionMethod(); | ||||||
|         $this->request |         $this->request | ||||||
|                 ->expects($this->once()) |                 ->expects($this->once()) | ||||||
| @ -98,7 +98,7 @@ class MongoStatementTest extends PHPUnit_Framework_TestCase | |||||||
|      */ |      */ | ||||||
|     public function testGetInsertId() |     public function testGetInsertId() | ||||||
|     { |     { | ||||||
|         Config::set('DEBUG', false); |         Config::set('PROFILER_DETAILS', false); | ||||||
|         $this->setDriverGetConnectionMethod(); |         $this->setDriverGetConnectionMethod(); | ||||||
|  |  | ||||||
|         $this->request = $this->getMockBuilder('InsertMongoCommand') |         $this->request = $this->getMockBuilder('InsertMongoCommand') | ||||||
| @ -127,7 +127,7 @@ class MongoStatementTest extends PHPUnit_Framework_TestCase | |||||||
|      */ |      */ | ||||||
|     public function testExecute() |     public function testExecute() | ||||||
|     { |     { | ||||||
|         Config::set('DEBUG', false); |         Config::set('PROFILER_DETAILS', false); | ||||||
|  |  | ||||||
|         $this->setDriverGetConnectionMethod()->setRequestExecuteMethod(); |         $this->setDriverGetConnectionMethod()->setRequestExecuteMethod(); | ||||||
|         $this->assertTrue($this->stmt->execute()); |         $this->assertTrue($this->stmt->execute()); | ||||||
| @ -139,7 +139,7 @@ class MongoStatementTest extends PHPUnit_Framework_TestCase | |||||||
|      */ |      */ | ||||||
|     public function testExecuteNoResult() |     public function testExecuteNoResult() | ||||||
|     { |     { | ||||||
|         Config::set('DEBUG', false); |         Config::set('PROFILER_DETAILS', false); | ||||||
|         $this->setDriverGetConnectionMethod(); |         $this->setDriverGetConnectionMethod(); | ||||||
|         $this->request |         $this->request | ||||||
|                 ->expects($this->any()) |                 ->expects($this->any()) | ||||||
| @ -155,7 +155,7 @@ class MongoStatementTest extends PHPUnit_Framework_TestCase | |||||||
|      */ |      */ | ||||||
|     public function testExecuteNoConnection() |     public function testExecuteNoConnection() | ||||||
|     { |     { | ||||||
|         Config::set('DEBUG', false); |         Config::set('PROFILER_DETAILS', false); | ||||||
|         $this->driver |         $this->driver | ||||||
|                 ->expects($this->any()) |                 ->expects($this->any()) | ||||||
|                 ->method('getConnection') |                 ->method('getConnection') | ||||||
| @ -170,10 +170,12 @@ class MongoStatementTest extends PHPUnit_Framework_TestCase | |||||||
|      */ |      */ | ||||||
|     public function testExecuteWithDebug() |     public function testExecuteWithDebug() | ||||||
|     { |     { | ||||||
|         Config::set('DEBUG', true); |         Config::set('PROFILER', true); | ||||||
|  |         Config::set('PROFILER_DETAILS', true); | ||||||
|         $this->setDriverGetConnectionMethod()->setRequestExecuteMethod(); |         $this->setDriverGetConnectionMethod()->setRequestExecuteMethod(); | ||||||
|         $this->assertTrue($this->stmt->execute()); |         $this->assertTrue($this->stmt->execute()); | ||||||
|         $this->assertEquals(10, $this->stmt->numRows()); |         $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() |     public function testBindParam() | ||||||
|     { |     { | ||||||
|         Config::set('DEBUG', true); |         Config::set('PROFILER', true); | ||||||
|  |         Config::set('PROFILER_DETAILS', true); | ||||||
|  |  | ||||||
|         $this->request |         $this->request | ||||||
|                 ->expects($this->once()) |                 ->expects($this->once()) | ||||||
| @ -203,7 +206,8 @@ class MongoStatementTest extends PHPUnit_Framework_TestCase | |||||||
|      */ |      */ | ||||||
|     public function testFetch() |     public function testFetch() | ||||||
|     { |     { | ||||||
|         Config::set('DEBUG', true); |         Config::set('PROFILER', true); | ||||||
|  |         Config::set('PROFILER_DETAILS', true); | ||||||
|         $this->assertFalse($this->stmt->fetch()); |         $this->assertFalse($this->stmt->fetch()); | ||||||
|  |  | ||||||
|         $this->setDriverGetConnectionMethod()->setRequestForFetch(); |         $this->setDriverGetConnectionMethod()->setRequestForFetch(); | ||||||
| @ -220,7 +224,8 @@ class MongoStatementTest extends PHPUnit_Framework_TestCase | |||||||
|      */ |      */ | ||||||
|     public function testFetchWithInitialArray() |     public function testFetchWithInitialArray() | ||||||
|     { |     { | ||||||
|         Config::set('DEBUG', true); |         Config::set('PROFILER', true); | ||||||
|  |         Config::set('PROFILER_DETAILS', true); | ||||||
|         $this->assertFalse($this->stmt->fetch()); |         $this->assertFalse($this->stmt->fetch()); | ||||||
|  |  | ||||||
|         $this->setDriverGetConnectionMethod(); |         $this->setDriverGetConnectionMethod(); | ||||||
| @ -239,7 +244,8 @@ class MongoStatementTest extends PHPUnit_Framework_TestCase | |||||||
|      */ |      */ | ||||||
|     public function testFetchAssocFromCursor() |     public function testFetchAssocFromCursor() | ||||||
|     { |     { | ||||||
|         Config::set('DEBUG', true); |         Config::set('PROFILER', true); | ||||||
|  |         Config::set('PROFILER_DETAILS', true); | ||||||
|         $this->assertFalse($this->stmt->fetch()); |         $this->assertFalse($this->stmt->fetch()); | ||||||
|  |  | ||||||
|         $this->setDriverGetConnectionMethod()->setRequestForFetch(); |         $this->setDriverGetConnectionMethod()->setRequestForFetch(); | ||||||
| @ -256,7 +262,8 @@ class MongoStatementTest extends PHPUnit_Framework_TestCase | |||||||
|      */ |      */ | ||||||
|     public function testFetchAssocFromArray() |     public function testFetchAssocFromArray() | ||||||
|     { |     { | ||||||
|         Config::set('DEBUG', true); |         Config::set('PROFILER', true); | ||||||
|  |         Config::set('PROFILER_DETAILS', true); | ||||||
|         $this->assertFalse($this->stmt->fetch()); |         $this->assertFalse($this->stmt->fetch()); | ||||||
|  |  | ||||||
|         $this->setDriverGetConnectionMethod(); |         $this->setDriverGetConnectionMethod(); | ||||||
| @ -276,7 +283,8 @@ class MongoStatementTest extends PHPUnit_Framework_TestCase | |||||||
|      */ |      */ | ||||||
|     public function testFetchWrongMode() |     public function testFetchWrongMode() | ||||||
|     { |     { | ||||||
|         Config::set('DEBUG', true); |         Config::set('PROFILER', true); | ||||||
|  |         Config::set('PROFILER_DETAILS', true); | ||||||
|         $this->assertFalse($this->stmt->fetch()); |         $this->assertFalse($this->stmt->fetch()); | ||||||
|  |  | ||||||
|         $this->setDriverGetConnectionMethod(); |         $this->setDriverGetConnectionMethod(); | ||||||
| @ -296,7 +304,8 @@ class MongoStatementTest extends PHPUnit_Framework_TestCase | |||||||
|      */ |      */ | ||||||
|     public function testSkipOrderLimit() |     public function testSkipOrderLimit() | ||||||
|     { |     { | ||||||
|         Config::set('DEBUG', true); |         Config::set('PROFILER', true); | ||||||
|  |         Config::set('PROFILER_DETAILS', true); | ||||||
|         $this->setDriverGetConnectionMethod()->setRequestForFetch(); |         $this->setDriverGetConnectionMethod()->setRequestForFetch(); | ||||||
|  |  | ||||||
|         $this->stmt->execute(); |         $this->stmt->execute(); | ||||||
| @ -314,7 +323,8 @@ class MongoStatementTest extends PHPUnit_Framework_TestCase | |||||||
|      */ |      */ | ||||||
|     public function testCount() |     public function testCount() | ||||||
|     { |     { | ||||||
|         Config::set('DEBUG', true); |         Config::set('PROFILER', true); | ||||||
|  |         Config::set('PROFILER_DETAILS', true); | ||||||
|         $this->setDriverGetConnectionMethod()->setRequestForFetch(); |         $this->setDriverGetConnectionMethod()->setRequestForFetch(); | ||||||
|  |  | ||||||
|         $this->stmt->execute(); |         $this->stmt->execute(); | ||||||
| @ -329,7 +339,8 @@ class MongoStatementTest extends PHPUnit_Framework_TestCase | |||||||
|      */ |      */ | ||||||
|     public function testCountException() |     public function testCountException() | ||||||
|     { |     { | ||||||
|         Config::set('DEBUG', true); |         Config::set('PROFILER', true); | ||||||
|  |         Config::set('PROFILER_DETAILS', true); | ||||||
|         $this->setDriverGetConnectionMethod(); |         $this->setDriverGetConnectionMethod(); | ||||||
|         $this->request |         $this->request | ||||||
|                 ->expects($this->once()) |                 ->expects($this->once()) | ||||||
| @ -347,7 +358,8 @@ class MongoStatementTest extends PHPUnit_Framework_TestCase | |||||||
|      */ |      */ | ||||||
|     public function testOrderException() |     public function testOrderException() | ||||||
|     { |     { | ||||||
|         Config::set('DEBUG', true); |         Config::set('PROFILER', true); | ||||||
|  |         Config::set('PROFILER_DETAILS', true); | ||||||
|         $this->setDriverGetConnectionMethod(); |         $this->setDriverGetConnectionMethod(); | ||||||
|         $this->request |         $this->request | ||||||
|                 ->expects($this->once()) |                 ->expects($this->once()) | ||||||
| @ -365,7 +377,8 @@ class MongoStatementTest extends PHPUnit_Framework_TestCase | |||||||
|      */ |      */ | ||||||
|     public function testSkipException() |     public function testSkipException() | ||||||
|     { |     { | ||||||
|         Config::set('DEBUG', true); |         Config::set('PROFILER', true); | ||||||
|  |         Config::set('PROFILER_DETAILS', true); | ||||||
|         $this->setDriverGetConnectionMethod(); |         $this->setDriverGetConnectionMethod(); | ||||||
|         $this->request |         $this->request | ||||||
|                 ->expects($this->once()) |                 ->expects($this->once()) | ||||||
| @ -383,7 +396,8 @@ class MongoStatementTest extends PHPUnit_Framework_TestCase | |||||||
|      */ |      */ | ||||||
|     public function testLimitException() |     public function testLimitException() | ||||||
|     { |     { | ||||||
|         Config::set('DEBUG', true); |         Config::set('PROFILER', true); | ||||||
|  |         Config::set('PROFILER_DETAILS', true); | ||||||
|         $this->setDriverGetConnectionMethod(); |         $this->setDriverGetConnectionMethod(); | ||||||
|         $this->request |         $this->request | ||||||
|                 ->expects($this->once()) |                 ->expects($this->once()) | ||||||
|  | |||||||
| @ -211,6 +211,7 @@ class MySQLiStatementTest extends PHPUnit_Framework_TestCase | |||||||
|         $this->setDriverGetConnectionMethod(); |         $this->setDriverGetConnectionMethod(); | ||||||
|         $this->stmt->execute(array('place' => 'place_val', 'new' => 'new_val')); |         $this->stmt->execute(array('place' => 'place_val', 'new' => 'new_val')); | ||||||
|         $this->assertSame('OBJECT', $this->stmt->fetch()); |         $this->assertSame('OBJECT', $this->stmt->fetch()); | ||||||
|  |         $this->assertContains('Queries: 1', Profiler::getInstance()->getCli()); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     /** |     /** | ||||||
|  | |||||||
| @ -1,4 +1,4 @@ | |||||||
| <?php |     <?php | ||||||
|  |  | ||||||
| /* | /* | ||||||
|  * @copyright NetMonsters <team@netmonsters.ru> |  * @copyright NetMonsters <team@netmonsters.ru> | ||||||
| @ -107,7 +107,8 @@ class RedisManagerTest extends PHPUnit_Framework_TestCase | |||||||
|      */ |      */ | ||||||
|     public function testConnectWithDebug() |     public function testConnectWithDebug() | ||||||
|     { |     { | ||||||
|         Config::set('DEBUG', true); |         Config::set('PROFILER', true); | ||||||
|  |         Config::set('PROFILER_DETAILS', true); | ||||||
|         $this->getMock('RedisDebug'); |         $this->getMock('RedisDebug'); | ||||||
|  |  | ||||||
|         Config::set('Redis', array('new' => array('host' => true, 'port' => 2023, 'database' => true))); |         Config::set('Redis', array('new' => array('host' => true, 'port' => 2023, 'database' => true))); | ||||||
|  | |||||||
		Reference in New Issue
	
	Block a user