Skip to content

Commit

Permalink
Void return type must now be specified in certain test methods
Browse files Browse the repository at this point in the history
See 'Return Type of Template Methods' at https://phpunit.de/announcements/phpunit-8.html
  • Loading branch information
psrpinto committed Jan 10, 2024
1 parent b24480a commit 49fc738
Show file tree
Hide file tree
Showing 22 changed files with 28 additions and 28 deletions.
2 changes: 1 addition & 1 deletion tests/phpunit/lib/testcase-route.php
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion tests/phpunit/lib/testcase.php
Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion tests/phpunit/testcases/test_builtin_errors.php
Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion tests/phpunit/testcases/test_builtin_warnings.php
Expand Up @@ -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();
Expand Down
4 changes: 2 additions & 2 deletions tests/phpunit/testcases/test_noop_translations.php
@@ -1,7 +1,7 @@
<?php

class GP_Test_NOOP_Translations extends GP_UnitTestCase {
function setUp() {
function setUp(): void {
parent::setUp();
$this->noop = new NOOP_Translations;
$this->entry = new Translation_Entry( array( 'singular' => 'baba' ) );
Expand Down Expand Up @@ -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 ) );
}
}
}
2 changes: 1 addition & 1 deletion tests/phpunit/testcases/test_template.php
Expand Up @@ -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');
}
Expand Down
4 changes: 2 additions & 2 deletions tests/phpunit/testcases/test_thing.php
Expand Up @@ -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';
Expand Down Expand Up @@ -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' ) );
}
}
}
4 changes: 2 additions & 2 deletions tests/phpunit/testcases/test_urls.php
Expand Up @@ -2,7 +2,7 @@

class GP_Test_Urls extends GP_UnitTestCase {

function setUp() {
function setUp(): void {
parent::setUp();

$this->home_url = 'http://example.org';
Expand All @@ -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' ) );
Expand Down
2 changes: 1 addition & 1 deletion tests/phpunit/testcases/test_validation.php
Expand Up @@ -21,7 +21,7 @@ function normalize_fields( $args ) {


class GP_Test_Validation extends GP_UnitTestCase {
function setUp() {
function setUp(): void {
parent::setUp();

global $wpdb;
Expand Down
2 changes: 1 addition & 1 deletion tests/phpunit/testcases/test_warnings.php
@@ -1,7 +1,7 @@
<?php

class GP_Test_Translation_Warnings extends GP_UnitTestCase {
function setUp() {
function setUp(): void {
parent::setUp();
$this->is_baba = function( $o, $t, $l ) {
return $t == "баба"? true : "error";
Expand Down
@@ -1,7 +1,7 @@
<?php

class GP_Test_Format_Android extends GP_UnitTestCase {
function setUp() {
function setUp(): void {
parent::setUp();
$this->android = new GP_Format_Android;
$this->entries = array(
Expand Down
Expand Up @@ -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' ) );
Expand Down
2 changes: 1 addition & 1 deletion tests/phpunit/testcases/tests_formats/test_format_json.php
Expand Up @@ -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' ) );
Expand Down
Expand Up @@ -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' ) );
Expand Down
2 changes: 1 addition & 1 deletion tests/phpunit/testcases/tests_formats/test_format_ngx.php
Expand Up @@ -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' ) );
Expand Down
2 changes: 1 addition & 1 deletion tests/phpunit/testcases/tests_formats/test_format_php.php
Expand Up @@ -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' ) );
Expand Down
4 changes: 2 additions & 2 deletions tests/phpunit/testcases/tests_formats/test_format_pomo.php
Expand Up @@ -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';
Expand Down Expand Up @@ -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';
Expand Down
Expand Up @@ -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(
Expand Down Expand Up @@ -38,15 +38,15 @@ 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 );
}

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' );

Expand Down
2 changes: 1 addition & 1 deletion tests/phpunit/testcases/tests_formats/test_format_resx.php
@@ -1,7 +1,7 @@
<?php

class GP_Test_Format_ResX extends GP_UnitTestCase {
function setUp() {
function setUp(): void {
parent::setUp();
$this->resx = new GP_Format_ResX;
$this->entries = array(
Expand Down
Expand Up @@ -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(
Expand Down
2 changes: 1 addition & 1 deletion tests/phpunit/testcases/tests_routes/test_route_api.php
Expand Up @@ -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;
Expand Down
Expand Up @@ -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();
}
Expand Down

0 comments on commit 49fc738

Please sign in to comment.