Skip to content

Commit

Permalink
Merge pull request #1746 from doctrine/jmikola-patch-1
Browse files Browse the repository at this point in the history
Fix normal/capped collection tests
  • Loading branch information
alcaeus committed Feb 27, 2018
2 parents 4009e31 + a7b9dfa commit 35344aa
Showing 1 changed file with 36 additions and 12 deletions.
48 changes: 36 additions & 12 deletions tests/Doctrine/ODM/MongoDB/Tests/Functional/CollectionsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,30 +76,52 @@ public function testCollections()
$this->assertSame($bar->getLocations(), $changeSet['locations'][1]);
}

public function testCreateCollections()
public function testCreateCollectionsBasic()
{
$sm = $this->dm->getSchemaManager();
$sm->dropDocumentCollection(__NAMESPACE__.'\CreateCollectionTest');
$sm->createDocumentCollection(__NAMESPACE__.'\CreateCollectionTest');

$coll = $this->dm->getDocumentCollection(__NAMESPACE__.'\CreateCollectionTest');
$insert = array(array(1), array(2), array(3));
$sm->dropDocumentCollection(CollectionTestBasic::class);
$sm->createDocumentCollection(CollectionTestBasic::class);

$coll = $this->dm->getDocumentCollection(CollectionTestBasic::class);
$insert = [
['username' => 'bob'],
['username' => 'alice'],
['username' => 'jim'],
];
$coll->insertMany($insert);

$data = $coll->find()->toArray();
$this->assertCount(3, $data);
}

public function testCreateCollectionsCapped()
{
$sm = $this->dm->getSchemaManager();
$sm->dropDocumentCollection(CollectionTestCapped::class);
$sm->createDocumentCollection(CollectionTestCapped::class);

$coll = $this->dm->getDocumentCollection(CollectionTestCapped::class);
$insert = [
['username' => 'bob'],
['username' => 'alice'],
['username' => 'jim'],
];
$coll->insertMany($insert);

$data = $coll->find()->toArray();
$this->assertCount(1, $data);
}
}

/**
* @ODM\Document(collection={
* "name"="testing",
* "capped"="true",
* "size"="1000",
* "max"="1"
* "name"="CollectionTestCapped",
* "capped"=true,
* "size"=1000,
* "max"=1
* })
*/
class CollectionTest
class CollectionTestCapped
{
/** @ODM\Id */
public $id;
Expand All @@ -111,9 +133,11 @@ class CollectionTest
/**
* @ODM\Document
*/
class CreateCollectionTest
class CollectionTestBasic
{
/** @ODM\Id */
public $id;

/** @ODM\Field(type="string") */
public $username;
}

0 comments on commit 35344aa

Please sign in to comment.