diff --git a/.wp-env.json b/.wp-env.json index 2bf444112..0a5605543 100644 --- a/.wp-env.json +++ b/.wp-env.json @@ -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", "." ], diff --git a/composer.json b/composer.json index b6a3b1f99..06b4954b2 100644 --- a/composer.json +++ b/composer.json @@ -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'", diff --git a/tests/bootstrap.php b/tests/bootstrap.php index 03c6b870b..8e45c5144 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -23,11 +23,24 @@ * Manually load the plugin being tested. */ function _manually_load_plugin() { - require dirname( __DIR__, 2 ) . '/glotpress/tests/phpunit/includes/loader.php'; - 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(); diff --git a/tests/stats-listener.php b/tests/stats-listener.php index ed2571dac..fe414c54b 100644 --- a/tests/stats-listener.php +++ b/tests/stats-listener.php @@ -2,10 +2,30 @@ namespace Wporg\tests; -use WP_Ajax_UnitTestCase; +use GP_Route_Translation; +use GP_UnitTestCase_Route; -class Stats_Listener_Test extends WP_Ajax_UnitTestCase { +class Stats_Listener_Test extends GP_UnitTestCase_Route { public function test_stores_translation_created() { + $this->set_admin_user_as_current(); + + $_POST = array( + 'foo' => 'bar', + ); + + $translation_controller = new GP_Route_Translation(); + $translation_controller->translations_post( 'foo', 'en', 'bar' ); + $this->assertTrue( true ); + +// array(3) { +// ["original_id"]=> string(4) "3840" +// ["_gp_route_nonce"]=> string(10) "b3f6657922" +// ["translation"]=> array(1) { +// [3840]=> array(1) { +// [0]=> string(6) "Menuga" +// } +// } +// } } }