Your original attribute, #[Given('product :arg1 with price :arg2')], did not account for the double quotes around the product name "A book".
<?php
use Behat\Behat\Context\Context;
use Behat\Gherkin\Node\PyStringNode;
use Behat\Gherkin\Node\TableNode;
use PHPUnit\Framework\Assert;
class FeatureContext implements Context
{
public function __construct()
{
}
#[Given('product ":arg1" with price :arg2')]
public function productWithPrice($arg1, $arg2): void
{
// Now you can access the arguments correctly.
// $arg1 will be "A book" (without the quotes)
// $arg2 will be 5
}
}
output
php vendor/bin/behat
Feature: Product basket
In order to buy products
As a customer
I need to be able to put interesting products into a basket
Scenario: Buying a single product under 10 dollars
Given product "A book" with price 5
# The step is now found and matched.
1 scenario (1 passed)
1 step (1 passed)
0m0.00s (4.01Mb)