Giter Site home page Giter Site logo

Unit test overridden values about enum HOT 3 CLOSED

spatie avatar spatie commented on September 7, 2024
Unit test overridden values

from enum.

Comments (3)

Gummibeer avatar Gummibeer commented on September 7, 2024 1

The reason is that you don't access the enum in your test method but the data provider. These are executed outside the normal context (possibly even a different process) why you can't use things like Laravel/Symfony Container or other more complex dependencies in them.
That's why xDebug doesn't see the call to the enum methods.
One way to solve it would be to pass the method name as string from the data provider and call ReadingContext::from($name) in your test method. That way you should get a proper coverage report.

Another thing: we will proceed the package even after PHP8.1 (see #96) - as the native enums are a massive improvement but we want to keep some of the current methods/features and also need them for the Laravel Wrapper.
So just to let you know - it's up to you how you want to switch. 😉

from enum.

yaroslavche avatar yaroslavche commented on September 7, 2024 1

yes, it works fine now. Thanks for explanation!
I'm writing framework agnostic package and in 8.1 planning to move to built-in enums because enums in my package never wouldn't change and right now spatie/enum is just single dependency and it would be better without any of dependencies. But maybe will leave this package, I will see later at autumn.
Many thanks for quick response and your work! Appreciated

from enum.

Gummibeer avatar Gummibeer commented on September 7, 2024 1

The new version will integrate with native enums. So you will use enum ReadingContext but have methods like the values(), labels() and equals() on it.
If you don't need these things or think that you don't need the package for it - totally fine! 👍
Just wanted to let you know that we won't abandon that package but bring it to the next level.^^

from enum.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.