我按照http://docs.behat.org/en/latest/quick_intro_pt1.html上的教程进行了操作。 但是,当我实现该功能并运行时,教程中会说我应该收到错误:“致命错误:找不到类'Shelf'。” 我没有得到那个错误。只有用户故事的输出:
$ vendor / bin / behat
特色:产品篮 为了购买产品 作为客户 我需要能够将有趣的产品放入购物篮
规则: - 增值税是20% - 低于10英镑的篮子交付是3英镑 - 超过10英镑的篮子交付是2英镑
class FeatureContext implements SnippetAcceptingContext
{
private $shelf;
private $basket;
public function __construct()
{
$this->shelf = new Shelf();
$this->basket = new Basket($this->shelf);
}
/**
* @Given there is a :product, which costs £:price
*/
public function thereIsAWhichCostsPs($product, $price)
{
$this->shelf->setProductPrice($product, floatval($price));
}
看起来,当我使用构造函数发生这种情况时,behat的输出只是用户故事而不是测试。 即使我在函数中放了exit(),也不会发生exit()。 我在PHPStorm中尝试了不同的项目。它始终是一样的。
我想知道如何得到预期的错误:“致命错误:找不到类'货架'。” 我正在使用behat 3.0.14:我使用了composer来安装它。