Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix normal/capped collection tests #1746

Merged
merged 1 commit into from
Feb 27, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
}