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
2076361e
Commit
2076361e
authored
Jun 22, 2018
by
Jeremy Mikola
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
PHPLIB-358: Do not require collection name for Aggregate operation
parent
930fb185
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
31 additions
and
6 deletions
+31
-6
Aggregate.php
src/Operation/Aggregate.php
+9
-6
AggregateFunctionalTest.php
tests/Operation/AggregateFunctionalTest.php
+22
-0
No files found.
src/Operation/Aggregate.php
View file @
2076361e
...
@@ -116,8 +116,11 @@ class Aggregate implements Executable
...
@@ -116,8 +116,11 @@ class Aggregate implements Executable
* This is not supported for server versions < 3.4 and will result in an
* This is not supported for server versions < 3.4 and will result in an
* exception at execution time if used.
* exception at execution time if used.
*
*
* Note: Collection-agnostic commands (e.g. $currentOp) may be executed by
* specifying null for the collection name.
*
* @param string $databaseName Database name
* @param string $databaseName Database name
* @param string $collectionName Collection name
* @param string
|null
$collectionName Collection name
* @param array $pipeline List of pipeline operations
* @param array $pipeline List of pipeline operations
* @param array $options Command options
* @param array $options Command options
* @throws InvalidArgumentException for parameter/option parsing errors
* @throws InvalidArgumentException for parameter/option parsing errors
...
@@ -220,7 +223,7 @@ class Aggregate implements Executable
...
@@ -220,7 +223,7 @@ class Aggregate implements Executable
}
}
$this
->
databaseName
=
(
string
)
$databaseName
;
$this
->
databaseName
=
(
string
)
$databaseName
;
$this
->
collectionName
=
(
string
)
$collectionName
;
$this
->
collectionName
=
isset
(
$collectionName
)
?
(
string
)
$collectionName
:
null
;
$this
->
pipeline
=
$pipeline
;
$this
->
pipeline
=
$pipeline
;
$this
->
options
=
$options
;
$this
->
options
=
$options
;
}
}
...
@@ -289,7 +292,7 @@ class Aggregate implements Executable
...
@@ -289,7 +292,7 @@ class Aggregate implements Executable
private
function
createCommand
(
Server
$server
)
private
function
createCommand
(
Server
$server
)
{
{
$cmd
=
[
$cmd
=
[
'aggregate'
=>
$this
->
collectionName
,
'aggregate'
=>
isset
(
$this
->
collectionName
)
?
$this
->
collectionName
:
1
,
'pipeline'
=>
$this
->
pipeline
,
'pipeline'
=>
$this
->
pipeline
,
];
];
$cmdOptions
=
[];
$cmdOptions
=
[];
...
...
tests/Operation/AggregateFunctionalTest.php
View file @
2076361e
...
@@ -12,6 +12,28 @@ use stdClass;
...
@@ -12,6 +12,28 @@ use stdClass;
class
AggregateFunctionalTest
extends
FunctionalTestCase
class
AggregateFunctionalTest
extends
FunctionalTestCase
{
{
public
function
testCurrentOpCommand
()
{
if
(
version_compare
(
$this
->
getServerVersion
(),
'3.6.0'
,
'<'
))
{
$this
->
markTestSkipped
(
'$currentOp is not supported'
);
}
(
new
CommandObserver
)
->
observe
(
function
()
{
$operation
=
new
Aggregate
(
'admin'
,
null
,
[[
'$currentOp'
=>
(
object
)
[]]]
);
$operation
->
execute
(
$this
->
getPrimaryServer
());
},
function
(
stdClass
$command
)
{
$this
->
assertSame
(
1
,
$command
->
aggregate
);
}
);
}
public
function
testDefaultReadConcernIsOmitted
()
public
function
testDefaultReadConcernIsOmitted
()
{
{
(
new
CommandObserver
)
->
observe
(
(
new
CommandObserver
)
->
observe
(
...
...
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