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
b45d3034
Commit
b45d3034
authored
Aug 24, 2013
by
Jens Segers
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Tweaked tests
parent
e44534db
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
40 additions
and
16 deletions
+40
-16
ModelTest.php
tests/ModelTest.php
+40
-0
QueryTest.php
tests/QueryTest.php
+0
-16
No files found.
tests/ModelTest.php
View file @
b45d3034
...
...
@@ -10,6 +10,7 @@ class ModelTest extends PHPUnit_Framework_TestCase {
User
::
truncate
();
Soft
::
truncate
();
Book
::
truncate
();
Item
::
truncate
();
}
public
function
testNewModel
()
...
...
@@ -120,6 +121,31 @@ class ModelTest extends PHPUnit_Framework_TestCase {
$this
->
assertEquals
(
35
,
$check
->
age
);
}
public
function
testGet
()
{
User
::
insert
(
array
(
array
(
'name'
=>
'John Doe'
),
array
(
'name'
=>
'Jane Doe'
)
));
$users
=
User
::
get
();
$this
->
assertEquals
(
2
,
count
(
$users
));
$this
->
assertInstanceOf
(
'Illuminate\Database\Eloquent\Collection'
,
$users
);
$this
->
assertInstanceOf
(
'Jenssegers\Mongodb\Model'
,
$users
[
0
]);
}
public
function
testFirst
()
{
User
::
insert
(
array
(
array
(
'name'
=>
'John Doe'
),
array
(
'name'
=>
'Jane Doe'
)
));
$user
=
User
::
get
()
->
first
();
$this
->
assertInstanceOf
(
'Jenssegers\Mongodb\Model'
,
$user
);
$this
->
assertEquals
(
'John Doe'
,
$user
->
name
);
}
/**
* @expectedException Illuminate\Database\Eloquent\ModelNotFoundException
*/
...
...
@@ -225,4 +251,18 @@ class ModelTest extends PHPUnit_Framework_TestCase {
$this
->
assertEquals
(
1
,
$sharp
->
count
());
}
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
());
}
}
\ No newline at end of file
tests/QueryTest.php
View file @
b45d3034
...
...
@@ -21,22 +21,6 @@ class QueryTest extends PHPUnit_Framework_TestCase {
User
::
truncate
();
}
public
function
testGet
()
{
$users
=
User
::
get
();
$this
->
assertEquals
(
9
,
count
(
$users
));
$this
->
assertInstanceOf
(
'Illuminate\Database\Eloquent\Collection'
,
$users
);
$this
->
assertInstanceOf
(
'Jenssegers\Mongodb\Model'
,
$users
[
0
]);
}
public
function
testFirst
()
{
$user
=
User
::
get
()
->
first
();
$this
->
assertInstanceOf
(
'Jenssegers\Mongodb\Model'
,
$user
);
$this
->
assertEquals
(
'John Doe'
,
$user
->
name
);
}
public
function
testWhere
()
{
$users
=
User
::
where
(
'age'
,
35
)
->
get
();
...
...
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