| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -49,7 +49,8 @@ public function __construct(Model $parent, $attributes, $table, $exists = false) | |||
| 49 | 49 | // The pivot model is a "dynamic" model since we will set the tables dynamically | |
| 50 | 50 | // for the instance. This allows it work for any intermediate tables for the | |
| 51 | 51 | // many to many relationship that are defined by this developer's classes. | |
| 52 | - $this->setRawAttributes($attributes, true); | ||
| 52 | + $this->forceFill($attributes); | ||
| 53 | + $this->syncOriginal(); | ||
| 53 | 54 | ||
| 54 | 55 | $this->setTable($table); | |
| 55 | 56 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -23,6 +23,15 @@ public function testPropertiesAreSetCorrectly() | |||
| 23 | 23 | $this->assertTrue($pivot->exists); | |
| 24 | 24 | } | |
| 25 | 25 | ||
| 26 | + public function testMutatorsAreCalledFromConstructor() { | ||
| 27 | + $parent = m::mock('Illuminate\Database\Eloquent\Model[getConnectionName]'); | ||
| 28 | + $parent->shouldReceive('getConnectionName')->once()->andReturn('connection'); | ||
| 29 | + | ||
| 30 | + $pivot = new DatabaseEloquentPivotTestMutatorStub($parent, array('foo' => 'bar'), 'table', true); | ||
| 31 | + | ||
| 32 | + $this->assertTrue($pivot->getMutatorCalled()); | ||
| 33 | + } | ||
| 34 | + | ||
| 26 | 35 | ||
| 27 | 36 | public function testPropertiesUnchangedAreNotDirty() | |
| 28 | 37 | { | |
@@ -99,3 +108,16 @@ public function getDates() | |||
| 99 | 108 | return array(); | |
| 100 | 109 | } | |
| 101 | 110 | } | |
| 111 | + | ||
| 112 | + class DatabaseEloquentPivotTestMutatorStub extends Illuminate\Database\Eloquent\Relations\Pivot { | ||
| 113 | + private $mutatorCalled = false; | ||
| 114 | + | ||
| 115 | + public function setFooAttribute($value) { | ||
| 116 | + $this->mutatorCalled = true; | ||
| 117 | + return $value; | ||
| 118 | + } | ||
| 119 | + | ||
| 120 | + public function getMutatorCalled() { | ||
| 121 | + return $this->mutatorCalled; | ||
| 122 | + } | ||
| 123 | + } | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments