Questions tagged [testing]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
0 votes
0 answers
31 views

Jest Unit tests for High order component containing Block Editor

everyone! I created High order component HOC which adds additional panel to Advanced section at the right sidebar Something like this: import React from 'react' import {InspectorAdvancedControls} ...
oshka's user avatar
  • 1
0 votes
1 answer
50 views

Staging site on subdomain - all links dont work except home page

hi i've created a staging site on subdomain https://stagin.mysite.com/ for testing purposes and put in on var/www/stagin, is on the same server as live site, staging and live site use different ports. ...
PC Welcome's user avatar
0 votes
1 answer
45 views

How to test plugin development with Git Hub Actions (integration tests)?

I am learning CI/CD pipeline and I had created a single one to deploy to staging environment every time I push to develop branch, using GitHub Actions. I also understood how to perform unit tests with ...
Lucas Bacciotti's user avatar
1 vote
0 answers
28 views

ACF - programmatically install and activate in pipeline to automate testing for custom plugin development?

Original question on SO: WP plugin integretion testing - how to enable additional plugins? TL/DR I'm developing a custom plugin and setting up ci/cd via gitlab pipeline. Testing and publishing to ...
fudo's user avatar
  • 111
0 votes
0 answers
20 views

Testing Plugin - Install plugin dependencies in testing enviroment

I have a problem with a unit test. My plugin depends on the Timber plugin for rendering a Twig template. But when I need to run the unit test with WordPress testing enviroment, I can't install ...
Lautaro's user avatar
1 vote
0 answers
59 views

How do I activate a plugin while testing?

