From 9a590b33094077e0acb9efba2acdfe2d4eaf0b53 Mon Sep 17 00:00:00 2001 From: Paulo Pinto Date: Wed, 10 Jan 2024 12:51:15 +0000 Subject: [PATCH] Void return type must now be specified in certain test methods See 'Return Type of Template Methods' at https://phpunit.de/announcements/phpunit-8.html --- tests/phpunit/lib/testcase-route.php | 2 +- tests/phpunit/lib/testcase.php | 2 +- tests/phpunit/testcases/test_builtin_errors.php | 2 +- tests/phpunit/testcases/test_builtin_warnings.php | 2 +- tests/phpunit/testcases/test_noop_translations.php | 4 ++-- tests/phpunit/testcases/test_template.php | 2 +- tests/phpunit/testcases/test_thing.php | 4 ++-- tests/phpunit/testcases/test_urls.php | 4 ++-- tests/phpunit/testcases/test_validation.php | 2 +- tests/phpunit/testcases/test_warnings.php | 2 +- .../phpunit/testcases/tests_formats/test_format_android.php | 2 +- tests/phpunit/testcases/tests_formats/test_format_jed1x.php | 2 +- tests/phpunit/testcases/tests_formats/test_format_json.php | 2 +- .../tests_formats/test_format_json_pretty_print.php | 2 +- tests/phpunit/testcases/tests_formats/test_format_ngx.php | 2 +- tests/phpunit/testcases/tests_formats/test_format_php.php | 2 +- tests/phpunit/testcases/tests_formats/test_format_pomo.php | 4 ++-- .../testcases/tests_formats/test_format_properties.php | 6 +++--- tests/phpunit/testcases/tests_formats/test_format_resx.php | 2 +- .../phpunit/testcases/tests_formats/test_format_strings.php | 2 +- tests/phpunit/testcases/tests_routes/test_route_api.php | 2 +- .../testcases/tests_routes/test_route_translation_set.php | 2 +- 22 files changed, 28 insertions(+), 28 deletions(-) diff --git a/tests/phpunit/lib/testcase-route.php b/tests/phpunit/lib/testcase-route.php index efb3a615df..374298c996 100644 --- a/tests/phpunit/lib/testcase-route.php +++ b/tests/phpunit/lib/testcase-route.php @@ -4,7 +4,7 @@ class GP_UnitTestCase_Route extends GP_UnitTestCase { var $route; var $route_class; - function setUp() { + function setUp(): void { parent::setUp(); $this->route = new $this->route_class; $this->route->fake_request = true; diff --git a/tests/phpunit/lib/testcase.php b/tests/phpunit/lib/testcase.php index 6eebd90273..5999ee67d4 100644 --- a/tests/phpunit/lib/testcase.php +++ b/tests/phpunit/lib/testcase.php @@ -14,7 +14,7 @@ class GP_UnitTestCase extends WP_UnitTestCase { */ public $factory; - function setUp() { + function setUp(): void { parent::setUp(); $this->factory = new GP_UnitTest_Factory(); diff --git a/tests/phpunit/testcases/test_builtin_errors.php b/tests/phpunit/testcases/test_builtin_errors.php index 444c057cd0..5498ef16e8 100644 --- a/tests/phpunit/testcases/test_builtin_errors.php +++ b/tests/phpunit/testcases/test_builtin_errors.php @@ -2,7 +2,7 @@ class GP_Test_Builtin_Translation_Errors extends GP_UnitTestCase { - function setUp() { + function setUp(): void { parent::setUp(); $this->w = new GP_Builtin_Translation_Errors(); $this->l = $this->factory->locale->create(); diff --git a/tests/phpunit/testcases/test_builtin_warnings.php b/tests/phpunit/testcases/test_builtin_warnings.php index fb2eba55f7..b94dd750f3 100644 --- a/tests/phpunit/testcases/test_builtin_warnings.php +++ b/tests/phpunit/testcases/test_builtin_warnings.php @@ -2,7 +2,7 @@ class GP_Test_Builtin_Translation_Warnings extends GP_UnitTestCase { - function setUp() { + function setUp(): void { parent::setUp(); $this->w = new GP_Builtin_Translation_Warnings(); $this->l = $this->factory->locale->create(); diff --git a/tests/phpunit/testcases/test_noop_translations.php b/tests/phpunit/testcases/test_noop_translations.php index 582bc458a3..b3ca60a0c6 100644 --- a/tests/phpunit/testcases/test_noop_translations.php +++ b/tests/phpunit/testcases/test_noop_translations.php @@ -1,7 +1,7 @@ noop = new NOOP_Translations; $this->entry = new Translation_Entry( array( 'singular' => 'baba' ) ); @@ -38,4 +38,4 @@ function test_plural() { $this->assertEquals( 'dyados', $this->noop->translate_plural( 'dyado', 'dyados', 11 ) ); $this->assertEquals( 'dyados', $this->noop->translate_plural( 'dyado', 'dyados', 0 ) ); } -} \ No newline at end of file +} diff --git a/tests/phpunit/testcases/test_template.php b/tests/phpunit/testcases/test_template.php index 1dfeca8663..3aa6aac62d 100644 --- a/tests/phpunit/testcases/test_template.php +++ b/tests/phpunit/testcases/test_template.php @@ -2,7 +2,7 @@ class GP_Test_Template_Functions extends GP_UnitTestCase { - function tearDown() { + function tearDown(): void { parent::tearDown(); remove_all_filters('gp_breadcrumb_items'); } diff --git a/tests/phpunit/testcases/test_thing.php b/tests/phpunit/testcases/test_thing.php index 7acf112609..7a2f02d12d 100644 --- a/tests/phpunit/testcases/test_thing.php +++ b/tests/phpunit/testcases/test_thing.php @@ -7,7 +7,7 @@ class GP_My_Table extends GP_Thing { class GP_Test_Thing extends GP_UnitTestCase { - function setUp() { + function setUp(): void { parent::setUp(); $GLOBALS['wpdb']->mytable = 'mytable'; @@ -41,4 +41,4 @@ function test_sql_from_order() { $this->assertEquals( 'ORDER BY table.field ASC', $this->t->sql_from_order( array( 'table.field', 'ASC' ) ) ); $this->assertEquals( 'ORDER BY table.field ASC', $this->t->sql_from_order( array( 'table.field', 'ASC' ), 'baba' ) ); } -} \ No newline at end of file +} diff --git a/tests/phpunit/testcases/test_urls.php b/tests/phpunit/testcases/test_urls.php index 31ee9c6446..1a98b41fd9 100644 --- a/tests/phpunit/testcases/test_urls.php +++ b/tests/phpunit/testcases/test_urls.php @@ -2,7 +2,7 @@ class GP_Test_Urls extends GP_UnitTestCase { - function setUp() { + function setUp(): void { parent::setUp(); $this->home_url = 'http://example.org'; @@ -16,7 +16,7 @@ function setUp() { add_filter( 'option_home', array( $this, '_gp_url_home_url' ) ); } - function teardown() { + function teardown(): void { parent::tearDown(); remove_filter( 'gp_url_base_path', array( $this, '_gp_url_base_path_sub_dir' ) ); diff --git a/tests/phpunit/testcases/test_validation.php b/tests/phpunit/testcases/test_validation.php index d23dc481de..4f2580d2cc 100644 --- a/tests/phpunit/testcases/test_validation.php +++ b/tests/phpunit/testcases/test_validation.php @@ -21,7 +21,7 @@ function normalize_fields( $args ) { class GP_Test_Validation extends GP_UnitTestCase { - function setUp() { + function setUp(): void { parent::setUp(); global $wpdb; diff --git a/tests/phpunit/testcases/test_warnings.php b/tests/phpunit/testcases/test_warnings.php index 55562005f2..f0f5ca87af 100644 --- a/tests/phpunit/testcases/test_warnings.php +++ b/tests/phpunit/testcases/test_warnings.php @@ -1,7 +1,7 @@ is_baba = function( $o, $t, $l ) { return $t == "баба"? true : "error"; diff --git a/tests/phpunit/testcases/tests_formats/test_format_android.php b/tests/phpunit/testcases/tests_formats/test_format_android.php index 4c0913e14d..3abb800099 100644 --- a/tests/phpunit/testcases/tests_formats/test_format_android.php +++ b/tests/phpunit/testcases/tests_formats/test_format_android.php @@ -1,7 +1,7 @@ android = new GP_Format_Android; $this->entries = array( diff --git a/tests/phpunit/testcases/tests_formats/test_format_jed1x.php b/tests/phpunit/testcases/tests_formats/test_format_jed1x.php index 12c1150629..f43ee991cf 100644 --- a/tests/phpunit/testcases/tests_formats/test_format_jed1x.php +++ b/tests/phpunit/testcases/tests_formats/test_format_jed1x.php @@ -16,7 +16,7 @@ class GP_Test_Format_Jed1x extends GP_UnitTestCase { */ protected $format = 'jed1x'; - public function setUp() { + public function setUp(): void { parent::setUp(); $this->translation_set = $this->factory->translation_set->create_with_project_and_locale( array(), array( 'name' => 'foo_project' ) ); diff --git a/tests/phpunit/testcases/tests_formats/test_format_json.php b/tests/phpunit/testcases/tests_formats/test_format_json.php index fbb2359315..3edca84181 100644 --- a/tests/phpunit/testcases/tests_formats/test_format_json.php +++ b/tests/phpunit/testcases/tests_formats/test_format_json.php @@ -16,7 +16,7 @@ class GP_Test_Format_JSON extends GP_UnitTestCase { */ protected $format = 'json'; - public function setUp() { + public function setUp(): void { parent::setUp(); $this->translation_set = $this->factory->translation_set->create_with_project_and_locale( array(), array( 'name' => 'foo_project' ) ); diff --git a/tests/phpunit/testcases/tests_formats/test_format_json_pretty_print.php b/tests/phpunit/testcases/tests_formats/test_format_json_pretty_print.php index b812d92d1b..4b7d55f426 100644 --- a/tests/phpunit/testcases/tests_formats/test_format_json_pretty_print.php +++ b/tests/phpunit/testcases/tests_formats/test_format_json_pretty_print.php @@ -11,7 +11,7 @@ class GP_Test_JSON_Pretty_Print extends GP_UnitTestCase { */ protected $locale; - public function setUp() { + public function setUp(): void { parent::setUp(); $this->translation_set = $this->factory->translation_set->create_with_project_and_locale( array(), array( 'name' => 'foo_project' ) ); diff --git a/tests/phpunit/testcases/tests_formats/test_format_ngx.php b/tests/phpunit/testcases/tests_formats/test_format_ngx.php index 3899b8ebe8..d31068f72a 100644 --- a/tests/phpunit/testcases/tests_formats/test_format_ngx.php +++ b/tests/phpunit/testcases/tests_formats/test_format_ngx.php @@ -16,7 +16,7 @@ class GP_Test_Format_NGX extends GP_UnitTestCase { */ protected $format = 'ngx'; - public function setUp() { + public function setUp(): void { parent::setUp(); $this->translation_set = $this->factory->translation_set->create_with_project_and_locale( array(), array( 'name' => 'foo_project' ) ); diff --git a/tests/phpunit/testcases/tests_formats/test_format_php.php b/tests/phpunit/testcases/tests_formats/test_format_php.php index 755f6611fb..290f542082 100644 --- a/tests/phpunit/testcases/tests_formats/test_format_php.php +++ b/tests/phpunit/testcases/tests_formats/test_format_php.php @@ -16,7 +16,7 @@ class GP_Test_Format_PHP extends GP_UnitTestCase { */ protected $format = 'php'; - public function setUp() { + public function setUp(): void { parent::setUp(); $this->translation_set = $this->factory->translation_set->create_with_project_and_locale( array(), array( 'name' => 'foo_project' ) ); diff --git a/tests/phpunit/testcases/tests_formats/test_format_pomo.php b/tests/phpunit/testcases/tests_formats/test_format_pomo.php index 3d93022e3e..6b5b3b8fd8 100644 --- a/tests/phpunit/testcases/tests_formats/test_format_pomo.php +++ b/tests/phpunit/testcases/tests_formats/test_format_pomo.php @@ -26,7 +26,7 @@ class GP_Test_Format_PO extends GP_UnitTestCase { */ protected $has_comments = true; - public function setUp() { + public function setUp(): void { parent::setUp(); $this->translation_file = GP_DIR_TESTDATA . '/translation.po'; @@ -182,7 +182,7 @@ class GP_Test_Format_MO extends GP_Test_Format_PO { */ protected $format; - public function setUp() { + public function setUp(): void { parent::setUp(); $this->translation_file = GP_DIR_TESTDATA . '/translation.mo'; diff --git a/tests/phpunit/testcases/tests_formats/test_format_properties.php b/tests/phpunit/testcases/tests_formats/test_format_properties.php index 693be6a15f..e8fe8910f5 100644 --- a/tests/phpunit/testcases/tests_formats/test_format_properties.php +++ b/tests/phpunit/testcases/tests_formats/test_format_properties.php @@ -2,7 +2,7 @@ class GP_Test_Format_Properties extends GP_UnitTestCase { - function setUp() { + function setUp(): void { parent::setUp(); $this->properties = new GP_Format_Properties; $this->entries = array( @@ -38,7 +38,7 @@ function test_export() { $file_contents = file_get_contents( GP_DIR_TESTDATA . '/translation.properties' ); $file_contents = str_replace( '[GP VERSION]', GP_VERSION, $file_contents ); - + $exported = $this->properties->print_exported_file( $project, $locale, $set, $entries_for_export ); $this->assertEquals( $file_contents, $exported ); @@ -46,7 +46,7 @@ function test_export() { function test_read_originals() { $translations = $this->properties->read_originals_from_file( GP_DIR_TESTDATA . '/originals.properties' ); - + // We're adding one extra to the count for the entries because the file contains a multi-line entry that we want to test reading but don't test writing later. $this->assertEquals( count( $this->entries ) + 1, count( $translations->entries ), 'number of read originals is different from the expected' ); diff --git a/tests/phpunit/testcases/tests_formats/test_format_resx.php b/tests/phpunit/testcases/tests_formats/test_format_resx.php index 12943a97fb..7d4e0b5020 100644 --- a/tests/phpunit/testcases/tests_formats/test_format_resx.php +++ b/tests/phpunit/testcases/tests_formats/test_format_resx.php @@ -1,7 +1,7 @@ resx = new GP_Format_ResX; $this->entries = array( diff --git a/tests/phpunit/testcases/tests_formats/test_format_strings.php b/tests/phpunit/testcases/tests_formats/test_format_strings.php index d1e8094eda..ba691032e2 100644 --- a/tests/phpunit/testcases/tests_formats/test_format_strings.php +++ b/tests/phpunit/testcases/tests_formats/test_format_strings.php @@ -2,7 +2,7 @@ class GP_Test_Format_Strings extends GP_UnitTestCase { - function setUp() { + function setUp(): void { parent::setUp(); $this->strings = new GP_Format_Strings; $this->entries = array( diff --git a/tests/phpunit/testcases/tests_routes/test_route_api.php b/tests/phpunit/testcases/tests_routes/test_route_api.php index 7ac2453171..8a34346574 100644 --- a/tests/phpunit/testcases/tests_routes/test_route_api.php +++ b/tests/phpunit/testcases/tests_routes/test_route_api.php @@ -3,7 +3,7 @@ class GP_Test_Projects_API extends GP_UnitTestCase_Route { var $route_class = 'GP_Route_Project'; - function setUp() { + function setUp(): void { parent::setUp(); $this->set = $this->factory->translation_set->create_with_project_and_locale(); $this->route->api = true; diff --git a/tests/phpunit/testcases/tests_routes/test_route_translation_set.php b/tests/phpunit/testcases/tests_routes/test_route_translation_set.php index 04db506853..6fd469f22f 100644 --- a/tests/phpunit/testcases/tests_routes/test_route_translation_set.php +++ b/tests/phpunit/testcases/tests_routes/test_route_translation_set.php @@ -3,7 +3,7 @@ class GP_Test_Route_Translation_Set extends GP_UnitTestCase_Route { var $route_class = 'GP_Route_Translation_Set'; - function setUp() { + function setUp(): void { parent::setUp(); $this->set = $this->factory->translation_set->create_with_project_and_locale(); }