Skip to content

Commit

Permalink
Revert "Update MorphTo tests to account for new withDefault() behavior"
Browse files Browse the repository at this point in the history
This reverts commit ea6ca49.
  • Loading branch information
driesvints committed Feb 7, 2019
1 parent 350db07 commit ae98e75
Showing 1 changed file with 9 additions and 15 deletions.
24 changes: 9 additions & 15 deletions tests/Database/DatabaseEloquentMorphToTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,9 @@ public function testMorphToWithDefault()

$newModel = new EloquentMorphToModelStub;

$this->assertEquals($newModel, $relation->getResults());
$this->related->shouldReceive('newInstance')->once()->andReturn($newModel);

$this->assertSame($newModel, $relation->getResults());
}

public function testMorphToWithDynamicDefault()
Expand All @@ -65,13 +67,12 @@ public function testMorphToWithDynamicDefault()
$this->builder->shouldReceive('first')->once()->andReturnNull();

$newModel = new EloquentMorphToModelStub;
$newModel->username = 'taylor';

$result = $relation->getResults();
$this->related->shouldReceive('newInstance')->once()->andReturn($newModel);

$this->assertEquals($newModel, $result);
$this->assertSame($newModel, $relation->getResults());

$this->assertSame('taylor', $result->username);
$this->assertSame('taylor', $newModel->username);
}

public function testMorphToWithArrayDefault()
Expand All @@ -81,13 +82,12 @@ public function testMorphToWithArrayDefault()
$this->builder->shouldReceive('first')->once()->andReturnNull();

$newModel = new EloquentMorphToModelStub;
$newModel->username = 'taylor';

$result = $relation->getResults();
$this->related->shouldReceive('newInstance')->once()->andReturn($newModel);

$this->assertEquals($newModel, $result);
$this->assertSame($newModel, $relation->getResults());

$this->assertSame('taylor', $result->username);
$this->assertSame('taylor', $newModel->username);
}

public function testAssociateMethodSetsForeignKeyAndTypeOnModel()
Expand Down Expand Up @@ -165,10 +165,4 @@ public function getRelation($parent = null, $builder = null)
class EloquentMorphToModelStub extends Model
{
public $foreign_key = 'foreign.value';

public $table = 'eloquent_morph_to_model_stubs';

public function relation() {
return $this->morphTo();
}
}

0 comments on commit ae98e75

Please sign in to comment.