wp-browser: [BUG] Integration tests have some seed failure
Environment
OS: MacOS 10.15.4
PHP version: 7.2.24
Installed Codeception version: 3.1.2
Installed wp-browser version: 2.3.3
WordPress version: 5.4
Local development environment: Valet+
WordPress structure and management: default
Codeception configuration file
My codeception.dist.yaml
is
paths:
tests: tests
output: tests/_output
data: tests/_data
support: tests/_support
envs: tests/_envs
actor_suffix: Tester
extensions:
enabled:
- Codeception\Extension\RunFailed
commands:
- Codeception\Command\GenerateWPUnit
- Codeception\Command\GenerateWPRestApi
- Codeception\Command\GenerateWPRestController
- Codeception\Command\GenerateWPRestPostTypeController
- Codeception\Command\GenerateWPAjax
- Codeception\Command\GenerateWPCanonical
- Codeception\Command\GenerateWPXMLRPC
params:
- .env.testing
Suite configuration file
The wpunit.suite.yml
file looks like this
# Codeception Test Suite Configuration
#
# Suite for unit or integration tests that require WordPress functions and classes.
actor: WpunitTester
modules:
enabled:
- WPLoader
- \Helper\Wpunit
config:
WPLoader:
wpRootFolder: "%WP_ROOT_FOLDER%"
dbName: "%TEST_DB_NAME%"
dbHost: "%TEST_DB_HOST%"
dbUser: "%TEST_DB_USER%"
dbPassword: "%TEST_DB_PASSWORD%"
tablePrefix: "%TEST_TABLE_PREFIX%"
domain: "%TEST_SITE_WP_DOMAIN%"
adminEmail: "%TEST_SITE_ADMIN_EMAIL%"
title: "Test"
plugins: ['woocommerce/woocommerce.php', 'woo-solo-api/woo-solo-api.php']
activatePlugins: ['woocommerce/woocommerce.php', 'woo-solo-api/woo-solo-api.php']
Describe the bug
I have set up the testing suite for my plugin, and when I run the integration test suite the tests pass, but I do get a bit with some error when seeding DB
Output
WordPress database error Table 'wordpress-test.wp_actionscheduler_actions' doesn't exist for query SELECT a.action_id FROM wp_actionscheduler_actions a WHERE a.hook='action_scheduler/migration_hook' AND a.status='in-progress' ORDER BY scheduled_date_gmt DESC LIMIT 1 made by shutdown_action_hook, do_action('shutdown'), WP_Hook->do_action, WP_Hook->apply_filters, Action_Scheduler\Migration\Controller->schedule_migration, Action_Scheduler\Migration\Scheduler->is_migration_scheduled, as_next_scheduled_action, ActionScheduler_HybridStore->find_action, ActionScheduler_DBStore->find_action
WordPress database error Table 'wordpress-test.wp_actionscheduler_actions' doesn't exist for query SELECT a.action_id FROM wp_actionscheduler_actions a WHERE a.hook='action_scheduler/migration_hook' AND a.status='pending' ORDER BY scheduled_date_gmt ASC LIMIT 1 made by shutdown_action_hook, do_action('shutdown'), WP_Hook->do_action, WP_Hook->apply_filters, Action_Scheduler\Migration\Controller->schedule_migration, Action_Scheduler\Migration\Scheduler->is_migration_scheduled, as_next_scheduled_action, ActionScheduler_HybridStore->find_action, ActionScheduler_DBStore->find_action
WordPress database error Table 'wordpress-test.wp_actionscheduler_actions' doesn't exist for query SELECT a.action_id FROM wp_actionscheduler_actions a WHERE a.hook='action_scheduler/migration_hook' AND a.status='in-progress' ORDER BY scheduled_date_gmt DESC LIMIT 1 made by shutdown_action_hook, do_action('shutdown'), WP_Hook->do_action, WP_Hook->apply_filters, Action_Scheduler\Migration\Controller->schedule_migration, Action_Scheduler\Migration\Scheduler->schedule_migration, as_next_scheduled_action, ActionScheduler_HybridStore->find_action, ActionScheduler_DBStore->find_action
WordPress database error Table 'wordpress-test.wp_actionscheduler_actions' doesn't exist for query SELECT a.action_id FROM wp_actionscheduler_actions a WHERE a.hook='action_scheduler/migration_hook' AND a.status='pending' ORDER BY scheduled_date_gmt ASC LIMIT 1 made by shutdown_action_hook, do_action('shutdown'), WP_Hook->do_action, WP_Hook->apply_filters, Action_Scheduler\Migration\Controller->schedule_migration, Action_Scheduler\Migration\Scheduler->schedule_migration, as_next_scheduled_action, ActionScheduler_HybridStore->find_action, ActionScheduler_DBStore->find_action
WordPress database error Table 'wordpress-test.wp_actionscheduler_groups' doesn't exist for query SELECT group_id FROM wp_actionscheduler_groups WHERE slug='action-scheduler-migration' made by shutdown_action_hook, do_action('shutdown'), WP_Hook->do_action, WP_Hook->apply_filters, Action_Scheduler\Migration\Controller->schedule_migration, Action_Scheduler\Migration\Scheduler->schedule_migration, as_schedule_single_action, ActionScheduler_ActionFactory->single, ActionScheduler_ActionFactory->store, ActionScheduler_HybridStore->save_action, ActionScheduler_DBStoreMigrator->save_action, ActionScheduler_DBStore->save_action, ActionScheduler_DBStore->get_group_id
WordPress database error Table 'wordpress-test.wp_actionscheduler_groups' doesn't exist for query SHOW FULL COLUMNS FROM `wp_actionscheduler_groups` made by shutdown_action_hook, do_action('shutdown'), WP_Hook->do_action, WP_Hook->apply_filters, Action_Scheduler\Migration\Controller->schedule_migration, Action_Scheduler\Migration\Scheduler->schedule_migration, as_schedule_single_action, ActionScheduler_ActionFactory->single, ActionScheduler_ActionFactory->store, ActionScheduler_HybridStore->save_action, ActionScheduler_DBStoreMigrator->save_action, ActionScheduler_DBStore->save_action, ActionScheduler_DBStore->get_group_id, ActionScheduler_DBStore->create_group
WordPress database error Table 'wordpress-test.wp_actionscheduler_actions' doesn't exist for query INSERT INTO `wp_actionscheduler_actions` (`hook`, `status`, `scheduled_date_gmt`, `scheduled_date_local`, `schedule`, `group_id`, `args`) VALUES ('action_scheduler/migration_hook', 'pending', '2020-04-01 20:33:57', '2020-04-01 20:33:57', 'O:30:\"ActionScheduler_SimpleSchedule\":2:{s:22:\"\0*\0scheduled_timestamp\";i:1585773237;s:41:\"\0ActionScheduler_SimpleSchedule\0timestamp\";i:1585773237;}', '0', '[]') made by shutdown_action_hook, do_action('shutdown'), WP_Hook->do_action, WP_Hook->apply_filters, Action_Scheduler\Migration\Controller->schedule_migration, Action_Scheduler\Migration\Scheduler->schedule_migration, as_schedule_single_action, ActionScheduler_ActionFactory->single, ActionScheduler_ActionFactory->store, ActionScheduler_HybridStore->save_action, ActionScheduler_DBStoreMigrator->save_action, ActionScheduler_DBStore->save_action
PHP Fatal error: Uncaught RuntimeException: Error saving action: Error saving action: Table 'wordpress-test.wp_actionscheduler_actions' doesn't exist in /Users/denis.zoljom/vagrant-local/www/personal/wordpress-test/public_html/wp-content/plugins/woocommerce/packages/action-scheduler/classes/migration/ActionScheduler_DBStoreMigrator.php:44
Stack trace:
#0 /Users/denis.zoljom/vagrant-local/www/personal/wordpress-test/public_html/wp-content/plugins/woocommerce/packages/action-scheduler/classes/data-stores/ActionScheduler_HybridStore.php(225): ActionScheduler_DBStoreMigrator->save_action(Object(ActionScheduler_Action), NULL)
#1 /Users/denis.zoljom/vagrant-local/www/personal/wordpress-test/public_html/wp-content/plugins/woocommerce/packages/action-scheduler/classes/ActionScheduler_ActionFactory.php(177): ActionScheduler_HybridStore->save_action(Object(ActionScheduler_Action))
#2 /Users/denis.zoljom/vagrant-local/www/personal/wordpress-test/public_html/wp-content/plugins/woocommerce/packages/action-scheduler/classes/ActionScheduler in /Users/denis.zoljom/vagrant-local/www/personal/wordpress-test/public_html/wp-content/plugins/woocommerce/packages/action-scheduler/classes/migration/ActionScheduler_DBStoreMigrator.php on line 44
Wpunit Tests (2) ---------------------------------------------------------------
✔ ActivationTest: It works (0.01s)
✔ ActivationTest: Plugin can be activated (0.00s)
--------------------------------------------------------------------------------
To Reproduce
I’m updating my plugin (rewriting to be honest), the PR is here so you can check settings: https://github.com/dingo-d/woo-solo-api/pull/19/files, I’ve added a composer script "tests:integration": "codecept run wpunit",
and when I run it I get this error.
I’ve set up a test environment wp-tests.app
using Valet+ and wp-cli.
Expected behavior
No errors should appear when running tests 😄
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 16 (8 by maintainers)
Hi, sorry for being late to this party.
I will try out your same setup using the two plugins you use and come back to this.
I think setups like this should be less “clunky” and more straightforward and, definitely, not generate errors.
Ah, it’s because they extend an abstract class that you need to load as well. Require the
abstract class ActionScheduler_Store
as well and it should workThere might be a prettier way of handling this. Maybe @lucatume have some insight