Skip to content

Commit

Permalink
Make newBuilder() method on Model public
Browse files Browse the repository at this point in the history
  • Loading branch information
robgridley committed Jan 3, 2020
1 parent f7ba6ae commit ae1c047
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Model.php
Original file line number Diff line number Diff line change
Expand Up @@ -657,7 +657,7 @@ protected function isCompoundKey($key)
*
* @return Builder
*/
protected function newBuilder()
public function newBuilder()
{
return new Builder($this);
}
Expand Down
3 changes: 3 additions & 0 deletions tests/ModelTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ public function testHasMany()
$model = new Model($client, 'Job');
$model->job = '12345';
$related = Mockery::mock(Model::class);
$related->shouldReceive('newBuilder')->passthru();
$client->shouldReceive('model')->with('JobPart')->once()->andReturn($related);
$builder = $model->hasMany('JobPart', 'job');
$this->assertInstanceOf(Builder::class, $builder);
Expand All @@ -138,6 +139,7 @@ public function testHasManyWithCompoundKey()
$model = new Model($client, 'JobPart');
$model->primaryKey = '12345:01';
$related = Mockery::mock(Model::class);
$related->shouldReceive('newBuilder')->passthru();
$client->shouldReceive('model')->with('JobMaterial')->once()->andReturn($related);
$builder = $model->hasMany('JobMaterial', 'job:jobPart');
$this->assertInstanceOf(Builder::class, $builder);
Expand All @@ -155,6 +157,7 @@ public function testMorphMany()
$model = new Model($client, 'Job');
$model->job = '12345';
$related = Mockery::mock(Model::class);
$related->shouldReceive('newBuilder')->passthru();
$client->shouldReceive('model')->with('FileAttachment')->once()->andReturn($related);
$builder = $model->morphMany('FileAttachment');
$this->assertInstanceOf(Builder::class, $builder);
Expand Down

0 comments on commit ae1c047

Please sign in to comment.