-1

Recently I was refactoring tests in my application and broke one of them. But I can reproduce problem only if I run entire set of tests. If I run only one class with problem test, all works fine.

Problem row:

$float_value = (float)$string_value;

How does it looks when only one test class executed (ok case):

enter image description here

How does it looks when problem appears:

enter image description here

And then I have a problem inserting that value in database, because database doesn't agree that value is numeric.

What does mean that "comma and dot presented both"?

I tried find information about comma as fraction part separator and appearing dot, but failed.

Does we have any settings for such behavior? Because it is can be reproduced only if other tests was executed before.

Roberto Caboni
  • 7,252
  • 10
  • 25
  • 39
Hayate
  • 653
  • 1
  • 9
  • 25
  • Describe your problem using a code example so that it can be reproduced with PHP independently of test environments, own classes and databases. – jspit Aug 04 '20 at 06:04
  • @jspit it is obviously trickiest part. Only way I can reproduce it - run entire set of my tests. – Hayate Aug 04 '20 at 06:07
  • I think the problem is in the development- / testenvironment or the database and has nothing to do with PHP. – jspit Aug 04 '20 at 06:21
  • @jspit I just want remind that we discussing PHP's type casting operator. I don't think that database anyhow can affect that operator. If it is environment - that exactly my question - how can we change behaviour of PHP type casting operator in way described above? – Hayate Aug 04 '20 at 07:59

1 Answers1

0

So I found a problem and solve it. Reason was setlocale() called in one of tested methods that set decimal point to comma.

Hayate
  • 653
  • 1
  • 9
  • 25