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
76781d79
Commit
76781d79
authored
Jan 05, 2014
by
Jens Segers
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed insert return type and tweaked some tests
parent
9f601636
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
12 additions
and
19 deletions
+12
-19
Builder.php
src/Jenssegers/Mongodb/Query/Builder.php
+1
-1
ModelTest.php
tests/ModelTest.php
+3
-14
QueryBuilderTest.php
tests/QueryBuilderTest.php
+8
-4
No files found.
src/Jenssegers/Mongodb/Query/Builder.php
View file @
76781d79
...
@@ -338,7 +338,7 @@ class Builder extends \Illuminate\Database\Query\Builder {
...
@@ -338,7 +338,7 @@ class Builder extends \Illuminate\Database\Query\Builder {
$this
->
from
.
'.batchInsert('
.
json_encode
(
$values
)
.
')'
,
$this
->
from
.
'.batchInsert('
.
json_encode
(
$values
)
.
')'
,
array
(),
$this
->
connection
->
getElapsedTime
(
$start
));
array
(),
$this
->
connection
->
getElapsedTime
(
$start
));
return
$result
;
return
(
1
==
(
int
)
$result
[
'ok'
])
;
}
}
/**
/**
...
...
tests/ModelTest.php
View file @
76781d79
...
@@ -274,22 +274,11 @@ class ModelTest extends PHPUnit_Framework_TestCase {
...
@@ -274,22 +274,11 @@ class ModelTest extends PHPUnit_Framework_TestCase {
public
function
testToArray
()
public
function
testToArray
()
{
{
$original
=
array
(
array
(
'name'
=>
'knife'
,
'type'
=>
'sharp'
),
array
(
'name'
=>
'spoon'
,
'type'
=>
'round'
)
);
Item
::
insert
(
$original
);
$items
=
Item
::
all
();
$this
->
assertEquals
(
$original
,
$items
->
toArray
());
$this
->
assertEquals
(
$original
[
0
],
$items
[
0
]
->
toArray
());
// with date
$item
=
Item
::
create
(
array
(
'name'
=>
'fork'
,
'type'
=>
'sharp'
));
$item
=
Item
::
create
(
array
(
'name'
=>
'fork'
,
'type'
=>
'sharp'
));
$array
=
$item
->
toArray
();
$array
=
$item
->
toArray
();
$
this
->
assertTrue
(
array_key_exists
(
'created_at'
,
$array
)
);
$
keys
=
array_keys
(
$array
);
sort
(
$keys
);
$this
->
assert
True
(
array_key_exists
(
'updated_at'
,
$array
)
);
$this
->
assert
Equals
(
array
(
'_id'
,
'created_at'
,
'name'
,
'type'
,
'updated_at'
),
$keys
);
$this
->
assertTrue
(
is_string
(
$array
[
'created_at'
]));
$this
->
assertTrue
(
is_string
(
$array
[
'created_at'
]));
$this
->
assertTrue
(
is_string
(
$array
[
'updated_at'
]));
$this
->
assertTrue
(
is_string
(
$array
[
'updated_at'
]));
}
}
...
...
tests/QueryBuilderTest.php
View file @
76781d79
...
@@ -271,11 +271,13 @@ class QueryBuilderTest extends PHPUnit_Framework_TestCase {
...
@@ -271,11 +271,13 @@ class QueryBuilderTest extends PHPUnit_Framework_TestCase {
array
(
'name'
=>
'spoon'
,
'type'
=>
'round'
)
array
(
'name'
=>
'spoon'
,
'type'
=>
'round'
)
));
));
$items
=
DB
::
collection
(
'items'
)
->
distinct
(
'name'
)
->
get
();
$items
=
DB
::
collection
(
'items'
)
->
distinct
(
'name'
)
->
get
();
sort
(
$items
);
$this
->
assertEquals
(
array
(
'knife'
,
'fork'
,
'spoon'
),
$items
);
$this
->
assertEquals
(
3
,
count
(
$items
));
$this
->
assertEquals
(
array
(
'fork'
,
'knife'
,
'spoon'
),
$items
);
$types
=
DB
::
collection
(
'items'
)
->
distinct
(
'type'
)
->
get
();
$types
=
DB
::
collection
(
'items'
)
->
distinct
(
'type'
)
->
get
();
sort
(
$types
);
$this
->
assertEquals
(
array
(
'sharp'
,
'round'
),
$types
);
$this
->
assertEquals
(
2
,
count
(
$types
));
$this
->
assertEquals
(
array
(
'round'
,
'sharp'
),
$types
);
}
}
public
function
testCustomId
()
public
function
testCustomId
()
...
@@ -350,9 +352,11 @@ class QueryBuilderTest extends PHPUnit_Framework_TestCase {
...
@@ -350,9 +352,11 @@ class QueryBuilderTest extends PHPUnit_Framework_TestCase {
));
));
$list
=
DB
::
collection
(
'items'
)
->
lists
(
'name'
);
$list
=
DB
::
collection
(
'items'
)
->
lists
(
'name'
);
$this
->
assertEquals
(
4
,
count
(
$list
));
$this
->
assertEquals
(
array
(
'knife'
,
'fork'
,
'spoon'
,
'spoon'
),
$list
);
$this
->
assertEquals
(
array
(
'knife'
,
'fork'
,
'spoon'
,
'spoon'
),
$list
);
$list
=
DB
::
collection
(
'items'
)
->
lists
(
'type'
,
'name'
);
$list
=
DB
::
collection
(
'items'
)
->
lists
(
'type'
,
'name'
);
$this
->
assertEquals
(
3
,
count
(
$list
));
$this
->
assertEquals
(
array
(
'knife'
=>
'sharp'
,
'fork'
=>
'sharp'
,
'spoon'
=>
'round'
),
$list
);
$this
->
assertEquals
(
array
(
'knife'
=>
'sharp'
,
'fork'
=>
'sharp'
,
'spoon'
=>
'round'
),
$list
);
}
}
...
...
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