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
7a6daefb
Commit
7a6daefb
authored
Sep 15, 2017
by
Jeremy Mikola
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #402
parents
4dc36f62
4914b968
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
16 additions
and
13 deletions
+16
-13
Aggregate.php
src/Operation/Aggregate.php
+0
-4
AggregateFunctionalTest.php
tests/Operation/AggregateFunctionalTest.php
+16
-0
AggregateTest.php
tests/Operation/AggregateTest.php
+0
-9
No files found.
src/Operation/Aggregate.php
View file @
7a6daefb
...
@@ -111,10 +111,6 @@ class Aggregate implements Executable
...
@@ -111,10 +111,6 @@ class Aggregate implements Executable
*/
*/
public
function
__construct
(
$databaseName
,
$collectionName
,
array
$pipeline
,
array
$options
=
[])
public
function
__construct
(
$databaseName
,
$collectionName
,
array
$pipeline
,
array
$options
=
[])
{
{
if
(
empty
(
$pipeline
))
{
throw
new
InvalidArgumentException
(
'$pipeline is empty'
);
}
$expectedIndex
=
0
;
$expectedIndex
=
0
;
foreach
(
$pipeline
as
$i
=>
$operation
)
{
foreach
(
$pipeline
as
$i
=>
$operation
)
{
...
...
tests/Operation/AggregateFunctionalTest.php
View file @
7a6daefb
...
@@ -53,6 +53,22 @@ class AggregateFunctionalTest extends FunctionalTestCase
...
@@ -53,6 +53,22 @@ class AggregateFunctionalTest extends FunctionalTestCase
);
);
}
}
public
function
testEmptyPipelineReturnsAllDocuments
()
{
$this
->
createFixtures
(
3
);
$operation
=
new
Aggregate
(
$this
->
getDatabaseName
(),
$this
->
getCollectionName
(),
[]);
$results
=
iterator_to_array
(
$operation
->
execute
(
$this
->
getPrimaryServer
()));
$expectedDocuments
=
[
(
object
)
[
'_id'
=>
1
,
'x'
=>
(
object
)
[
'foo'
=>
'bar'
]],
(
object
)
[
'_id'
=>
2
,
'x'
=>
(
object
)
[
'foo'
=>
'bar'
]],
(
object
)
[
'_id'
=>
3
,
'x'
=>
(
object
)
[
'foo'
=>
'bar'
]],
];
$this
->
assertEquals
(
$expectedDocuments
,
$results
);
}
/**
/**
* @expectedException MongoDB\Driver\Exception\RuntimeException
* @expectedException MongoDB\Driver\Exception\RuntimeException
*/
*/
...
...
tests/Operation/AggregateTest.php
View file @
7a6daefb
...
@@ -6,15 +6,6 @@ use MongoDB\Operation\Aggregate;
...
@@ -6,15 +6,6 @@ use MongoDB\Operation\Aggregate;
class
AggregateTest
extends
TestCase
class
AggregateTest
extends
TestCase
{
{
/**
* @expectedException MongoDB\Exception\InvalidArgumentException
* @expectedExceptionMessage $pipeline is empty
*/
public
function
testConstructorPipelineArgumentMustNotBeEmpty
()
{
new
Aggregate
(
$this
->
getDatabaseName
(),
$this
->
getCollectionName
(),
[]);
}
/**
/**
* @expectedException MongoDB\Exception\InvalidArgumentException
* @expectedException MongoDB\Exception\InvalidArgumentException
* @expectedExceptionMessage $pipeline is not a list (unexpected index: "1")
* @expectedExceptionMessage $pipeline is not a list (unexpected index: "1")
...
...
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