device-detector icon indicating copy to clipboard operation
device-detector copied to clipboard

Make tests compatible with newer phpunit versions

Open williamdes opened this issue 1 year ago • 18 comments

Description:

  • Non breaking changes for newer phpunit versions (running on PHPUnit 11.1.3 at Debian)
  • Fixing the parameter names for newer PHP versions (Error: Unknown named parameter $check)
  • Upgrade GitHub actions
  • Allow newer PHPunit versions up to 12
  • Fix deprecations in tests

Review

williamdes avatar Jul 02 '24 17:07 williamdes

Variable "user_agent" is not in valid camel caps format

Can someone give me the best way to fix this. Not by changing the variable name for sure 😄

williamdes avatar Jul 02 '24 17:07 williamdes

Why should the variable name need to contain a _? What is the problem with useragent? This doesn't comply with our coding style.

sgiehl avatar Jul 02 '24 17:07 sgiehl

Why should the variable name need to contain a _? What is the problem with useragent? This doesn't comply with our coding style.

Nope, because as you can see getTypeMethodFixtures is directly fed from \Spyc::YAMLLoad($fixturePath); So the variable names should match the yaml data key names

One solution is that I can put an array map to re-format the key name

williamdes avatar Jul 02 '24 18:07 williamdes

Hello @sgiehl

What is the best path for me to get this one merged ?

williamdes avatar Jul 11 '24 10:07 williamdes

Weird CI failures, new commits broke something or is it my diff ?

williamdes avatar Jul 17 '24 14:07 williamdes

Not sure, but probably the PHPUnit workflow should be updated too so it can use composer update? Now it tries to run PHPUnit 11 on PHP 7.2.

I installed PHP 7.2.5 (this is the lowest version required by symfony/yaml 5.1.7) and the tests pass.

liviuconcioiu avatar Jul 17 '24 16:07 liviuconcioiu

Not sure, but probably the PHPUnit workflow should be updated too so it can use composer update? Now it tries to run PHPUnit 11 on PHP 7.2.

I installed PHP 7.2.5 (this is the lowest version required by symfony/yaml 5.1.7) and the tests pass.

Oh snap, let's revert that part. I only need the PHP diff anyway PRs like #7570 can update that

williamdes avatar Jul 18 '24 09:07 williamdes

I dropped the last commit, it should help

williamdes avatar Jul 18 '24 09:07 williamdes

@williamdes can you fix the conflicts? And also you should also add static to getFixturesDeviceTypeFromClientHints. It was added after your PR.

liviuconcioiu avatar Dec 20 '24 21:12 liviuconcioiu

I did some ajustements as I am quite sure the ignore should not have been used for all versions and this way.

williamdes avatar Dec 22 '24 19:12 williamdes

Run local php vendor/bin/phpcbf for fix phpcs

sanchezzzhak avatar Dec 24 '24 05:12 sanchezzzhak

Run local php vendor/bin/phpcbf for fix phpcs

Unrelated, see CI log

PHP Parse error: syntax error, unexpected '|', expecting variable (T_VARIABLE) in /home/runner/work/device-detector/device-detector/vendor/phpunit/phpunit/src/Framework/Assert/Functions.php on line 83

Probably some issue with the php version installed

Edit: pushed a fix, maybe it will work

williamdes avatar Dec 24 '24 20:12 williamdes

@williamdes is it possible to update the workflow so it does look like this?

ok

Right now it looks like this:

notok

Those are missing (pending but aren't running):

PHPUnit (windows-latest, 8.4) PHPUnit (macos-latest, 8.4)

2

liviuconcioiu avatar Mar 25 '25 05:03 liviuconcioiu

@williamdes is it possible to update the workflow so it does look like this?

Not really (I have no options to change the text), can it be merged as is @sgiehl ? I have one more PR for phpunit 12 afterwards

williamdes avatar Apr 12 '25 10:04 williamdes

Hi @sgiehl Can you check this one please ?

williamdes avatar May 16 '25 14:05 williamdes