#Weird state/cache behaviour noticed in tests after Laravel/Framework upgrade v9 -> v10 using Shift

5 messages · Page 1 of 1 (latest)

pulsar basin
#

Hi all,

Just upgraded Laravel from v9 to v10 using Shift. Also upgraded PHPUnit to 10 and Pest to v2.

I've noticed some strange behaviour in my tests after the upgrade:

Example 1:
I've set a rate limit on throttle of 3 attempts on /example-route . If I run my tests a few times, I'll get a 429 error indicating too many requests. I expect the count to reset after each tests like it did before.

Example 2:
I've got ExampleController which uses Cache::remember() to retrieve data from cache and otherwise retrieve the latest value. I've noticed the cache is remembered and not resetted after each test. For example: if I use

return Cache::remember('example', 1800, fn () => 'Hi');

Run my test, change Hi to Bye and run the test again, I get Hi while I expect Bye
If I add Cache::flush() to my test, i get Bye and it works as expected

I've already checked .env.testing and phpunit.xml for APP_ENV.

I'm running the tests in a Docker container which initially exports .env

near moss
#

Sounds like you're now using a persistent cache driver (such as file or redis), while previously it was set to array

pulsar basin
#

CACHE_DRIVER was set to:

  • phpunit.xml: array
  • .env.testing: file
  • .env: file

I've changed .env.testing file to array -> Nothing changed
I've changed .env file to array -> Fixed the problem

Looks like we're on the right track, thank you @near moss !

It looks like running /vendor/bin/pest ignores phpunit.xml. Any idea why that might be?

near moss
#

phpunit.xml should overwrite whatever is in your env, but maybe pest does some magic, dunno

pulsar basin
#

Thnx, will do some more testing.