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
c2fb55c4
Commit
c2fb55c4
authored
Apr 12, 2014
by
Jens Segers
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Increasing test coverage
parent
b9e4cdae
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
21 additions
and
11 deletions
+21
-11
BelongsToMany.php
src/Jenssegers/Mongodb/Relations/BelongsToMany.php
+0
-10
RelationsTest.php
tests/RelationsTest.php
+21
-0
User.php
tests/models/User.php
+0
-1
No files found.
src/Jenssegers/Mongodb/Relations/BelongsToMany.php
View file @
c2fb55c4
...
@@ -214,14 +214,4 @@ class BelongsToMany extends EloquentBelongsToMany {
...
@@ -214,14 +214,4 @@ class BelongsToMany extends EloquentBelongsToMany {
{
{
return
$this
->
foreignKey
;
return
$this
->
foreignKey
;
}
}
/**
* Get the fully qualified "other key" for the relation.
*
* @return string
*/
public
function
getOtherKey
()
{
return
$this
->
otherKey
;
}
}
}
tests/RelationsTest.php
View file @
c2fb55c4
...
@@ -287,6 +287,11 @@ class RelationsTest extends TestCase {
...
@@ -287,6 +287,11 @@ class RelationsTest extends TestCase {
$photo
=
Photo
::
first
();
$photo
=
Photo
::
first
();
$this
->
assertEquals
(
$photo
->
imageable
->
name
,
$user
->
name
);
$this
->
assertEquals
(
$photo
->
imageable
->
name
,
$user
->
name
);
$user
=
User
::
with
(
'photos'
)
->
find
(
$user
->
_id
);
$relations
=
$user
->
getRelations
();
$this
->
assertTrue
(
array_key_exists
(
'photos'
,
$relations
));
$this
->
assertEquals
(
1
,
$relations
[
'photos'
]
->
count
());
}
}
public
function
testEmbedsManySave
()
public
function
testEmbedsManySave
()
...
@@ -579,4 +584,20 @@ class RelationsTest extends TestCase {
...
@@ -579,4 +584,20 @@ class RelationsTest extends TestCase {
$this
->
assertFalse
(
$user
->
addresses
()
->
contains
(
'123'
));
$this
->
assertFalse
(
$user
->
addresses
()
->
contains
(
'123'
));
}
}
public
function
testEmbedsManyEagerLoading
()
{
$user
=
User
::
create
(
array
(
'name'
=>
'John Doe'
));
$address1
=
$user
->
addresses
()
->
save
(
new
Address
(
array
(
'city'
=>
'New York'
)));
$address2
=
$user
->
addresses
()
->
save
(
new
Address
(
array
(
'city'
=>
'Paris'
)));
$user
=
User
::
find
(
$user
->
id
);
$relations
=
$user
->
getRelations
();
$this
->
assertFalse
(
array_key_exists
(
'addresses'
,
$relations
));
$user
=
User
::
with
(
'addresses'
)
->
find
(
$user
->
id
);
$relations
=
$user
->
getRelations
();
$this
->
assertTrue
(
array_key_exists
(
'addresses'
,
$relations
));
$this
->
assertEquals
(
2
,
$relations
[
'addresses'
]
->
count
());
}
}
}
tests/models/User.php
View file @
c2fb55c4
...
@@ -7,7 +7,6 @@ use Illuminate\Auth\Reminders\RemindableInterface;
...
@@ -7,7 +7,6 @@ use Illuminate\Auth\Reminders\RemindableInterface;
class
User
extends
Eloquent
implements
UserInterface
,
RemindableInterface
{
class
User
extends
Eloquent
implements
UserInterface
,
RemindableInterface
{
protected
$collection
=
'users'
;
protected
$dates
=
array
(
'birthday'
);
protected
$dates
=
array
(
'birthday'
);
protected
static
$unguarded
=
true
;
protected
static
$unguarded
=
true
;
...
...
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