Skip to content

Commit

Permalink
Re-add test
Browse files Browse the repository at this point in the history
  • Loading branch information
staudenmeir committed Mar 6, 2018
1 parent a738129 commit 8bfcf52
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions tests/Database/DatabaseEloquentPivotTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,16 @@ public function testMutatorsAreCalledFromConstructor()
$this->assertTrue($pivot->getMutatorCalled());
}

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

$pivot = DatabaseEloquentPivotTestJsonCastStub::fromRawAttributes($parent, ['foo' => json_encode(['name' => 'Taylor'])], 'table', true);

$this->assertEquals(['name' => 'Taylor'], $pivot->foo);
}

public function testFromRawAttributesDoesNotMutate()
{
$parent = m::mock('Illuminate\Database\Eloquent\Model[getConnectionName]');
Expand Down Expand Up @@ -135,3 +145,10 @@ public function getMutatorCalled()
return $this->mutatorCalled;
}
}

class DatabaseEloquentPivotTestJsonCastStub extends \Illuminate\Database\Eloquent\Relations\Pivot
{
protected $casts = [
'foo' => 'json',
];
}

0 comments on commit 8bfcf52

Please sign in to comment.