Skip to content

Commit

Permalink
Polishing of WPCS.
Browse files Browse the repository at this point in the history
  • Loading branch information
kagg-design committed Sep 7, 2021
1 parent 4453a6c commit e159f75
Show file tree
Hide file tree
Showing 13 changed files with 33 additions and 34 deletions.
2 changes: 0 additions & 2 deletions src/php/class-main.php
Expand Up @@ -373,8 +373,6 @@ public function transliterate( $string ) {
* @link https://kagg.eu/how-to-catch-gutenberg/
*
* @return bool
*
* @noinspection PhpIncludeInspection
*/
private function is_classic_editor_plugin_active() {
// @codeCoverageIgnoreStart
Expand Down
7 changes: 3 additions & 4 deletions tests/phpunit/Settings/Abstracts/SettingsBaseTest.php
Expand Up @@ -199,6 +199,7 @@ public function test_tab_name() {
* Test get_class_name().
*
* @throws ReflectionException ReflectionException.
* @noinspection PhpParamsInspection
*/
public function test_get_class_name() {
$subject = Mockery::mock( SettingsBase::class )->makePartial();
Expand Down Expand Up @@ -463,7 +464,6 @@ public function test_base_admin_enqueue_scripts() {
*
* @dataProvider dp_test_setup_sections
* @throws ReflectionException ReflectionException.
* @noinspection NullCoalescingOperatorCanBeUsedInspection
*/
public function test_setup_sections( $tabs ) {
$tab_option_page = 'cyr-to-lat';
Expand Down Expand Up @@ -664,7 +664,6 @@ public function test_get_tabs() {
* Test get_active_tab().
*
* @throws ReflectionException ReflectionException.
* @noinspection JsonEncodingApiUsageInspection
*/
public function test_get_active_tab() {
$tab = Mockery::mock( SettingsBase::class )->makePartial()->shouldAllowMockingProtectedMethods();
Expand Down Expand Up @@ -1624,7 +1623,7 @@ public function test_load_plugin_text_domain() {
* Test is_options_screen().
*
* @param mixed $current_screen Current admin screen.
* @param boolean $is_main_menu_page It it the main menu page.
* @param boolean $is_main_menu_page It is the main menu page.
* @param boolean $expected Expected result.
*
* @dataProvider dp_test_is_options_screen
Expand All @@ -1648,7 +1647,7 @@ public function test_is_options_screen( $current_screen, $is_main_menu_page, $ex
}

/**
* Data provider for test_is_options_screen(0.
* Data provider for test_is_options_screen().
*
* @return array
*/
Expand Down
2 changes: 0 additions & 2 deletions tests/phpunit/Settings/ConverterTest.php
Expand Up @@ -12,11 +12,9 @@

namespace Cyr_To_Lat\Tests\Settings;

use Cyr_To_Lat\Settings\Abstracts\SettingsBase;
use Cyr_To_Lat\Settings\Converter;
use Cyr_To_Lat\Cyr_To_Lat_TestCase;
use Mockery;
use ReflectionClass;
use ReflectionException;
use tad\FunctionMocker\FunctionMocker;
use WP_Mock;
Expand Down
1 change: 0 additions & 1 deletion tests/phpunit/Settings/SettingsTest.php
Expand Up @@ -55,7 +55,6 @@ public function test_constructor() {
* @preserveGlobalState disabled
*
* @throws ReflectionException ReflectionException.
* @noinspection JsonEncodingApiUsageInspection
*/
public function test_init_and_screen_ids() {
$subject = Mockery::mock( Settings::class )->makePartial()->shouldAllowMockingProtectedMethods();
Expand Down
2 changes: 0 additions & 2 deletions tests/phpunit/Settings/TablesTest.php
Expand Up @@ -160,8 +160,6 @@ public function test_init_locales() {
/**
* Test init_form_fields()
*
* @noinspection PhpSwitchCanBeReplacedWithMatchExpressionInspection
*
* @throws ReflectionException ReflectionException.
*/
public function test_init_form_fields() {
Expand Down
23 changes: 9 additions & 14 deletions tests/phpunit/bootstrap.php
Expand Up @@ -10,11 +10,6 @@

use tad\FunctionMocker\FunctionMocker;

/**
* Plugin test dir.
*/
define( 'PLUGIN_TESTS_DIR', __DIR__ );

/**
* Plugin main file.
*/
Expand All @@ -28,7 +23,7 @@
/**
* Kilobytes in bytes.
*/
define( 'KB_IN_BYTES', 1024 );
const KB_IN_BYTES = 1024;

require_once PLUGIN_PATH . '/vendor/autoload.php';

Expand All @@ -47,42 +42,42 @@
/**
* Path to the plugin dir.
*/
define( 'CYR_TO_LAT_TEST_PATH', PLUGIN_PATH );
const CYR_TO_LAT_TEST_PATH = PLUGIN_PATH;

/**
* Plugin dir url.
*/
define( 'CYR_TO_LAT_TEST_URL', 'http://site.org/wp-content/plugins/cyr2lat' );
const CYR_TO_LAT_TEST_URL = 'https://site.org/wp-content/plugins/cyr2lat';

/**
* Main plugin file.
*/
define( 'CYR_TO_LAT_TEST_FILE', PLUGIN_MAIN_FILE );
const CYR_TO_LAT_TEST_FILE = PLUGIN_MAIN_FILE;

/**
* Plugin prefix.
*/
define( 'CYR_TO_LAT_TEST_PREFIX', 'cyr_to_lat' );
const CYR_TO_LAT_TEST_PREFIX = 'cyr_to_lat';

/**
* Post conversion action.
*/
define( 'CYR_TO_LAT_TEST_POST_CONVERSION_ACTION', 'post_conversion_action' );
const CYR_TO_LAT_TEST_POST_CONVERSION_ACTION = 'post_conversion_action';

/**
* Term conversion action.
*/
define( 'CYR_TO_LAT_TEST_TERM_CONVERSION_ACTION', 'term_conversion_action' );
const CYR_TO_LAT_TEST_TERM_CONVERSION_ACTION = 'term_conversion_action';

/**
* Minimum required php version.
*/
define( 'CYR_TO_LAT_TEST_MINIMUM_PHP_REQUIRED_VERSION', '5.6' );
const CYR_TO_LAT_TEST_MINIMUM_PHP_REQUIRED_VERSION = '5.6';

/**
* Minimum required max_input_vars value.
*/
define( 'CYR_TO_LAT_TEST_REQUIRED_MAX_INPUT_VARS', 1000 );
const CYR_TO_LAT_TEST_REQUIRED_MAX_INPUT_VARS = 1000;

FunctionMocker::init(
[
Expand Down
6 changes: 6 additions & 0 deletions tests/phpunit/classes/class-cyr-to-lat-testcase.php
Expand Up @@ -88,6 +88,9 @@ abstract class Cyr_To_Lat_TestCase extends TestCase {

/**
* Setup test
*
* @noinspection PhpLanguageLevelInspection
* @noinspection PhpUndefinedClassInspection
*/
public function setUp(): void {
FunctionMocker::setUp();
Expand Down Expand Up @@ -131,6 +134,9 @@ function ( $name ) {

/**
* End test
*
* @noinspection PhpLanguageLevelInspection
* @noinspection PhpUndefinedClassInspection
*/
public function tearDown(): void {
WP_Mock::tearDown();
Expand Down
Expand Up @@ -29,6 +29,9 @@ class Test_Post_Conversion_Process extends Cyr_To_Lat_TestCase {

/**
* End test
*
* @noinspection PhpLanguageLevelInspection
* @noinspection PhpUndefinedClassInspection
*/
public function tearDown(): void {
unset( $GLOBALS['wpdb'] );
Expand Down
Expand Up @@ -28,6 +28,9 @@ class Test_Term_Conversion_Process extends Cyr_To_Lat_TestCase {

/**
* End test
*
* @noinspection PhpLanguageLevelInspection
* @noinspection PhpUndefinedClassInspection
*/
public function tearDown(): void {
unset( $GLOBALS['wpdb'] );
Expand Down
2 changes: 1 addition & 1 deletion tests/phpunit/tests/class-test-admin-notices.php
Expand Up @@ -25,7 +25,7 @@ class Test_Admin_Notices extends Cyr_To_Lat_TestCase {
* @noinspection NullPointerExceptionInspection
*/
public function test_constructor() {
$classname = __NAMESPACE__ . '\Admin_Notices';
$classname = Admin_Notices::class;

// Get mock, without the constructor being called.
$mock = $this->getMockBuilder( $classname )->disableOriginalConstructor()->getMock();
Expand Down
3 changes: 3 additions & 0 deletions tests/phpunit/tests/class-test-converter.php
Expand Up @@ -30,6 +30,9 @@ class Test_Converter extends Cyr_To_Lat_TestCase {

/**
* End test
*
* @noinspection PhpLanguageLevelInspection
* @noinspection PhpUndefinedClassInspection
*/
public function tearDown(): void {
// phpcs:disable WordPress.Security.NonceVerification.Recommended
Expand Down
4 changes: 3 additions & 1 deletion tests/phpunit/tests/class-test-plugin-file.php
Expand Up @@ -22,6 +22,9 @@ class Test_Cyr_To_Lat_Plugin_File extends Cyr_To_Lat_TestCase {

/**
* Tear down.
*
* @noinspection PhpLanguageLevelInspection
* @noinspection PhpUndefinedClassInspection
*/
public function tearDown(): void {
unset( $GLOBALS['cyr_to_lat_plugin'] );
Expand All @@ -38,7 +41,6 @@ public function tearDown(): void {
*
* @runInSeparateProcess
* @preserveGlobalState disabled
* @noinspection PhpIncludeInspection
*/
public function test_main_plugin_file() {
$plugin_dir_url = 'http://test.test/wp-content/plugins/cyr2lat/';
Expand Down
9 changes: 2 additions & 7 deletions tests/phpunit/tests/class-test-requirements.php
Expand Up @@ -31,6 +31,8 @@ class Test_Requirements extends Cyr_To_Lat_TestCase {

/**
* Tear down.
*
* @noinspection PhpLanguageLevelInspection
*/
public function tearDown(): void {
// phpcs:ignore WordPress.Security.NonceVerification.Recommended
Expand Down Expand Up @@ -133,8 +135,6 @@ function ( $arg ) {

/**
* Test if are_requirements_met() returns true when requirements met.
*
* @noinspection PhpSwitchCanBeReplacedWithMatchExpressionInspection
*/
public function test_requirements_met() {
$settings = Mockery::mock( Settings::class );
Expand Down Expand Up @@ -180,8 +180,6 @@ function ( $arg ) {

/**
* Test if are_requirements_met() returns false when php requirements not met.
*
* @noinspection PhpSwitchCanBeReplacedWithMatchExpressionInspection
*/
public function test_php_requirements_not_met() {
$settings = Mockery::mock( Settings::class );
Expand Down Expand Up @@ -249,7 +247,6 @@ function ( $arg ) {
*
* @dataProvider dp_test_vars_requirements_not_met
* @throws ReflectionException ReflectionException.
* @noinspection PhpSwitchCanBeReplacedWithMatchExpressionInspection
*/
public function test_vars_requirements_not_met( $within_timeout, $content, $expected ) {
$max_input_vars = $this->cyr_to_lat_required_max_input_vars - 1;
Expand Down Expand Up @@ -382,8 +379,6 @@ public function dp_test_vars_requirements_not_met() {
/**
* Test are_requirements_met() when max_input_vars requirements not met and filesystem not available.
*
* @noinspection PhpSwitchCanBeReplacedWithMatchExpressionInspection
*
* @throws ReflectionException ReflectionException.
*/
public function test_vars_requirements_not_met_and_filesystem_not_available() {
Expand Down

0 comments on commit e159f75

Please sign in to comment.