Browse Source

updated MongoDbCommand Profiler output

master
Anton Grebnev 13 years ago
parent
commit
623666fb09
  1. 26
      model/MongoDbCommand.php
  2. 2
      tests/model/MongoDbCommandTest.php

26
model/MongoDbCommand.php

@ -97,11 +97,11 @@ class FindMongoCommand extends MongoDbCommand
public function __toString() public function __toString()
{ {
if ($this->checkParams()) { if ($this->checkParams()) {
$result = 'Collection: ' . $this->collection . PHP_EOL;
$result = PHP_EOL . 'Collection: ' . $this->collection . PHP_EOL;
ob_start(); ob_start();
var_dump($this->condition); var_dump($this->condition);
$condition = ob_get_clean(); $condition = ob_get_clean();
$result .= 'Condition: ' . $condition . PHP_EOL;
$result .= 'Condition: ' . $condition;
$result .= 'Type: FIND' . PHP_EOL; $result .= 'Type: FIND' . PHP_EOL;
ob_start(); ob_start();
var_dump($this->fields); var_dump($this->fields);
@ -143,12 +143,12 @@ class CountMongoCommand extends MongoDbCommand
public function __toString() public function __toString()
{ {
if ($this->checkParams()) { if ($this->checkParams()) {
$result = 'Collection: ' . $this->collection . PHP_EOL;
$result = PHP_EOL . 'Collection: ' . $this->collection . PHP_EOL;
$result .= 'Type: COUNT' . PHP_EOL; $result .= 'Type: COUNT' . PHP_EOL;
ob_start(); ob_start();
var_dump($this->condition); var_dump($this->condition);
$condition = ob_get_clean(); $condition = ob_get_clean();
$result .= 'Condition: ' . $condition . PHP_EOL;
$result .= 'Condition: ' . $condition;
$result .= 'Limit: ' . $this->limit . PHP_EOL; $result .= 'Limit: ' . $this->limit . PHP_EOL;
$result .= 'Skip: ' . $this->skip . PHP_EOL; $result .= 'Skip: ' . $this->skip . PHP_EOL;
return $result; return $result;
@ -199,12 +199,12 @@ class InsertMongoCommand extends MongoDbCommand
public function __toString() public function __toString()
{ {
if ($this->checkParams()) { if ($this->checkParams()) {
$result = 'Collection: ' . $this->collection . PHP_EOL;
$result = PHP_EOL . 'Collection: ' . $this->collection . PHP_EOL;
$result .= 'Type: INSERT' . PHP_EOL; $result .= 'Type: INSERT' . PHP_EOL;
ob_start(); ob_start();
var_dump($this->data); var_dump($this->data);
$data = ob_get_clean(); $data = ob_get_clean();
$result .= 'Data: ' . $data . PHP_EOL;
$result .= 'Data: ' . $data;
$mult = $this->multiple ? 'TRUE' : 'FALSE'; $mult = $this->multiple ? 'TRUE' : 'FALSE';
$result .= 'Bulk insert: ' . $mult . PHP_EOL; $result .= 'Bulk insert: ' . $mult . PHP_EOL;
$safe = $this->safe ? 'TRUE' : 'FALSE'; $safe = $this->safe ? 'TRUE' : 'FALSE';
@ -248,16 +248,16 @@ class UpdateMongoCommand extends MongoDbCommand
public function __toString() public function __toString()
{ {
if ($this->checkParams()) { if ($this->checkParams()) {
$result = 'Collection: ' . $this->collection . PHP_EOL;
$result = PHP_EOL . 'Collection: ' . $this->collection . PHP_EOL;
$result .= 'Type: UPDATE' . PHP_EOL; $result .= 'Type: UPDATE' . PHP_EOL;
ob_start(); ob_start();
var_dump($this->condition); var_dump($this->condition);
$condition = ob_get_clean(); $condition = ob_get_clean();
$result .= 'Condition: ' . $condition . PHP_EOL;
$result .= 'Condition: ' . $condition;
ob_start(); ob_start();
var_dump($this->data); var_dump($this->data);
$data = ob_get_clean(); $data = ob_get_clean();
$result .= 'Data: ' . $data . PHP_EOL;
$result .= 'Data: ' . $data;
$mult = $this->multiple ? 'TRUE' : 'FALSE'; $mult = $this->multiple ? 'TRUE' : 'FALSE';
$result .= 'Multiple fields: ' . $mult . PHP_EOL; $result .= 'Multiple fields: ' . $mult . PHP_EOL;
$upsert = $this->upsert ? 'TRUE' : 'FALSE'; $upsert = $this->upsert ? 'TRUE' : 'FALSE';
@ -294,12 +294,12 @@ class RemoveMongoCommand extends MongoDbCommand
public function __toString() public function __toString()
{ {
if ($this->checkParams()) { if ($this->checkParams()) {
$result = 'Collection: ' . $this->collection . PHP_EOL;
$result = PHP_EOL . 'Collection: ' . $this->collection . PHP_EOL;
$result .= 'Type: REMOVE' . PHP_EOL; $result .= 'Type: REMOVE' . PHP_EOL;
ob_start(); ob_start();
var_dump($this->condition); var_dump($this->condition);
$condition = ob_get_clean(); $condition = ob_get_clean();
$result .= 'Condition: ' . $condition . PHP_EOL;
$result .= 'Condition: ' . $condition;
$safe = $this->safe ? 'TRUE' : 'FALSE'; $safe = $this->safe ? 'TRUE' : 'FALSE';
$result .= 'Safe operation: ' . $safe . PHP_EOL; $result .= 'Safe operation: ' . $safe . PHP_EOL;
return $result; return $result;
@ -335,12 +335,12 @@ class CommandMongoCommand extends MongoDbCommand
public function __toString() public function __toString()
{ {
if ($this->checkParams()) { if ($this->checkParams()) {
$result = 'Collection: ' . $this->collection . PHP_EOL;
$result = PHP_EOL . 'Collection: ' . $this->collection . PHP_EOL;
$result .= 'Type: COMMAND' . PHP_EOL; $result .= 'Type: COMMAND' . PHP_EOL;
ob_start(); ob_start();
var_dump($this->command); var_dump($this->command);
$command = ob_get_clean(); $command = ob_get_clean();
$result .= 'Command: ' . $command . PHP_EOL;
$result .= 'Command: ' . $command;
return $result; return $result;
} else { } else {
return 'Command properties not set'; return 'Command properties not set';

2
tests/model/MongoDbCommandTest.php

@ -330,7 +330,7 @@ class MongoDbCommandTest extends PHPUnit_Framework_TestCase
$cmd = MongoCommandBuilder::factory(MongoCommandBuilder::COUNT, new CollectionMock()); $cmd = MongoCommandBuilder::factory(MongoCommandBuilder::COUNT, new CollectionMock());
$cmd->bindParam('condition', array()); $cmd->bindParam('condition', array());
$this->assertStringStartsWith('Collection: CollectionMock', $cmd->__toString()); $this->assertStringStartsWith('Collection: CollectionMock', $cmd->__toString());
$cmd = MongoCommandBuilder::factory(MongoCommandBuilder::FIND, new CollectionMock()); $cmd = MongoCommandBuilder::factory(MongoCommandBuilder::FIND, new CollectionMock());
$cmd->bindParam('condition', array()); $cmd->bindParam('condition', array());
$this->assertStringStartsWith('Collection: CollectionMock', $cmd->__toString()); $this->assertStringStartsWith('Collection: CollectionMock', $cmd->__toString());

Loading…
Cancel
Save