Replies: 4 comments 1 reply
-
I will provide an immediate fix and an explanation. Fix - use the uopz extension to define and undefined constants. Explanation - the way the feature was implemented was brittle and never really satisfied me. Different versions of PHPUnit would handle things differently and it was a real pain to debug. My idea is to make an API around what is, currently, a test trait; that function is used over and over in the project tests to achieve the same effect: the code executed in the Closure passed to the To avoid delaying the release of version 4 further, I had resolved to remove the feature to readd it only if really requested. Could you provide an example of the kind of code you're currently running that leverages the |
Beta Was this translation helpful? Give feedback.
-
The I'll also try to see about that test trait. The thing that is bothering me mostly is that I have a test where I need to check if the user is on the admin or not, so I set For example, I have a code: public function myCallback()
{
if(is_admin()) {
return;
}
// Do some logic only on the front.
} So to cover the actual business logic of the method I need to set the So far I've 'circumvented' this by placing that test at the end of the class so that other tests before it will have the I've confirmed that by running a debug on the test class that gets executed after the test where the |
Beta Was this translation helpful? Give feedback.
-
The |
Beta Was this translation helpful? Give feedback.
-
I'm closing this discussion since the feature has been reintroduced. |
Beta Was this translation helpful? Give feedback.
-
I was running some tests where I want to set, and then unset the
define('WP_ADMIN', true);
constant (to simulate being on the admin side), and noticed my lines not being covered, and the last test where this should befalse
failing.When debugging the tests, I noticed that the
Annotations are no longer working and then noticed in the changelog that this is removed in V4.
This is a super useful feature for WordPress, seeing how it messes around with globals. Any idea when this feature will be re-added in v4?
Beta Was this translation helpful? Give feedback.
All reactions