Skip to content
This repository has been archived by the owner on Nov 11, 2020. It is now read-only.

Commit

Permalink
Merge branch '1.1.x'
Browse files Browse the repository at this point in the history
  • Loading branch information
jmikola committed Apr 29, 2014
2 parents 7afe595 + 205c8e4 commit 5f6e0ee
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/Doctrine/MongoDB/Database.php
Expand Up @@ -128,6 +128,10 @@ public function createCollection($name, $cappedOrOptions = false, $size = 0, $ma
? array_merge(array('capped' => false, 'size' => 0, 'max' => 0), $cappedOrOptions)
: array('capped' => $cappedOrOptions, 'size' => $size, 'max' => $max);

$options['capped'] = (boolean) $options['capped'];
$options['size'] = (integer) $options['size'];
$options['max'] = (integer) $options['max'];

if ($this->eventManager->hasListeners(Events::preCreateCollection)) {
$this->eventManager->dispatchEvent(Events::preCreateCollection, new CreateCollectionEventArgs($this, $name, $options));
}
Expand Down
25 changes: 25 additions & 0 deletions tests/Doctrine/MongoDB/Tests/DatabaseTest.php
Expand Up @@ -60,6 +60,31 @@ public function testCreateCollectionWithOptionsArgument()
$this->assertInstanceOf('Doctrine\MongoDB\Collection', $collection);
}

public function testCreateCollectionCappedOptionsAreCast()
{
$mongoDB = $this->getMockMongoDB();

if (version_compare(phpversion('mongo'), '1.4.0', '>=')) {
$mongoDB->expects($this->once())
->method('createCollection')
->with('foo', array('capped' => false, 'size' => 0, 'max' => 0));
} else {
$mongoDB->expects($this->once())
->method('createCollection')
->with('foo', false, 0, 0);
}

$mongoDB->expects($this->once())
->method('selectCollection')
->with('foo')
->will($this->returnValue($this->getMockMongoCollection()));

$database = new Database($this->getMockConnection(), $mongoDB, $this->getMockEventManager());
$collection = $database->createCollection('foo', array('capped' => 0, 'size' => null, 'max' => null));

$this->assertInstanceOf('Doctrine\MongoDB\Collection', $collection);
}

public function testGetSetSlaveOkay()
{
if (version_compare(phpversion('mongo'), '1.3.0', '>=')) {
Expand Down

0 comments on commit 5f6e0ee

Please sign in to comment.