1 | <?php |
||
33 | class FeatureContext implements Context |
||
34 | { |
||
35 | protected $engine; |
||
36 | |||
37 | /** @var Customer */ |
||
38 | protected $customer; |
||
39 | /** |
||
40 | * @var \hiqdev\php\billing\price\PriceInterface|\hiqdev\php\billing\charge\FormulaChargeModifierTrait |
||
41 | * |
||
42 | * TODO: FormulaChargeModifierTrait::setFormula() must be moved to interface |
||
43 | */ |
||
44 | protected $price; |
||
45 | |||
46 | /** @var string */ |
||
47 | protected $formula; |
||
48 | |||
49 | /** |
||
50 | * @var \hiqdev\php\billing\action\ActionInterface|\hiqdev\php\billing\action\AbstractAction |
||
51 | */ |
||
52 | protected $action; |
||
53 | /** |
||
54 | * @var ChargeInterface[] |
||
55 | */ |
||
56 | protected $charges; |
||
57 | |||
58 | /** @var \Money\MoneyParser */ |
||
59 | protected $moneyParser; |
||
60 | |||
61 | /** @var string */ |
||
62 | protected $expectedError; |
||
63 | |||
64 | /** |
||
65 | * Initializes context. |
||
66 | */ |
||
67 | public function __construct() |
||
72 | |||
73 | /** |
||
74 | * @Given /(\S+) (\S+) price is ([0-9.]+) (\w+) per (\w+)/ |
||
75 | */ |
||
76 | public function priceIs($target, $type, $sum, $currency, $unit) |
||
84 | |||
85 | /** |
||
86 | * @Given /action is (\S+) (\w+) ([0-9.]+) (\S+)/ |
||
87 | */ |
||
88 | public function actionIs($target, $type, $amount, $unit) |
||
96 | |||
97 | /** |
||
98 | * @Given /formula is (.+)/ |
||
99 | * @param string $formula |
||
100 | */ |
||
101 | public function formulaIs(string $formula): void |
||
105 | |||
106 | protected function getFormulaEngine() |
||
114 | |||
115 | /** |
||
116 | * @When /action date is ([0-9.-]+)/ |
||
117 | * @param string $date |
||
118 | * @throws \Exception |
||
119 | */ |
||
120 | public function actionDateIs(string $date): void |
||
124 | |||
125 | /** |
||
126 | * @Then /^error is (.+)$/ |
||
127 | * @param string $error |
||
128 | */ |
||
129 | public function errorIs(string $error): void |
||
133 | |||
134 | /** |
||
135 | * @Then /^(\w+) charge is $/ |
||
136 | * @param string $numeral |
||
137 | */ |
||
138 | public function emptyCharge(string $numeral): void |
||
142 | |||
143 | /** |
||
144 | * @Then /^(\w+) charge is (\S+) +([0-9.]+) ([A-Z]{3})$/ |
||
145 | */ |
||
146 | public function chargeWithSum($numeral, $type = null, $sum = null, $currency = null): void |
||
150 | |||
151 | /** |
||
152 | * @Then /^(\w+) charge is (\S+) +([0-9.]+) ([A-Z]{3}) reason (.+)/ |
||
153 | */ |
||
154 | public function chargeWithReason($numeral, $type = null, $sum = null, $currency = null, $reason = null): void |
||
158 | |||
159 | public function chargeIs($numeral, $type = null, $sum = null, $currency = null, $reason = null): void |
||
167 | |||
168 | /** |
||
169 | * @When /^calculating charges$/ |
||
170 | */ |
||
171 | public function calculateCharges(): void |
||
178 | |||
179 | public function expectError(Closure $closure): void |
||
191 | |||
192 | protected function isExpectedError(\Exception $e): bool |
||
196 | |||
197 | protected function startsWith(string $string, string $prefix = null): bool |
||
201 | |||
202 | /** |
||
203 | * @param ChargeInterface|null $charge |
||
204 | * @param string|null $type |
||
205 | * @param string|null $sum |
||
206 | * @param string|null $currency |
||
207 | * @param string|null $reason |
||
208 | */ |
||
209 | public function assertCharge($charge, $type, $sum, $currency, $reason): void |
||
224 | |||
225 | private function ensureNo(string $numeral): int |
||
235 | } |
||
236 |
It seems like the method you are trying to call exists only in some of the possible types.
Let’s take a look at an example:
Available Fixes
Add an additional type-check:
Only allow a single type to be passed if the variable comes from a parameter: