Skip to content

Commit

Permalink
Add some tests to ensure mass-assignment works
Browse files Browse the repository at this point in the history
  • Loading branch information
rmasters committed Dec 10, 2013
1 parent 9f2ccb7 commit 8c62ff8
Showing 1 changed file with 21 additions and 2 deletions.
23 changes: 21 additions & 2 deletions tests/Filter/HasFiltersTest.php
Expand Up @@ -6,6 +6,8 @@ class Address extends \Illuminate\Database\Eloquent\Model
{
use HasFilters;

protected $fillable = ['line1', 'city', 'postcode', 'country'];

protected $input = array(
'line1' => 'trim',
'city' => 'trim',
Expand Down Expand Up @@ -68,5 +70,22 @@ public function testOutputs()

$this->assertEquals('LONDON', $this->address->city);
$this->assertEquals('ENGLAND_OUTPUT', $this->address->country);
}
}
}

public function testMassAssignmentFill()
{
$this->address->fill(array(
'country' => ' england '
));

$raw = $this->address->getAttributes();
$this->assertEquals('england_input', $raw['country']);
}

public function testMassAssignmentConstructor()
{
$this->address = new Address(array('postcode' => 'sw1 1aa '));
$raw = $this->address->getAttributes();
$this->assertEquals('SW1 1AA', $raw['postcode']);
}
}

0 comments on commit 8c62ff8

Please sign in to comment.