WordPress is far from having a standard conventions for unit testing extensions. Or for extension structure in general.
At current time you should either:
- research how unit testing framework of your choice recommends to work with globals and such for PHP code in general
- look into WordPress-specific tools for unit testing that start to appear, such as WP_Mock
Related Posts:
- Unit tests – Dealing with dependencies
- PHPUnit testing WordPress Plugin
- Implement phpunit testing on a plugin
- Unit testing to simulate the loop
- What is the best way to do unit tests for your plugin in 2018 [closed]
- Plugin development with unit tests
- Unit testing wordpress plugins with plugin options
- Install and load additional plugins when running unit tests
- Unit Testing a Plugin functionality with cron
- PHPUnit test plugin activation
- Why is WP_Mock not used instead of WP_UnitTestCase for writing unit tests by most plugins?
- DataBase connection problem with PHPUnit and WordPress
- how to set context in WordPress for unit testing
- Unit testing a plugin with a theme dependency
- PHPUnit Testing and woocommerce Constant
- Unit Testing action hook
- PHPUnit Ajax Serialization of ‘Closure’ is not allowed
- PHPUnit Testing Installation Issue
- PHP error with shortcode handler from a class
- Passing arguments to a admin menu page callback?
- Add async script
- What is the difference between using global $current_screen and get_current_screen()?
- Adding pre-publish checks with Gutenberg
- What areas to Unit test while building a plugin?
- How Do I Make WordPress Run an Event Every Day?
- How can I change the frequency of a scheduled event?
- How to filter $post->post_content prior to save
- How to get data from WordPress $wpdb into React Gutenberg Blocks Frontend?
- How to check if certain plugin exists and in expected version
- Customizer Not Saving Options
- How to add SQL file with PHP to WordPress database [closed]
- Platform/Website that Supports Crowd-Funded WordPress Projects? [closed]
- Get user id for delete and update selected user
- How can I call template partials inside my custom plugin
- Add version query tag to all images
- Creating table with plugin is not working
- How to store a medium amount of options?
- Get the post id as early as possible
- How to delete an user including data from custom database tables
- Custom plugin changes not showing
- Beginner advice
- Multiple options pages validation for a plugin
- Prefixing plugin hooks (actions/filters) with a wrapper class or functions
- get_option() not returning expected value from plugin
- Woocommerce Composite Products – Add a composite product to cart programmatically via ajax [closed]
- Testing Rewrite Rules with PHPUnit
- Add a page in admin without adding menu item
- Including third party libraries in plugin [closed]
- Avoid updating post when sending POST or GET request to post.php
- What action hook can I use to add a JavaScript to a page post using a theme template that is not including get_header() nor get_footer()?
- should i be checking for jquery before enqueing it in a plugin
- WordPress Specified file failed upload test
- WordPress theme options Menu
- Add information to HTTP Header in WordPress Plugin
- Catching Gutenberg sidebar switch event
- Can’t retrieve body params from PUT endpoint using formdata
- enabling Twig as Template Engine withing own plugin [closed]
- Set _regular_price 0 if empty in woocommerce product
- Can I Hook Into the TinyMCE Insert/Edit Link Button to Use Shortlink For Post?
- Ajax function is not working on WordPress
- Writing editor content to a file
- $wpdb in php 5.5
- how to display a string in admin_notices hook from a class plugin
- Create an user on external database
- How to Find a Gallery’s ID
- How do i remove the title from a specific page
- WP 3.3 makes it possible to add meta box to Category Editor Screen?
- Widget internal hooks and functions
- Why does website stretch and white space on load? [duplicate]
- check_admin_referer()
- How to create a custom wordpress plugin
- Undefined cache functions in my custom plugin
- Twenty-seventy theme remove additional CSS from head
- Does hooking into a plugin action / filter override the plugin’s function for that hook?
- Nested Hooks with do_action for performance reasons – safe/necessary?
- Replace the WordPress Media Library Uploader
- do_action from within a class does not seem to work
- WordPress delete mysql rows with string
- Select field value not returned after saving changes
- WP Query Relations / Compare
- Page template compatibility with different themes
- WordPress Plugin: OSCommerce images not displaying in front end
- Implementing plugin with HTML/CSS form?
- Adding class to the parent of current-post-ancestor / current-menu-parent / current-post-parent
- Best practices/popular methods for distributing a program with a plugin?
- How to delete all the options in an option group
- How to create a database table in WordPress using PHP
- Render raw html in Gutenberg block
- How can I create a custom plugin to call webapi after user registration?
- Displaying an Uploaded Image as a Custom Avatar in WordPress
- Rest Api WordPress
- How to create A – Z List with pictures?
- How do I display and edit other posts within the ‘Edit Post’ area of Wp-Admin Dashboard
- A better way of getting draft posts that has a particular post meta using get_posts function
- Save translation file of third party plugin in a custom plugin?
- Custom rewrite, url path with parameters to a page
- Developing an IP lookup function using an API
- Making a user platform reachable by a qr code on a pin-back-button [closed]
- how to add contact form 7 shortcode in javascript variable
- select rows based on exact time (hours, minutes and seconds)