【发布时间】:2014-12-15 17:27:46
【问题描述】:
如果我无法访问或使用任何 Eloquent 方法,那么使用 PHPSpec 有什么意义?
例如:($this 指的是 Eloquent Product 模型)
function it_removes_property(PropertyValueInterface $property)
{
$this->addProperty($property);
$this->properties->shouldHaveCount(1);
$this->removeProperty($property);
$this->properties->shouldHaveCount(0);
}
这将不起作用,因为在 addProperty 和 removeProperty 方法中调用了各种 Eloquent Collection 和 Model 函数,似乎 PHPSpec 无法处理这个问题,即使所有这些类都包含在 use 语句中。
我注意到 Jeffery Way 在 Laracasts 上的屏幕投射中,他从不使用真正的 Eloquent 模型。他只使用普通的 PHP 对象。那有什么意义呢?那不是真实的世界。
这也与正确引用 eloquent 模型类无关,因为我已经在这样做了use Illuminate\Database\Eloquent\Model;
我也从不使用外墙。所以它也不是。
【问题讨论】:
标签: php testing laravel bdd phpspec