Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
M
mongo-php-library
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
sinan
mongo-php-library
Commits
e574c2df
Commit
e574c2df
authored
Apr 10, 2015
by
Jeremy Mikola
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
PHPLIB-45: Test listCollections with filter option
parent
ccf1eba5
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
2 deletions
+20
-2
DatabaseFunctionalTest.php
tests/DatabaseFunctionalTest.php
+20
-2
No files found.
tests/DatabaseFunctionalTest.php
View file @
e574c2df
...
...
@@ -71,8 +71,8 @@ class DatabaseFunctionalTest extends FunctionalTestCase
public
function
testListCollections
()
{
$
writeResult
=
$this
->
manager
->
executeInsert
(
$this
->
getNamespace
(),
array
(
'x'
=>
1
));
$this
->
assert
Equals
(
1
,
$writeResult
->
getInsertedCount
()
);
$
commandResult
=
$this
->
database
->
createCollection
(
$this
->
getCollectionName
(
));
$this
->
assert
CommandSucceeded
(
$commandResult
);
$collections
=
$this
->
database
->
listCollections
();
$this
->
assertInstanceOf
(
'MongoDB\Model\CollectionInfoIterator'
,
$collections
);
...
...
@@ -82,6 +82,24 @@ class DatabaseFunctionalTest extends FunctionalTestCase
}
}
public
function
testListCollectionsWithFilter
()
{
$commandResult
=
$this
->
database
->
createCollection
(
$this
->
getCollectionName
());
$this
->
assertCommandSucceeded
(
$commandResult
);
$collectionName
=
$this
->
getCollectionName
();
$options
=
array
(
'filter'
=>
array
(
'name'
=>
$collectionName
));
$collections
=
$this
->
database
->
listCollections
(
$options
);
$this
->
assertInstanceOf
(
'MongoDB\Model\CollectionInfoIterator'
,
$collections
);
$this
->
assertCount
(
1
,
$collections
);
foreach
(
$collections
as
$collection
)
{
$this
->
assertInstanceOf
(
'MongoDB\Model\CollectionInfo'
,
$collection
);
$this
->
assertEquals
(
$collectionName
,
$collection
->
getName
());
}
}
/**
* Asserts that a collection with the given name exists in the database.
*
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment