-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
β
π Add tests and fix bugs for RelationsInModelFinder
- Loading branch information
Showing
3 changed files
with
49 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<?php | ||
|
||
namespace MathieuTu\JsonImport\Tests\Helpers; | ||
|
||
use MathieuTu\JsonImport\Helpers\RelationsInModelFinder; | ||
|
||
class RelationsInModelFinderTest extends \PHPUnit\Framework\TestCase | ||
{ | ||
public function testhasOneOrMany() | ||
{ | ||
$this->assertEquals(['foos', 'bar'], RelationsInModelFinder::hasOneOrMany(new MyModel())); | ||
} | ||
} | ||
|
||
class MyModel extends \Illuminate\Database\Eloquent\Model | ||
{ | ||
public function foos() | ||
{ | ||
return $this->hasMany('foo'); | ||
} | ||
|
||
public function bar() | ||
{ | ||
return $this->hasOne('bar'); | ||
} | ||
|
||
public function baz() | ||
{ | ||
return $this->hasManyThrough('baz', 'bar'); | ||
} | ||
|
||
public function notARelation() | ||
{ | ||
return 'this is not a relation!'; | ||
} | ||
|
||
public function parent() | ||
{ | ||
return $this->belongsTo('parent'); | ||
} | ||
|
||
} |