Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
L
laravel-mongodb
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
laravel-mongodb
Commits
37398d2e
Commit
37398d2e
authored
Mar 30, 2016
by
Renato Moura
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed logQuery to display ObjectID in parameters
parent
289ec4c5
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
40 additions
and
0 deletions
+40
-0
Collection.php
src/Jenssegers/Mongodb/Collection.php
+6
-0
CollectionTest.php
tests/CollectionTest.php
+34
-0
No files found.
src/Jenssegers/Mongodb/Collection.php
View file @
37398d2e
...
@@ -49,6 +49,12 @@ class Collection
...
@@ -49,6 +49,12 @@ class Collection
$query
=
[];
$query
=
[];
// Convert the query paramters to a json string.
// Convert the query paramters to a json string.
array_walk_recursive
(
$parameters
,
function
(
&
$item
,
$key
){
if
(
$item
instanceof
\MongoDB\BSON\ObjectID
)
{
$item
=
(
string
)
$item
;
}
});
foreach
(
$parameters
as
$parameter
)
{
foreach
(
$parameters
as
$parameter
)
{
try
{
try
{
$query
[]
=
json_encode
(
$parameter
);
$query
[]
=
json_encode
(
$parameter
);
...
...
tests/CollectionTest.php
0 → 100644
View file @
37398d2e
<?php
use
Jenssegers\Mongodb\Connection
;
use
Jenssegers\Mongodb\Collection
;
use
MongoDB\Collection
as
MongoCollection
;
use
MongoDB\BSON\ObjectID
;
class
CollectionTest
extends
TestCase
{
public
function
testExecuteMethodCall
()
{
$return
=
[
'foo'
=>
'bar'
];
$where
=
[
'id'
=>
new
ObjectID
(
'56f94800911dcc276b5723dd'
)];
$time
=
1.1
;
$queryString
=
'name-collection.findOne({"id":"56f94800911dcc276b5723dd"})'
;
$mongoCollection
=
$this
->
getMockBuilder
(
MongoCollection
::
class
)
->
disableOriginalConstructor
()
->
getMock
();
$mongoCollection
->
expects
(
$this
->
once
())
->
method
(
'findOne'
)
->
with
(
$where
)
->
willReturn
(
$return
);
$mongoCollection
->
expects
(
$this
->
once
())
->
method
(
'getCollectionName'
)
->
willReturn
(
'name-collection'
);
$connection
=
$this
->
getMockBuilder
(
Connection
::
class
)
->
disableOriginalConstructor
()
->
getMock
();
$connection
->
expects
(
$this
->
once
())
->
method
(
'logging'
)
->
willReturn
(
true
);
$connection
->
expects
(
$this
->
once
())
->
method
(
'getElapsedTime'
)
->
willReturn
(
$time
);
$connection
->
expects
(
$this
->
once
())
->
method
(
'logQuery'
)
->
with
(
$queryString
,
[],
$time
);
$collection
=
new
Collection
(
$connection
,
$mongoCollection
);
$this
->
assertEquals
(
$return
,
$collection
->
findOne
(
$where
));
}
}
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