I want to make sure my plugin works while another plugin is activated: public function test_registration_3() { activate_plugin( 'new-user-approve/new-user-approve.php', '', false, true ); ...
StevieD's user avatar
  • 211
1 vote
1 answer
37 views

How do I simulate a registration form submission while testing?

I'm trying to figure out how to do an integration test on the registration form by simulating a registration with something like: public function test_registration_form_submission_valid() { // ...
StevieD's user avatar
  • 211
0 votes
1 answer
99 views

Running plugin unit tests vs. integration tests?

I'm finding it difficult to figure out how to run unit tests vs. integration tests. If I run phpunit in the directory of my plugin, it seems to spin up a whole temporary version of wordpress in /tmp. ...
StevieD's user avatar
  • 211
0 votes
0 answers
54 views

How do I package and distribute my WordPress plugin via git?

I wrote a custom plugin for saving an uploaded .xlsx file to a .csv file. The code required an outside library and I used composer to install the code into my plugin's directory. So now I have this ...
StevieD's user avatar
  • 211
1 vote
0 answers
55 views

Mock a dependency of a WP_REST_Controller class

I have a custom WordPress REST API with a client for an external service being injected in its constructor; that client is going to be used internally in that class, like this: class ...
Ian Rodrigues's user avatar
0 votes
1 answer
509 views

why my must use plugins (mu-plugins) not work at localhost?

I have my local WordPress setup I create folder named mu-plugins in wp-content/plugins/mu-plugins and in mu-plugins directory I create one file and write a simple code for test my mu-plugins not work ...
MR. shaikh__92's user avatar
1 vote
2 answers
538 views

How do I get PHPUnit Polyfills set up for testing on a mac?

Got a mac development machine with PHP installed via brew. I'm trying to get testing tools set up. I successfully set up test scaffolding with wp cli and managed to get bin/install-wp-tests.sh to do ...
StevieD's user avatar
  • 211
1 vote
0 answers
104 views

Can't run WP e2e-test-utils because the browser exits on login?

I'm trying to run e2e tests for my Gutenberg plugin. Here's my pertinent code import { createNewPost, enablePageDialogAccept, insertBlock, clickButton, } from "@wordpress/e2e-test-utils&...
Nav Saini's user avatar
1 vote
0 answers
542 views

Python with wordpress plugin

I am trying to do some experiments with python and wordpress plugins. I would like to have shortcode [python] with some functionalities. I was trying this metod - Method i tried, but when I do ...
TriX 's user avatar
  • 11
1 vote
1 answer
410 views

Sample -- test -- data for large WordPress install

I'm working on a plugin, Index WP MySQL for Speed. For testing it would be helpful to have a very large WordPress installation containing many thousands of posts, pages, metadata entries, media items, ...
O. Jones's user avatar
  • 471
1 vote
1 answer
854 views

How to disable redirect on test/staging copy of wordpress site

This site I inherited runs a forum on a combination of Buddyboss and Buddypress. I've had to install ReCaptcha's on all user interactions, but I'm not happy with their layout and I'm suspecting ...
RolfBly's user avatar
  • 111
0 votes
1 answer
246 views

Mocking WP_CLI static methods in unit tests

I'm writing unit tests (not integration) for a lib I'm working on. There, we created some WP-CLI commands that I'd like to test. Most of them are just renaming things, copying and pasting things over ...
dingo_d's user avatar
  • 1,939
0 votes
1 answer
147 views

Clone WordPress for testing on localhost (with Fiddler)

My local setup for WordPress is at http://127.0.0.3/blog. When calling https://my.domain.name/blog/wp-login.php, I get the page served; including Google CAPTCHA. But the login post to a 302 redirect ...
MeSo2's user avatar
  • 111
0 votes
1 answer
64 views

How can I enable IDE integration (autocomplete) for WordPress test suite

When testing a theme or plugin, you can use WP-CLI to scaffold the test suite setup, wp scaffold plugin-test plugin. So is there a good way to integrate an editor/IDE (VS Code in my case) so that ...
Corey's user avatar
  • 172
0 votes
1 answer
20 views

Is there a delay to include call function modification in a scheduled cron task?

I´m testing my cron task. I´m not sure but it seems to be the effect of a previous code. So, I´m wondering when you modify you call function and you run now your cron task (I´m using WP Control) and ...
J.BizMai's user avatar
  • 820
1 vote
2 answers
47 views

Is it possible to populate my wordpress site with many random posts for testing purposes?

I have just deployed the Wordpress application on my Kubernetes cluster following the instructions from https://kubernetes.io/docs/tutorials/stateful-application/mysql-wordpress-persistent-volume/ Now ...
mark's user avatar
  • 113
0 votes
2 answers
327 views

Cloning production site down to local?

I've been using WordPress for awhile now but one problem I'm constantly facing is creating a local clone of a production site so I can test changes/updates. My current process goes something like this....
Jon's user avatar
  • 351
1 vote
1 answer
494 views

How do I phpunit test a post output process?

I like to know how to test the html output of a post. Like WP would output it on the frontend in reality. My specific case at this point is to test oembed caching as I want to test re-caching. AFAIK ...
NextGenThemes's user avatar
0 votes
1 answer
384 views

PHPUnit Testing and woocommerce Constant

I tried to perform a test on the WC_VERSION constant. The main class : class WC_Custom_Variable_Products_Dependencies { /** minimum WooCommerce version required by this plugin */ const ...
Younes.D's user avatar
  • 162
1 vote
2 answers
849 views

Rest API in integration tests - filtering by slug not working?

I have a bunch of custom fields in my REST API response, and I need to refactor the code for it, so I'm creating an integration test for it, just to make sure nothing breaks in the process of ...
dingo_d's user avatar
  • 1,939
1 vote
0 answers
321 views

Coverage in integration tests

EDIT: I've created the mwe as a small test plugin: https://github.com/dingo-d/test-plugin Original question: I'm writing tests for my plugin and one thing makes no sense to me and I'm not sure if I'm ...
dingo_d's user avatar
  • 1,939
0 votes
1 answer
497 views

How can I measure CPU and RAM used by my theme or plugin

I have produced a few plugins for WordPress, but other than generating errors, I don´t have a way to tell if my plugin is doing things right. How can I tell the ammount of CPU time and RAM my ...
Rafa Carvalhido's user avatar
0 votes
1 answer
3k views

How to trigger "wp_handle_upload_prefilter" filter when uploading an image programatically?

I am sanitizing uploaded SVG files with wp_handle_upload_prefilter, example: // Example code add_filter( 'wp_handle_upload_prefilter', function($file) { if ( $file['type'] === 'image/svg+xml' ) { ...
Lucas Bustamante's user avatar
3 votes
1 answer
273 views

What's the proper method of installing a plugin during unit testing?

I am testing a plugin that depends on WooCommerce. In order to properly test the integration, I need WooCommerce installed in the WordPress test application. I tried installing the plugin using wp-...
Ben Harold's user avatar
1 vote
0 answers
115 views

Integration tests don't register menu

I have integration tests set up. The install-wp-tests.sh is taken from the wpcli scaffold plugin tests. I'm on VVV and I have wordpress-develop set up. In my plugin I have phpunit.integration.xml....
dingo_d's user avatar
  • 1,939
0 votes
0 answers
172 views

Integration test - remove the mu plugins in the test

As a recurring theme these past few questions I asked, I'm doing integration testing and want to check the activate static method that gets called in my register_activation_hook in the main plugin ...
dingo_d's user avatar
  • 1,939
1 vote
0 answers
233 views

Integration testing - test is_wp_error in the code?

I'm testing ajax callback in my plugin that is used to import users from JSON file. I have tested everything, but one thing. In my import callback I have: $user_id = wp_create_user( $username, $...
dingo_d's user avatar
  • 1,939
1 vote
0 answers
79 views

Am I testing this right?

Since I need to have 100% test coverage for the client, I'm writing integration and unit tests in my plugin. And I have a method in a class that is hooked to admin_menu hook, which adds submenu. ...
dingo_d's user avatar
  • 1,939
0 votes
1 answer
422 views

Integration tests test script enqueue/register fails

This question is related to this SO post I'm testing a plugin, and in it I have public function enqueue_scripts() { $main_style = 'public/scripts/application.js'; wp_register_script( '...
dingo_d's user avatar
  • 1,939
3 votes
2 answers
698 views

Revert WordPress default options after a PHPUnit test has run

tl;dr: is there a way to make changes to WordPress options during a PHPUnit test suite execution, and have the changes reverted to the WordPress defaults before the next test suite is executed, ...
Sean's user avatar
  • 647
0 votes
1 answer
2k views

.PO file is found but I don't see translations: how to debug the problem?

I have installed the Stack theme, and I want to make Danish translations. I have downloaded the Stack.pot file, made the modifications I need, and uploaded them to: /wp-content/themes/stack/languages/...
Lars Holdgaard's user avatar
2 votes
0 answers
1k views

Deploy WordPress From Local Docker to Hosting Provider

I've seen articles that teach how to migrate WordPress into Docker containers (see also here). I want to do the opposite. I am already running WordPress locally via Docker on my Windows 10 laptop. I ...
Brent Arias's user avatar
1 vote
1 answer
480 views

How to create a network using a command line script?

I would like to run UI automated tests for my WordPress plugin. I am using Docker to run a WP instance and it runs my tests, that is fine. I am using wp-cli to install and config a testing site. I ...
Pavel Dohnal's user avatar
2 votes
1 answer
945 views

Why is WP_Mock not used instead of WP_UnitTestCase for writing unit tests by most plugins?

For writing unit-tests, why do most plugins use WP_UnitTestCase instead of popular libraries like WP_Mock? The reason I am asking this is because WP_UnitTestCase doesn't seem to be a unit test case ...
learning_13's user avatar
0 votes
2 answers
69 views

Making sure updates didn't break anything

I am tasked with updating plugins and core on a number of blogs that I am completely unfamiliar with (nothing weird about them, but I haven't worked with them before today). What I need to do is ...
dgo's user avatar
  • 115
0 votes
1 answer
157 views

Duplicated site isn't recognized as a site

I've duplicated a site using the following code. All code worked fine until the last row (the site itself goes up on the web but the last row of code fails and I get an error): echo "Please enter the ...
Arcticooling's user avatar
2 votes
1 answer
147 views

Best way to notify WordPress plugin users of new release candidates for beta testing?

Over the years I have developed a few WordPress plugins for my own use and shared some via the WordPress.org plugins directory. I have recently made some changes to one of my shared plugins and would ...
gwc's user avatar
  • 131
2 votes
1 answer
2k views

How to login to WordPress site using basic authentication HTTP headers?

I'm looking to run some of my automated acceptance tests as a logged in user. My acceptance tests are run using Ghost Inspector which can send basic authentication headers. There is a basic ...
JPollock's user avatar
  • 1,228
0 votes
1 answer
3k views

Testing localhost WordPress site over LAN with iPad, iPhone

1 down vote favorite I am developing a Wordpress theme that requires testing with multiple devices over my local network. I use the localhost server XAMPP which runs apache on port 80. When I access ...
carteruk's user avatar
0 votes
1 answer
73 views

How to set up a development/staging site to make major changes to the theme then update on the live site?

I made a site a few months ago without using a development or staging environment. I just updated everything on the live site, which was fine at the time because the domain wasn't public. We were ...
user avatar
0 votes
1 answer
205 views

Testing Plugins for Multisite

I have recently published a WordPress plugin and it works great on single sites. I was informed that the plugin is not working correctly on multi-site installations and I understand a few of the ...
amaster's user avatar
  • 103
1 vote
1 answer
425 views

How can I test why the comment hook is not working?

I am trying to perform an action after a comment is approved. What this action is, is to register the commenter automatically using register_new_user, using the commenter's name as the username, and ...
user6686780's user avatar
0 votes
1 answer
49 views

Identifying where plugins are being used in your wordpress install

I've inherited an existing wordpress installation and there are several plugins (active and inactive) that I'm unfamiliar with and unsure if they're even still being used in any fashion. Once I see ...
Will's user avatar
  • 749
0 votes
1 answer
57 views

Limit Google Ads to particular blog posts

I want to introduce Google Ads on my website. But to start on I want to do it only on a particular blog post. It is part of some real-time testing that I need to do. I want to use Google AdSense ...
HBalyan's user avatar
  • 101
4 votes
1 answer
622 views

Using wp_mail during an integration test

I'm working on some tests for WordPress, and I discovered that WordPress' PHPUnit automatically captures and doesn't send emails (using MockPHPMailer) when I try to use wp_mail. I've looked, but I ...
Pete's user avatar
  • 317