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
675bb863
Commit
675bb863
authored
Sep 21, 2013
by
Jens Segers
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed issue #42 and tweaked tests
parent
1e533493
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
45 additions
and
29 deletions
+45
-29
.travis.yml
.travis.yml
+2
-2
phpunit.xml
phpunit.xml
+18
-0
Builder.php
src/Jenssegers/Mongodb/Builder.php
+7
-7
CacheTest.php
tests/CacheTest.php
+1
-2
ConnectionTest.php
tests/ConnectionTest.php
+1
-3
ModelTest.php
tests/ModelTest.php
+1
-2
QueryBuilderTest.php
tests/QueryBuilderTest.php
+12
-7
QueryTest.php
tests/QueryTest.php
+1
-2
RelationsTest.php
tests/RelationsTest.php
+1
-2
SchemaTest.php
tests/SchemaTest.php
+1
-2
bootstrap.php
tests/bootstrap.php
+0
-0
No files found.
.travis.yml
View file @
675bb863
...
...
@@ -4,7 +4,7 @@ branches:
only
:
-
master
php
:
php
:
-
5.3
-
5.4
-
5.5
...
...
@@ -16,4 +16,4 @@ before_script:
-
composer self-update
-
composer install --dev --no-interaction
script
:
phpunit tests
\ No newline at end of file
script
:
phpunit
phpunit.xml
0 → 100644
View file @
675bb863
<?xml version="1.0" encoding="UTF-8"?>
<phpunit
backupGlobals=
"false"
backupStaticAttributes=
"false"
bootstrap=
"tests/bootstrap.php"
colors=
"true"
convertErrorsToExceptions=
"true"
convertNoticesToExceptions=
"true"
convertWarningsToExceptions=
"true"
processIsolation=
"false"
stopOnFailure=
"false"
syntaxCheck=
"false"
>
<testsuites>
<testsuite
name=
"Laravel MongoDB Test Suite"
>
<directory>
tests/
</directory>
</testsuite>
</testsuites>
</phpunit>
src/Jenssegers/Mongodb/Builder.php
View file @
675bb863
...
...
@@ -89,7 +89,7 @@ class Builder extends \Illuminate\Database\Query\Builder {
}
else
{
// If we don't use grouping, set the _id to null to prepare the pipeline for
// If we don't use grouping, set the _id to null to prepare the pipeline for
// other aggregation functions
$group
[
'_id'
]
=
null
;
}
...
...
@@ -149,7 +149,7 @@ class Builder extends \Illuminate\Database\Query\Builder {
$column
=
isset
(
$this
->
columns
[
0
])
?
$this
->
columns
[
0
]
:
'_id'
;
return
$this
->
collection
->
distinct
(
$column
,
$wheres
);
}
// Normal query
else
{
...
...
@@ -282,7 +282,7 @@ class Builder extends \Illuminate\Database\Query\Builder {
{
// As soon as we find a value that is not an array we assume the user is
// inserting a single document.
if
(
!
is_array
(
$value
))
if
(
!
is_array
(
$value
))
{
$batch
=
false
;
break
;
}
...
...
@@ -546,7 +546,7 @@ class Builder extends \Illuminate\Database\Query\Builder {
/**
* Convert a key to MongoID if needed.
*
*
* @param mixed $id
* @return mixed
*/
...
...
@@ -572,7 +572,7 @@ class Builder extends \Illuminate\Database\Query\Builder {
// The new list of compiled wheres
$wheres
=
array
();
foreach
(
$this
->
wheres
as
$i
=>
&
$where
)
foreach
(
$this
->
wheres
as
$i
=>
&
$where
)
{
// Convert id's
if
(
isset
(
$where
[
'column'
])
&&
$where
[
'column'
]
==
'_id'
)
...
...
@@ -586,7 +586,7 @@ class Builder extends \Illuminate\Database\Query\Builder {
}
}
// Single value
else
else
if
(
isset
(
$where
[
'value'
]))
{
$where
[
'value'
]
=
$this
->
convertKey
(
$where
[
'value'
]);
}
...
...
@@ -715,4 +715,4 @@ class Builder extends \Illuminate\Database\Query\Builder {
return
parent
::
__call
(
$method
,
$parameters
);
}
}
\ No newline at end of file
}
tests/CacheTest.php
View file @
675bb863
<?php
require_once
(
'tests/app.php'
);
use
Illuminate\Support\Facades\DB
;
...
...
@@ -38,4 +37,4 @@ class CacheTest extends PHPUnit_Framework_TestCase {
$this
->
assertEquals
(
3
,
count
(
$users
));
}
}
\ No newline at end of file
}
tests/ConnectionTest.php
View file @
675bb863
<?php
require_once
(
'tests/app.php'
);
use
Illuminate\Support\Facades\DB
;
use
Jenssegers\Mongodb\Connection
;
...
...
@@ -63,4 +61,4 @@ class ConnectionTest extends PHPUnit_Framework_TestCase {
$this
->
assertEquals
(
1
,
count
(
$hosts
));
}
}
\ No newline at end of file
}
tests/ModelTest.php
View file @
675bb863
<?php
require_once
(
'tests/app.php'
);
class
ModelTest
extends
PHPUnit_Framework_TestCase
{
...
...
@@ -305,4 +304,4 @@ class ModelTest extends PHPUnit_Framework_TestCase {
$this
->
assertFalse
(
isset
(
$user2
->
note2
));
}
}
\ No newline at end of file
}
tests/QueryBuilderTest.php
View file @
675bb863
<?php
require_once
(
'tests/app.php'
);
use
Illuminate\Support\Facades\DB
;
...
...
@@ -56,7 +55,7 @@ class QueryBuilderTest extends PHPUnit_Framework_TestCase {
$this
->
assertTrue
(
is_array
(
$user
[
'tags'
]));
}
public
function
testInsertGetId
()
public
function
testInsertGetId
()
{
$id
=
DB
::
collection
(
'users'
)
->
insertGetId
(
array
(
'name'
=>
'John Doe'
));
...
...
@@ -69,7 +68,7 @@ class QueryBuilderTest extends PHPUnit_Framework_TestCase {
DB
::
collection
(
'users'
)
->
insert
(
array
(
array
(
'tags'
=>
array
(
'tag1'
,
'tag2'
),
'name'
=>
'Jane Doe'
,
'name'
=>
'Jane Doe'
,
),
array
(
'tags'
=>
array
(
'tag3'
),
...
...
@@ -93,6 +92,12 @@ class QueryBuilderTest extends PHPUnit_Framework_TestCase {
$this
->
assertEquals
(
'John Doe'
,
$user
[
'name'
]);
}
public
function
testFindNull
()
{
$user
=
DB
::
collection
(
'users'
)
->
find
(
null
);
$this
->
assertEquals
(
null
,
$user
);
}
public
function
testCount
()
{
DB
::
collection
(
'users'
)
->
insert
(
array
(
...
...
@@ -201,14 +206,14 @@ class QueryBuilderTest extends PHPUnit_Framework_TestCase {
));
DB
::
collection
(
'users'
)
->
where
(
'_id'
,
$id
)
->
push
(
'tags'
,
'tag1'
);
$user
=
DB
::
collection
(
'users'
)
->
find
(
$id
);
$this
->
assertTrue
(
is_array
(
$user
[
'tags'
]));
$this
->
assertEquals
(
1
,
count
(
$user
[
'tags'
]));
$this
->
assertEquals
(
'tag1'
,
$user
[
'tags'
][
0
]);
DB
::
collection
(
'users'
)
->
where
(
'_id'
,
$id
)
->
push
(
'tags'
,
'tag2'
);
$user
=
DB
::
collection
(
'users'
)
->
find
(
$id
);
$this
->
assertTrue
(
is_array
(
$user
[
'tags'
]));
$this
->
assertEquals
(
2
,
count
(
$user
[
'tags'
]));
...
...
@@ -233,7 +238,7 @@ class QueryBuilderTest extends PHPUnit_Framework_TestCase {
));
DB
::
collection
(
'users'
)
->
where
(
'_id'
,
$id
)
->
pull
(
'tags'
,
'tag3'
);
$user
=
DB
::
collection
(
'users'
)
->
find
(
$id
);
$this
->
assertTrue
(
is_array
(
$user
[
'tags'
]));
$this
->
assertEquals
(
3
,
count
(
$user
[
'tags'
]));
...
...
@@ -408,4 +413,4 @@ class QueryBuilderTest extends PHPUnit_Framework_TestCase {
$this
->
assertFalse
(
isset
(
$user2
[
'note2'
]));
}
}
\ No newline at end of file
}
tests/QueryTest.php
View file @
675bb863
<?php
require_once
(
'tests/app.php'
);
class
QueryTest
extends
PHPUnit_Framework_TestCase
{
...
...
@@ -242,4 +241,4 @@ class QueryTest extends PHPUnit_Framework_TestCase {
$this
->
assertEquals
(
6
,
count
(
$users
));
}
}
\ No newline at end of file
}
tests/RelationsTest.php
View file @
675bb863
<?php
require_once
(
'tests/app.php'
);
class
RelationsTest
extends
PHPUnit_Framework_TestCase
{
...
...
@@ -103,4 +102,4 @@ class RelationsTest extends PHPUnit_Framework_TestCase {
$this
->
assertEquals
(
'admin'
,
$role
->
type
);
}
}
\ No newline at end of file
}
tests/SchemaTest.php
View file @
675bb863
<?php
require_once
(
'tests/app.php'
);
use
Illuminate\Support\Facades\DB
;
use
Illuminate\Support\Facades\Schema
;
...
...
@@ -105,4 +104,4 @@ class SchemaTest extends PHPUnit_Framework_TestCase {
return
false
;
}
}
\ No newline at end of file
}
tests/
ap
p.php
→
tests/
bootstra
p.php
View file @
675bb863
File moved
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