I suspect this would be a duplicate question or something with a very simple answer, but I've searched on every term I can come up with without any result.
It's really simple; How can I unit test WordPress plugins that depends on other plugins?
I'm currently working on a WooCommerce plugin which will contain a payment gateway, which has to extend the WC_Payment_Gateway
included in the WooCommerce plugin. So I need WordPress to load and activate WooCommerce. I tried;
- manually just including
/plugins/woocommerce/woocommerce.php
. Gives me db errors as WooCommerce tables has not been created. - running
activate_plugin( '<woocommerce plugin path>' );
on the"muplugins_loaded"
action. Gives same error as above. - Cloning WooCommerce dev. repo and including
test/bootstrap.php
in woocommerce. Gives me a PHP fatal error:wp-content/plugins/woocommerce/tmp/wordpress-tests-lib/includes/functions.php): failed to open stream: No such file or directory in /home/...
- Running
/plugins/woocommerce/tests/bin/install.sh
. Gives mePHP Fatal error: Cannot redeclare tests_add_filter() (previously declared in ...
- Combinations of the above
Anyone know what I'm doing wrong? I really don't want to drop unit tests but currently seems like the only option as I'm getting fatal b/c some classes in my plugin i.e. type hint the payment gateway which obviously forces the autoloader to get it.
Thanks in advance :)