Skip to content

Commit

Permalink
[Profiling][Collection]
Browse files Browse the repository at this point in the history
- #10 collection updateOne method is now profiled
  • Loading branch information
Alessandro Galli committed Sep 2, 2016
1 parent 827deae commit 5c0846a
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/Capsule/Collection.php
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,18 @@ public function insertOne($document, array $options = [])
return $result;
}

/**
* {@inheritdoc}
*/
public function updateOne($filter, $update, array $options = [])
{
$event = $this->startQueryLogging(__FUNCTION__, $filter, $update, $options);
$result = parent::updateOne($filter, $update, $options);
$this->logger->logQuery($event);

return $result;
}

/**
* @param string $method
* @param array $filters
Expand Down
12 changes: 12 additions & 0 deletions tests/Functional/Capsule/CollectionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,18 @@ public function test_insertOne()
$coll->insertOne(['test' => 1]);
}

public function test_updateOne()
{
$manager = new Manager('mongodb://localhost');
$logger = self::prophesize(DataCollectorLoggerInterface::class);
$logger->startLogging(Argument::type(LogEvent::class))->shouldBeCalled();
$logger->logQuery(Argument::type(LogEvent::class))->shouldBeCalled();

$coll = new Collection($manager, 'testdb', 'test_collection', [], $logger->reveal());

$coll->updateOne(['filter' => 1],['$set' => ['testField' => 1]]);
}

public function test_count()
{
$manager = new Manager('mongodb://localhost');
Expand Down

0 comments on commit 5c0846a

Please sign in to comment.