Skip to content

Commit

Permalink
Load GlotPress when running tests
Browse files Browse the repository at this point in the history
  • Loading branch information
psrpinto committed Feb 20, 2024
1 parent da2a433 commit bf1e542
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .wp-env.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"core": "WordPress/WordPress#master",
"plugins": [
"GlotPress/GlotPress#local",
"GlotPress/GlotPress",
"https://downloads.wordpress.org/plugin/sqlite-object-cache.1.3.7.zip",
"."
],
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"scripts":{
"lint": "phpcs --standard=phpcs.xml -s",
"lint:fix": "phpcbf --standard=phpcs.xml",
"dev:start": "wp-env start --debug && wp-env run cli wp rewrite structure '/%postname%/'",
"dev:start": "wp-env start && wp-env run cli wp rewrite structure '/%postname%/'",
"dev:debug": "wp-env start --xdebug",
"dev:stop": "wp-env stop",
"dev:db:schema": "wp-env run cli --env-cwd=wp-content/plugins/wporg-gp-translation-events sh -c 'wp db query < schema.sql'",
Expand Down
16 changes: 15 additions & 1 deletion tests/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,24 @@
* Manually load the plugin being tested.
*/
function _manually_load_plugin() {
require dirname( __DIR__ ) . '/wporg-gp-translation-events.php';
require_once dirname( __DIR__, 2 ) . '/glotpress/tests/phpunit/includes/loader.php';
require_once dirname( __DIR__ ) . '/wporg-gp-translation-events.php';
}

tests_add_filter( 'muplugins_loaded', '_manually_load_plugin' );

// Start up the WP testing environment.
require "$_tests_dir/includes/bootstrap.php";

// Require GlotPress test code.
require_once dirname( __DIR__, 2 ) . '/glotpress/tests/phpunit/lib/testcase.php';
require_once dirname( __DIR__, 2 ) . '/glotpress/tests/phpunit/lib/testcase-route.php';
require_once dirname( __DIR__, 2 ) . '/glotpress/tests/phpunit/lib/testcase-request.php';

function _install_glotpress() {
require_once ABSPATH . 'wp-admin/includes/upgrade.php';
require_once dirname( __DIR__, 2 ) . '/glotpress/gp-includes/schema.php';
require_once dirname( __DIR__, 2 ) . '/glotpress/gp-includes/install-upgrade.php';
gp_upgrade_db();
}
_install_glotpress();

0 comments on commit bf1e542

Please sign in to comment.