Skip to content

Commit

Permalink
Upgrade code to PHP 7.2.
Browse files Browse the repository at this point in the history
  • Loading branch information
kagg-design committed Nov 13, 2024
1 parent 6cdf8f4 commit 81cddad
Show file tree
Hide file tree
Showing 20 changed files with 202 additions and 227 deletions.
9 changes: 3 additions & 6 deletions tests/unit/ACFTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,6 @@ class ACFTest extends CyrToLatTestCase {

/**
* Tear down.
*
* @noinspection PhpLanguageLevelInspection
* @noinspection PhpUndefinedClassInspection
*/
public function tearDown(): void {
unset( $GLOBALS['cyr_to_lat_plugin'] );
Expand All @@ -40,7 +37,7 @@ public function tearDown(): void {
*
* @throws ReflectionException Reflection Exception.
*/
public function test_constructor() {
public function test_constructor(): void {
$classname = ACF::class;

$settings = Mockery::mock( Settings::class );
Expand All @@ -60,7 +57,7 @@ public function test_constructor() {
/**
* Test init_hooks()
*/
public function test_init_hooks() {
public function test_init_hooks(): void {
$settings = Mockery::mock( Settings::class );
$subject = new ACF( $settings );

Expand All @@ -75,7 +72,7 @@ public function test_init_hooks() {
/**
* Test enqueue_script()
*/
public function test_enqueue_script() {
public function test_enqueue_script(): void {
$table = [ 'я' => 'ya' ];
$object = [ 'table' => $table ];

Expand Down
8 changes: 4 additions & 4 deletions tests/unit/AdminNoticesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class AdminNoticesTest extends CyrToLatTestCase {
*
* @throws ReflectionException Reflection Exception.
*/
public function test_constructor() {
public function test_constructor(): void {
$classname = AdminNotices::class;

// Get mock, without the constructor being called.
Expand All @@ -42,7 +42,7 @@ public function test_constructor() {
/**
* Test add_notice() and show_notices()
*/
public function test_add_and_show_notices() {
public function test_add_and_show_notices(): void {
$expected = ' <div class="notice">
<p>
<strong>
Expand Down Expand Up @@ -79,7 +79,7 @@ public function test_add_and_show_notices() {
/**
* Test add_notice() and show_notices() when page is not allowed
*/
public function test_show_notices_when_page_is_not_allowed() {
public function test_show_notices_when_page_is_not_allowed(): void {
$page_slug = 'some_page';

WP_Mock::userFunction( 'get_current_screen' )->andReturn( null );
Expand All @@ -98,7 +98,7 @@ public function test_show_notices_when_page_is_not_allowed() {
/**
* Test add_notice() and show_notices() when page is allowed
*/
public function test_show_notices_when_page_is_allowed() {
public function test_show_notices_when_page_is_allowed(): void {
$expected = ' <div class="notice">
<p>
<strong>
Expand Down
11 changes: 5 additions & 6 deletions tests/unit/BackgroundProcesses/ConversionProcessTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

// phpcs:disable Generic.Commenting.DocComment.MissingShort
/** @noinspection PhpUndefinedMethodInspection */
/** @noinspection PhpArrayShapeAttributeCanBeAddedInspection */
// phpcs:enable Generic.Commenting.DocComment.MissingShort

namespace CyrToLat\Tests\Unit\BackgroundProcesses;
Expand All @@ -33,7 +32,7 @@ class ConversionProcessTest extends CyrToLatTestCase {
*
* @throws ReflectionException ReflectionException.
*/
public function test_task() {
public function test_task(): void {
$subject = Mockery::mock( ConversionProcess::class )->makePartial()->shouldAllowMockingProtectedMethods();
$method = 'task';

Expand All @@ -47,7 +46,7 @@ public function test_task() {
*
* @throws ReflectionException ReflectionException.
*/
public function test_complete() {
public function test_complete(): void {
$subject = Mockery::mock( ConversionProcess::class )->makePartial();
$subject->shouldAllowMockingProtectedMethods();
$subject->shouldReceive( 'clear_scheduled_event' )->once();
Expand Down Expand Up @@ -81,7 +80,7 @@ public function test_complete() {
*
* @dataProvider dp_test_is_process_completed
*/
public function test_is_process_completed( $transient, bool $expected ) {
public function test_is_process_completed( $transient, bool $expected ): void {
$main = Mockery::mock( Main::class );
$subject = new ConversionProcess( $main );

Expand Down Expand Up @@ -125,7 +124,7 @@ public static function dp_test_is_process_completed(): array {
*
* @dataProvider dp_test_is_process_running
*/
public function test_is_process_running( $transient, bool $expected ) {
public function test_is_process_running( $transient, bool $expected ): void {
$main = Mockery::mock( Main::class );
$subject = new ConversionProcess( $main );

Expand All @@ -149,7 +148,7 @@ public function test_is_process_running( $transient, bool $expected ) {
* @dataProvider dp_test_log
* @throws ReflectionException ReflectionException.
*/
public function test_log( bool $debug ) {
public function test_log( bool $debug ): void {
$subject = Mockery::mock( ConversionProcess::class )->makePartial()->shouldAllowMockingProtectedMethods();
$method = 'log';

Expand Down
23 changes: 10 additions & 13 deletions tests/unit/BackgroundProcesses/PostConversionProcessTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,6 @@ class PostConversionProcessTest extends CyrToLatTestCase {

/**
* End test
*
* @noinspection PhpLanguageLevelInspection
* @noinspection PhpUndefinedClassInspection
*/
public function tearDown(): void {
unset( $GLOBALS['wpdb'] );
Expand All @@ -50,7 +47,7 @@ public function tearDown(): void {
* @dataProvider dp_test_task
* @throws ReflectionException ReflectionException.
*/
public function test_task( string $post_name, string $transliterated_name ) {
public function test_task( string $post_name, string $transliterated_name ): void {
global $wpdb;

$post = (object) [
Expand Down Expand Up @@ -133,7 +130,7 @@ public static function dp_test_task(): array {
* @dataProvider dp_test_task_for_attachment
* @throws ReflectionException ReflectionException.
*/
public function test_task_for_attachment( string $post_name, string $transliterated_name ) {
public function test_task_for_attachment( string $post_name, string $transliterated_name ): void {
global $wpdb;

$post = (object) [
Expand Down Expand Up @@ -218,7 +215,7 @@ public static function dp_test_task_for_attachment(): array {
*
* @throws ReflectionException ReflectionException.
*/
public function test_rename_attachment_when_no_file() {
public function test_rename_attachment_when_no_file(): void {
$post_id = 5;

WP_Mock::userFunction( 'get_attached_file' )->with( $post_id )->andReturn( false );
Expand All @@ -245,7 +242,7 @@ public function test_rename_attachment_when_no_file() {
* @dataProvider dp_test_rename_attachment
* @throws ReflectionException ReflectionException.
*/
public function test_rename_attachment( bool $rename, bool $updated ) {
public function test_rename_attachment( bool $rename, bool $updated ): void {
$post_id = 5;
$file = '/var/www/test/wp-content/uploads/2020/05/Скамейка.jpg';
$transliterated_file = '/var/www/test/wp-content/uploads/2020/05/Skamejka.jpg';
Expand Down Expand Up @@ -295,7 +292,7 @@ public static function dp_test_rename_attachment(): array {
*
* @throws ReflectionException ReflectionException.
*/
public function test_rename_thumbnails() {
public function test_rename_thumbnails(): void {
$post_id = 5;
$sizes = [ 'thumbnail', 'medium', 'large' ];
$abspath = '/var/www/test/';
Expand Down Expand Up @@ -387,7 +384,7 @@ function ( $str ) {
*
* @throws ReflectionException ReflectionException.
*/
public function test_update_attachment_metadata() {
public function test_update_attachment_metadata(): void {
$attachment_id = 5;
$meta = [
'width' => 260,
Expand Down Expand Up @@ -438,7 +435,7 @@ public function test_update_attachment_metadata() {
*
* @throws ReflectionException ReflectionException.
*/
public function test_get_transliterated_file() {
public function test_get_transliterated_file(): void {
$file = '/var/www/test/wp-content/uploads/2020/05/Скамейка.jpg';
$transliterated_file = '/var/www/test/wp-content/uploads/2020/05/Skamejka.jpg';

Expand All @@ -459,7 +456,7 @@ public function test_get_transliterated_file() {
*
* @throws ReflectionException ReflectionException.
*/
public function test_rename_file() {
public function test_rename_file(): void {
$file = '/var/www/test/wp-content/uploads/2020/05/Скамейка.jpg';
$new_file = '/var/www/test/wp-content/uploads/2020/05/Skamejka.jpg';

Expand All @@ -485,7 +482,7 @@ static function ( $old_name, $new_name ) use ( $file, $new_file ) {
*
* @throws ReflectionException ReflectionException.
*/
public function test_complete() {
public function test_complete(): void {
$subject = Mockery::mock( PostConversionProcess::class )->makePartial();
$subject->shouldAllowMockingProtectedMethods();
$subject->shouldReceive( 'log' )->with( 'Post slugs conversion completed.' )->once();
Expand Down Expand Up @@ -531,7 +528,7 @@ public function test_complete() {
* @throws ReflectionException Reflection exception.
* @noinspection PhpMissingParamTypeInspection
*/
public function test_filter_post_locale( $wpml_post_language_details, string $locale, string $expected ) {
public function test_filter_post_locale( $wpml_post_language_details, string $locale, string $expected ): void {
$post = (object) [
'ID' => 5,
];
Expand Down
11 changes: 4 additions & 7 deletions tests/unit/BackgroundProcesses/TermConversionProcessTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,6 @@ class TermConversionProcessTest extends CyrToLatTestCase {

/**
* End test
*
* @noinspection PhpLanguageLevelInspection
* @noinspection PhpUndefinedClassInspection
*/
public function tearDown(): void {
unset( $GLOBALS['wpdb'] );
Expand All @@ -48,7 +45,7 @@ public function tearDown(): void {
* @dataProvider dp_test_task
* @throws ReflectionException ReflectionException.
*/
public function test_task( string $term_slug, string $transliterated_slug ) {
public function test_task( string $term_slug, string $transliterated_slug ): void {
global $wpdb;

$term = (object) [
Expand Down Expand Up @@ -117,7 +114,7 @@ public static function dp_test_task(): array {
*
* @throws ReflectionException ReflectionException.
*/
public function test_complete() {
public function test_complete(): void {
$subject = Mockery::mock( TermConversionProcess::class )->makePartial();
$subject->shouldAllowMockingProtectedMethods();
$subject->shouldReceive( 'log' )->with( 'Term slugs conversion completed.' )->once();
Expand Down Expand Up @@ -162,7 +159,7 @@ public function test_complete() {
* @dataProvider dp_test_filter_term_locale_with_polylang
* @throws ReflectionException Reflection exception.
*/
public function test_filter_term_locale_with_polylang( $pll_pll_get_term_language, string $locale, string $expected ) {
public function test_filter_term_locale_with_polylang( $pll_pll_get_term_language, string $locale, string $expected ): void {
$term = (object) [
'taxonomy' => 'category',
'term_taxonomy_id' => 5,
Expand Down Expand Up @@ -215,7 +212,7 @@ public static function dp_test_filter_term_locale_with_polylang(): array {
* @throws ReflectionException Reflection exception.
* @noinspection PhpMissingParamTypeInspection
*/
public function test_filter_term_locale_with_wpml( $wpml_element_language_details, $wpml_active_languages, string $locale, string $expected ) {
public function test_filter_term_locale_with_wpml( $wpml_element_language_details, $wpml_active_languages, string $locale, string $expected ): void {
$term = (object) [
'taxonomy' => 'category',
'term_taxonomy_id' => 5,
Expand Down
4 changes: 2 additions & 2 deletions tests/unit/ConversionTablesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class ConversionTablesTest extends CyrToLatTestCase {
/**
* Test get()
*/
public function test_get() {
public function test_get(): void {
// phpcs:disable WordPress.NamingConventions.ValidVariableName.VariableNotSnakeCase
$iso9 = [
'А' => 'A',
Expand Down Expand Up @@ -1287,7 +1287,7 @@ public function test_get() {
/**
* Test get_fix_table_for_mac()
*/
public function test_get_fix_table_for_mac() {
public function test_get_fix_table_for_mac(): void {
$fix_table = [
'Ё' => urldecode( '%d0%95%cc%88' ),
'ё' => urldecode( '%d0%B5%cc%88' ),
Expand Down
17 changes: 7 additions & 10 deletions tests/unit/ConverterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,6 @@ class ConverterTest extends CyrToLatTestCase {

/**
* End test
*
* @noinspection PhpLanguageLevelInspection
* @noinspection PhpUndefinedClassInspection
*/
public function tearDown(): void {
// phpcs:disable WordPress.Security.NonceVerification.Recommended
Expand All @@ -52,7 +49,7 @@ public function tearDown(): void {
*
* @throws ReflectionException Reflection Exception.
*/
public function test_constructor() {
public function test_constructor(): void {
$classname = Converter::class;

$main = Mockery::mock( Main::class );
Expand Down Expand Up @@ -82,7 +79,7 @@ public function test_constructor() {
/**
* Test init_hooks()
*/
public function test_init_hooks() {
public function test_init_hooks(): void {
$subject = $this->get_subject();

WP_Mock::expectActionAdded( 'admin_init', [ $subject, 'process_handler' ] );
Expand All @@ -106,7 +103,7 @@ public function test_conversion_notices(
bool $terms_process_running,
bool $posts_process_completed,
bool $terms_process_completed
) {
): void {
$main = Mockery::mock( Main::class );
$settings = Mockery::mock( Settings::class );
$process_all_posts = Mockery::mock( PostConversionProcess::class )->shouldAllowMockingProtectedMethods();
Expand Down Expand Up @@ -195,7 +192,7 @@ public static function dp_test_conversion_notices(): array {
*
* @dataProvider dp_test_start_conversion
*/
public function test_start_conversion( bool $convert ) {
public function test_start_conversion( bool $convert ): void {
$subject = Mockery::mock( Converter::class )->makePartial();

WP_Mock::passthruFunction( 'check_admin_referer' );
Expand Down Expand Up @@ -231,7 +228,7 @@ public static function dp_test_start_conversion(): array {
*
* @dataProvider dp_test_process_handler
*/
public function test_process_handler( string $query_arg, string $nonce, bool $verify_nonce ) {
public function test_process_handler( string $query_arg, string $nonce, bool $verify_nonce ): void {
$subject = Mockery::mock( Converter::class )->makePartial();

if ( $query_arg ) {
Expand Down Expand Up @@ -284,7 +281,7 @@ public static function dp_test_process_handler(): array {
* @dataProvider dp_test_convert_existing_slugs
* @noinspection PhpMissingParamTypeInspection
*/
public function test_convert_existing_slugs( $posts, $terms, bool $include_attachment ) {
public function test_convert_existing_slugs( $posts, $terms, bool $include_attachment ): void {
global $wpdb;

$main = Mockery::mock( Main::class );
Expand Down Expand Up @@ -420,7 +417,7 @@ public static function dp_test_convert_existing_slugs(): array {
* @dataProvider dp_test_log
* @throws ReflectionException ReflectionException.
*/
public function test_log( bool $debug ) {
public function test_log( bool $debug ): void {
$subject = Mockery::mock( Converter::class )->makePartial()->shouldAllowMockingProtectedMethods();
$message = 'Test message';
$method = 'log';
Expand Down
Loading

0 comments on commit 81cddad

Please sign in to comment.