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
53c481c8
Commit
53c481c8
authored
Sep 28, 2015
by
Jeremy Mikola
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ListCollections functional tests
parent
aee5a0c6
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
45 additions
and
0 deletions
+45
-0
ListCollectionsFunctionalTest.php
tests/Operation/ListCollectionsFunctionalTest.php
+45
-0
No files found.
tests/Operation/ListCollectionsFunctionalTest.php
0 → 100644
View file @
53c481c8
<?php
namespace
MongoDB\Tests\Operation
;
use
MongoDB\Driver\Server
;
use
MongoDB\Operation\DropDatabase
;
use
MongoDB\Operation\ListCollections
;
class
ListCollectionsFunctionalTest
extends
FunctionalTestCase
{
public
function
testListCollectionsForNewlyCreatedDatabase
()
{
$server
=
$this
->
getPrimaryServer
();
$operation
=
new
DropDatabase
(
$this
->
getDatabaseName
());
$operation
->
execute
(
$server
);
$writeResult
=
$this
->
manager
->
executeInsert
(
$this
->
getNamespace
(),
[
'x'
=>
1
]);
$this
->
assertEquals
(
1
,
$writeResult
->
getInsertedCount
());
$operation
=
new
ListCollections
(
$this
->
getDatabaseName
(),
[
'filter'
=>
[
'name'
=>
$this
->
getCollectionName
()]]);
// Convert the CollectionInfoIterator to an array since we cannot rewind its cursor
$collections
=
iterator_to_array
(
$operation
->
execute
(
$server
));
$this
->
assertCount
(
1
,
$collections
);
foreach
(
$collections
as
$collection
)
{
$this
->
assertInstanceOf
(
'MongoDB\Model\CollectionInfo'
,
$collection
);
$this
->
assertEquals
(
$this
->
getCollectionName
(),
$collection
->
getName
());
}
}
public
function
testListCollectionsForNonexistentDatabase
()
{
$server
=
$this
->
getPrimaryServer
();
$operation
=
new
DropDatabase
(
$this
->
getDatabaseName
());
$operation
->
execute
(
$server
);
$operation
=
new
ListCollections
(
$this
->
getDatabaseName
());
$collections
=
$operation
->
execute
(
$server
);
$this
->
assertCount
(
0
,
$collections
);
}
}
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