Closed sudkumar closed 2 years ago
Can you include a test on the example that fails?
@frederikbosch I have reverted the implementation and added a test to show the failure.
@sudkumar The tests pass. So the question is: why does it fail on your end?
Hmmm.. interesting 🤔.
BTW, there are two directories of tests. composer test
executes from specs dir.
What is inside $matches when you execute the test? Can you show the result of the following var_dump here?
var_dump($iso, $matches);
Here it is.
> var_dump($iso, $matches);
string(16) "EUR/USD 1.250000"
array(4) {
[0]=>
string(16) "EUR/USD 1.250000"
[1]=>
string(3) "EUR"
[2]=>
string(3) "USD"
[3]=>
string(8) "1.250000"
}
System:
Here is the exception when running composer test
---- broken examples
Money/Currencies/BitcoinCurrencies
32 ! is iterable
exception [err:AssertionError("assert(is_array($subject))")] has been thrown.
Money/Currencies/CurrencyList
45 ! is iterable
exception [err:AssertionError("assert(is_array($subject))")] has been thrown.
Money/CurrencyPair
30 ! parses an iso string
exception [err:AssertionError("assert(is_numeric($matches[2]))")] has been thrown.
21 specs
108 examples (105 passed, 3 broken)
150ms
What do you get with var_dump($iso, $matches);
?
Am I missing something obvious here!! 😄
@sudkumar Thank you very much, I have fixed the issue. zend.assertions
was not enabled in CI. That's why it was not throwing. Your observation was correct.
So glad we found the issue. Thank you for looking into it.
With iso as
EUR/USD 1.2500
, we will get$matches = ['EUR/USD 1.2500', 'EUR', 'USD', '1.2500']
afterpref_match
but the assertion expects$matches[2]
to be numeric which seems to be incorrect. Just updated the assertion to not expect an empty string.fixes #695