Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
psrpinto committed Feb 19, 2024
1 parent 0c1b677 commit 37e77b0
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 6 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
17 changes: 15 additions & 2 deletions tests/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
24 changes: 22 additions & 2 deletions tests/stats-listener.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {

Check warning on line 21 in tests/stats-listener.php

View workflow job for this annotation

GitHub Actions / phpcs

This comment is 59% valid code; is this commented out code?

Check failure on line 21 in tests/stats-listener.php

View workflow job for this annotation

GitHub Actions / phpcs

Line indented incorrectly; expected at least 2 tabs, found 0

Check failure on line 21 in tests/stats-listener.php

View workflow job for this annotation

GitHub Actions / phpcs

Spaces must be used for mid-line alignment; tabs are not allowed

Check failure on line 21 in tests/stats-listener.php

View workflow job for this annotation

GitHub Actions / phpcs

Expected 1 space before comment text but found 6; use block comment if you need indentation
// ["original_id"]=> string(4) "3840"

Check failure on line 22 in tests/stats-listener.php

View workflow job for this annotation

GitHub Actions / phpcs

Line indented incorrectly; expected at least 2 tabs, found 0

Check failure on line 22 in tests/stats-listener.php

View workflow job for this annotation

GitHub Actions / phpcs

Spaces must be used for mid-line alignment; tabs are not allowed

Check failure on line 22 in tests/stats-listener.php

View workflow job for this annotation

GitHub Actions / phpcs

Expected 1 space before comment text but found 10; use block comment if you need indentation
// ["_gp_route_nonce"]=> string(10) "b3f6657922"

Check failure on line 23 in tests/stats-listener.php

View workflow job for this annotation

GitHub Actions / phpcs

Line indented incorrectly; expected at least 2 tabs, found 0

Check failure on line 23 in tests/stats-listener.php

View workflow job for this annotation

GitHub Actions / phpcs

Spaces must be used for mid-line alignment; tabs are not allowed

Check failure on line 23 in tests/stats-listener.php

View workflow job for this annotation

GitHub Actions / phpcs

Expected 1 space before comment text but found 10; use block comment if you need indentation
// ["translation"]=> array(1) {

Check failure on line 24 in tests/stats-listener.php

View workflow job for this annotation

GitHub Actions / phpcs

Line indented incorrectly; expected at least 2 tabs, found 0
// [3840]=> array(1) {
// [0]=> string(6) "Menuga"
// }
// }
// }
}
}

0 comments on commit 37e77b0

Please sign in to comment.