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
25a258a5
Commit
25a258a5
authored
Aug 29, 2016
by
Pooya Parsa
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
5.3 UnitTests WIP
parent
cd75b176
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
44 additions
and
44 deletions
+44
-44
EmbeddedRelationsTest.php
tests/EmbeddedRelationsTest.php
+35
-35
ModelTest.php
tests/ModelTest.php
+2
-2
QueryBuilderTest.php
tests/QueryBuilderTest.php
+7
-7
No files found.
tests/EmbeddedRelationsTest.php
View file @
25a258a5
This diff is collapsed.
Click to expand it.
tests/ModelTest.php
View file @
25a258a5
...
...
@@ -156,8 +156,8 @@ class ModelTest extends TestCase
$all
=
User
::
all
();
$this
->
assertEquals
(
2
,
count
(
$all
));
$this
->
assertContains
(
'John Doe'
,
$all
->
lists
(
'name'
));
$this
->
assertContains
(
'Jane Doe'
,
$all
->
lists
(
'name'
));
$this
->
assertContains
(
'John Doe'
,
$all
->
pluck
(
'name'
));
$this
->
assertContains
(
'Jane Doe'
,
$all
->
pluck
(
'name'
));
}
public
function
testFind
()
...
...
tests/QueryBuilderTest.php
View file @
25a258a5
...
...
@@ -29,7 +29,7 @@ class QueryBuilderTest extends TestCase
public
function
testNoDocument
()
{
$items
=
DB
::
collection
(
'items'
)
->
where
(
'name'
,
'nothing'
)
->
get
();
$items
=
DB
::
collection
(
'items'
)
->
where
(
'name'
,
'nothing'
)
->
get
()
->
toArray
()
;
$this
->
assertEquals
([],
$items
);
$item
=
DB
::
collection
(
'items'
)
->
where
(
'name'
,
'nothing'
)
->
first
();
...
...
@@ -288,12 +288,12 @@ class QueryBuilderTest extends TestCase
[
'name'
=>
'spoon'
,
'type'
=>
'round'
],
]);
$items
=
DB
::
collection
(
'items'
)
->
distinct
(
'name'
)
->
get
();
$items
=
DB
::
collection
(
'items'
)
->
distinct
(
'name'
)
->
get
()
->
toArray
()
;
sort
(
$items
);
$this
->
assertEquals
(
3
,
count
(
$items
));
$this
->
assertEquals
([
'fork'
,
'knife'
,
'spoon'
],
$items
);
$types
=
DB
::
collection
(
'items'
)
->
distinct
(
'type'
)
->
get
();
$types
=
DB
::
collection
(
'items'
)
->
distinct
(
'type'
)
->
get
()
->
toArray
()
;
sort
(
$types
);
$this
->
assertEquals
(
2
,
count
(
$types
));
$this
->
assertEquals
([
'round'
,
'sharp'
],
$types
);
...
...
@@ -357,7 +357,7 @@ class QueryBuilderTest extends TestCase
[
'name'
=>
'John Doe'
,
'age'
=>
25
],
]);
$age
=
DB
::
collection
(
'users'
)
->
where
(
'name'
,
'John Doe'
)
->
pluck
(
'age'
);
$age
=
DB
::
collection
(
'users'
)
->
where
(
'name'
,
'John Doe'
)
->
pluck
(
'age'
)
->
toArray
()
;
$this
->
assertEquals
([
25
],
$age
);
}
...
...
@@ -370,16 +370,16 @@ class QueryBuilderTest extends TestCase
[
'name'
=>
'spoon'
,
'type'
=>
'round'
,
'amount'
=>
14
],
]);
$list
=
DB
::
collection
(
'items'
)
->
lists
(
'name'
);
$list
=
DB
::
collection
(
'items'
)
->
pluck
(
'name'
)
->
toArray
(
);
sort
(
$list
);
$this
->
assertEquals
(
4
,
count
(
$list
));
$this
->
assertEquals
([
'fork'
,
'knife'
,
'spoon'
,
'spoon'
],
$list
);
$list
=
DB
::
collection
(
'items'
)
->
lists
(
'type'
,
'name'
);
$list
=
DB
::
collection
(
'items'
)
->
pluck
(
'type'
,
'name'
)
->
toArray
(
);
$this
->
assertEquals
(
3
,
count
(
$list
));
$this
->
assertEquals
([
'knife'
=>
'sharp'
,
'fork'
=>
'sharp'
,
'spoon'
=>
'round'
],
$list
);
$list
=
DB
::
collection
(
'items'
)
->
lists
(
'name'
,
'_id'
);
$list
=
DB
::
collection
(
'items'
)
->
pluck
(
'name'
,
'_id'
)
->
toArray
(
);
$this
->
assertEquals
(
4
,
count
(
$list
));
$this
->
assertEquals
(
24
,
strlen
(
key
(
$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