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
79b6230a
Commit
79b6230a
authored
Aug 09, 2014
by
Jens Segers
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Expand test for push/pull
parent
7e8a9cc4
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
6 deletions
+20
-6
Model.php
src/Jenssegers/Mongodb/Model.php
+1
-1
ModelTest.php
tests/ModelTest.php
+19
-5
No files found.
src/Jenssegers/Mongodb/Model.php
View file @
79b6230a
...
...
@@ -449,7 +449,7 @@ abstract class Model extends \Jenssegers\Eloquent\Model {
}
}
$this
->
attributes
[
$column
]
=
$current
;
$this
->
attributes
[
$column
]
=
array_values
(
$current
)
;
$this
->
syncOriginalAttribute
(
$column
);
}
...
...
tests/ModelTest.php
View file @
79b6230a
...
...
@@ -406,14 +406,28 @@ class ModelTest extends TestCase {
public
function
testPushPull
()
{
$user
=
User
::
create
(
array
(
'name'
=>
'John Doe'
,
'tags'
=>
array
()));
$user
=
User
::
create
(
array
(
'name'
=>
'John Doe'
));
$user
->
push
(
'tags'
,
'tag1'
);
$user
->
push
(
'tags'
,
array
(
'tag1'
,
'tag2'
));
$user
->
push
(
'tags'
,
'tag2'
,
true
);
$
result
=
User
::
where
(
'_id'
,
$user
->
_id
)
->
push
(
'tags'
,
'tag1'
);
$
this
->
assertEquals
(
array
(
'tag1'
,
'tag1'
,
'tag2'
),
$user
->
tags
);
$user
=
User
::
where
(
'_id'
,
$user
->
_id
)
->
first
();
$this
->
assertEquals
(
array
(
'tag1'
,
'tag1'
,
'tag2'
),
$user
->
tags
);
$this
->
assertTrue
(
is_int
(
$result
));
$this
->
assertTrue
(
is_array
(
$user
->
tags
));
$this
->
assertEquals
(
1
,
count
(
$user
->
tags
));
$user
->
pull
(
'tags'
,
'tag1'
);
$this
->
assertEquals
(
array
(
'tag2'
),
$user
->
tags
);
$user
=
User
::
where
(
'_id'
,
$user
->
_id
)
->
first
();
$this
->
assertEquals
(
array
(
'tag2'
),
$user
->
tags
);
$user
->
push
(
'tags'
,
'tag3'
);
$user
->
pull
(
'tags'
,
array
(
'tag2'
,
'tag3'
));
$this
->
assertEquals
(
array
(),
$user
->
tags
);
$user
=
User
::
where
(
'_id'
,
$user
->
_id
)
->
first
();
$this
->
assertEquals
(
array
(),
$user
->
tags
);
}
public
function
testRaw
()
...
...
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