3
說我有兩個模型,從Eloquent
延伸,它們相互關聯。我可以嘲笑關係嗎?laravel 4嘲笑模擬模型關係
即:
class Track extends Eloquent {
public function courses()
{
return $this->hasMany('Course');
}
}
class Course extends Eloquent {
public function track()
{
return $this->belongsTo('Track');
}
}
在MyTest的,我想通過調用跟蹤屬性,而不是賽道實例(我不創造過程的模擬,並返回軌道,的一個實例要查詢生成器)
use \Mockery as m;
class MyTest extends TestCase {
public function setUp()
{
$track = new Track(array('title' => 'foo'));
$course = m::mock('Course[track]', array('track' => $track));
$track = $course->track // <-- This should return my track object
}
}