You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
<?php
// features/bootstrap/FeatureContext.php
use Behat\Behat\Tester\Exception\PendingException;
use Behat\Behat\Context\SnippetAcceptingContext;
use Behat\Gherkin\Node\PyStringNode;
use Behat\Gherkin\Node\TableNode;
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));
}
/**
* @When I add the :product to the basket
*/
public function iAddTheToTheBasket($product)
{
$this->basket->addProduct($product);
}
/**
* @Then I should have :count product(s) in the basket
*/
public function iShouldHaveProductInTheBasket($count)
{
PHPUnit_Framework_Assert::assertCount(
intval($count),
$this->basket
);
}
/**
* @Then the overall basket price should be £:price
*/
public function theOverallBasketPriceShouldBePs($price)
{
PHPUnit_Framework_Assert::assertSame(
floatval($price),
$this->basket->getTotalPrice()
);
}
}
First error is Fatal error: Class 'PHPUnit_Framework_Assert' not found (Behat\Testwork\Call\Exception\FatalThrowableError)
This is the case because PHPUnit_Framework_Assert used in method theOverallBasketPriceShouldBePs and else where is not defined or imported, this can be solved by adding the line
use PHPUnit\Framework\Assert as PHPUnit_Framework_Assert;
Just below the import statements
I would like to work on this issue if it is confirmed
Note I installed PHPUnit with composer require --dev phpunit/phpunit
The text was updated successfully, but these errors were encountered:
I am following the BDD examples on Quick guide and I ran into some errors this is what my composer.json looks like
Code sample from quick start page
First error is
Fatal error: Class 'PHPUnit_Framework_Assert' not found (Behat\Testwork\Call\Exception\FatalThrowableError)
This is the case because
PHPUnit_Framework_Assert
used in methodtheOverallBasketPriceShouldBePs
and else where is not defined or imported, this can be solved by adding the lineuse PHPUnit\Framework\Assert as PHPUnit_Framework_Assert;
Just below the import statements
I would like to work on this issue if it is confirmed
Note I installed PHPUnit with
composer require --dev phpunit/phpunit
The text was updated successfully, but these errors were encountered: