Skip to content

Commit

Permalink
[5.5] Remove attribute filling from pivot model #23401 (#23554)
Browse files Browse the repository at this point in the history
* Remove attribute filling from pivot model

* Re-add test
  • Loading branch information
sylvain-gaffie-sociomantic authored and taylorotwell committed Mar 15, 2018
1 parent 8d6b778 commit 260a3f8
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Illuminate/Database/Eloquent/Relations/Pivot.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public static function fromAttributes(Model $parent, $attributes, $table, $exist
*/
public static function fromRawAttributes(Model $parent, $attributes, $table, $exists = false)
{
$instance = static::fromAttributes($parent, $attributes, $table, $exists);
$instance = static::fromAttributes($parent, [], $table, $exists);

$instance->setRawAttributes($attributes, true);

Expand Down
10 changes: 10 additions & 0 deletions tests/Database/DatabaseEloquentPivotTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,16 @@ public function testFromRawAttributesDoesNotDoubleMutate()
$this->assertEquals(['name' => 'Taylor'], $pivot->foo);
}

public function testFromRawAttributesDoesNotMutate()
{
$parent = m::mock('Illuminate\Database\Eloquent\Model[getConnectionName]');
$parent->shouldReceive('getConnectionName')->once()->andReturn('connection');

$pivot = DatabaseEloquentPivotTestMutatorStub::fromRawAttributes($parent, ['foo' => 'bar'], 'table', true);

$this->assertFalse($pivot->getMutatorCalled());
}

public function testPropertiesUnchangedAreNotDirty()
{
$parent = m::mock('Illuminate\Database\Eloquent\Model[getConnectionName]');
Expand Down

0 comments on commit 260a3f8

Please sign in to comment.