From 75ff9d599a249e743fcfd693ad98ac111676f314 Mon Sep 17 00:00:00 2001 From: Enrico Battocchi Date: Mon, 18 Dec 2023 14:38:26 +0100 Subject: [PATCH 1/5] Move source classes to the `Yoast\WHIPv2` namespace Also includes backslashing of the global namespace functions --- .phpcs.xml.dist | 1 + src/Whip_Configuration.php | 14 ++--- src/Whip_Host.php | 21 +++---- src/Whip_MessageDismisser.php | 11 ++-- src/Whip_MessageFormatter.php | 7 +-- src/Whip_MessagesManager.php | 18 +++--- src/Whip_RequirementsChecker.php | 21 ++++--- src/Whip_VersionRequirement.php | 23 ++++---- src/Whip_WPDismissOption.php | 13 ++--- src/Whip_WPMessageDismissListener.php | 19 +++---- src/exceptions/Whip_EmptyProperty.php | 11 ++-- src/exceptions/Whip_InvalidOperatorType.php | 13 ++--- src/exceptions/Whip_InvalidType.php | 11 ++-- .../Whip_InvalidVersionComparisonString.php | 11 ++-- src/facades/wordpress.php | 6 ++ src/interfaces/Whip_DismissStorage.php | 7 +-- src/interfaces/Whip_Listener.php | 7 +-- src/interfaces/Whip_Message.php | 7 +-- src/interfaces/Whip_MessagePresenter.php | 7 +-- src/interfaces/Whip_Requirement.php | 7 +-- src/interfaces/Whip_VersionDetector.php | 7 +-- src/messages/Whip_BasicMessage.php | 13 +++-- src/messages/Whip_HostMessage.php | 15 ++--- .../Whip_InvalidVersionRequirementMessage.php | 12 ++-- src/messages/Whip_NullMessage.php | 9 ++- src/messages/Whip_UpgradePhpMessage.php | 41 +++++++------- src/presenters/Whip_WPMessagePresenter.php | 24 ++++---- tests/Unit/BasicMessageTest.php | 12 ++-- tests/Unit/ConfigurationTest.php | 20 +++---- tests/Unit/Doubles/DismissStorageMock.php | 2 +- tests/Unit/MessageDismisserTest.php | 10 ++-- tests/Unit/MessagesManagerTest.php | 4 +- tests/Unit/RequirementsCheckerTest.php | 56 +++++++++---------- tests/Unit/VersionRequirementTest.php | 50 ++++++++--------- tests/Unit/WPMessageDismissListenerTest.php | 6 +- 35 files changed, 251 insertions(+), 265 deletions(-) diff --git a/.phpcs.xml.dist b/.phpcs.xml.dist index 570f3b9..80fea1b 100644 --- a/.phpcs.xml.dist +++ b/.phpcs.xml.dist @@ -44,6 +44,7 @@ + diff --git a/src/Whip_Configuration.php b/src/Whip_Configuration.php index 97fa2c0..b853d3c 100644 --- a/src/Whip_Configuration.php +++ b/src/Whip_Configuration.php @@ -1,9 +1,9 @@ component(), $this->configuration ); + return \array_key_exists( $requirement->component(), $this->configuration ); } } diff --git a/src/Whip_Host.php b/src/Whip_Host.php index af18121..22e0e26 100644 --- a/src/Whip_Host.php +++ b/src/Whip_Host.php @@ -1,9 +1,6 @@ 0; + return isset( $GLOBALS['whip_messages'] ) && \count( $GLOBALS['whip_messages'] ) > 0; } /** @@ -73,7 +73,7 @@ public function getLatestMessage() { $this->deleteMessages(); - return array_pop( $messages ); + return \array_pop( $messages ); } /** @@ -84,7 +84,7 @@ public function getLatestMessage() { * @return array The sorted list of messages. */ private function sortByVersion( array $messages ) { - uksort( $messages, 'version_compare' ); + \uksort( $messages, 'version_compare' ); return $messages; } diff --git a/src/Whip_RequirementsChecker.php b/src/Whip_RequirementsChecker.php index dabe06a..4982780 100644 --- a/src/Whip_RequirementsChecker.php +++ b/src/Whip_RequirementsChecker.php @@ -1,9 +1,12 @@ requirements ); + return \count( $this->requirements ); } /** @@ -115,11 +118,11 @@ private function requirementIsFulfilled( Whip_Requirement $requirement ) { $availableVersion = $this->configuration->configuredVersion( $requirement ); $requiredVersion = $requirement->version(); - if ( in_array( $requirement->operator(), array( '=', '==', '===' ), true ) ) { - return version_compare( $availableVersion, $requiredVersion, '>=' ); + if ( \in_array( $requirement->operator(), array( '=', '==', '===' ), true ) ) { + return \version_compare( $availableVersion, $requiredVersion, '>=' ); } - return version_compare( $availableVersion, $requiredVersion, $requirement->operator() ); + return \version_compare( $availableVersion, $requiredVersion, $requirement->operator() ); } /** diff --git a/src/Whip_VersionRequirement.php b/src/Whip_VersionRequirement.php index ec0cc0d..ae25f8b 100644 --- a/src/Whip_VersionRequirement.php +++ b/src/Whip_VersionRequirement.php @@ -1,9 +1,12 @@ =<\s]+) # Matches anything except >, <, =, and whitespace. `x'; - if ( ! preg_match( $matcher, $comparisonString, $match ) ) { + if ( ! \preg_match( $matcher, $comparisonString, $match ) ) { throw new Whip_InvalidVersionComparisonString( $comparisonString ); } @@ -122,7 +125,7 @@ private function validateParameters( $component, $version, $operator ) { throw new Whip_EmptyProperty( 'Component' ); } - if ( ! is_string( $component ) ) { + if ( ! \is_string( $component ) ) { throw new Whip_InvalidType( 'Component', $component, 'string' ); } @@ -130,7 +133,7 @@ private function validateParameters( $component, $version, $operator ) { throw new Whip_EmptyProperty( 'Version' ); } - if ( ! is_string( $version ) ) { + if ( ! \is_string( $version ) ) { throw new Whip_InvalidType( 'Version', $version, 'string' ); } @@ -138,12 +141,12 @@ private function validateParameters( $component, $version, $operator ) { throw new Whip_EmptyProperty( 'Operator' ); } - if ( ! is_string( $operator ) ) { + if ( ! \is_string( $operator ) ) { throw new Whip_InvalidType( 'Operator', $operator, 'string' ); } $validOperators = array( '=', '==', '===', '<', '>', '<=', '>=' ); - if ( ! in_array( $operator, $validOperators, true ) ) { + if ( ! \in_array( $operator, $validOperators, true ) ) { throw new Whip_InvalidOperatorType( $operator, $validOperators ); } } diff --git a/src/Whip_WPDismissOption.php b/src/Whip_WPDismissOption.php index 6392323..10a4dc5 100644 --- a/src/Whip_WPDismissOption.php +++ b/src/Whip_WPDismissOption.php @@ -1,9 +1,8 @@ optionName, $dismissedValue ); + return \update_option( $this->optionName, $dismissedValue ); } /** @@ -34,7 +33,7 @@ public function set( $dismissedValue ) { * @return int Returns the value of the option or an empty string when not set. */ public function get() { - $dismissedOption = get_option( $this->optionName ); + $dismissedOption = \get_option( $this->optionName ); if ( ! $dismissedOption ) { return 0; } diff --git a/src/Whip_WPMessageDismissListener.php b/src/Whip_WPMessageDismissListener.php index 9eb6a80..ae3236a 100644 --- a/src/Whip_WPMessageDismissListener.php +++ b/src/Whip_WPMessageDismissListener.php @@ -1,9 +1,8 @@ dismisser->verifyNonce( $nonce, self::ACTION_NAME ) ) { $this->dismisser->dismiss(); @@ -56,10 +55,10 @@ public function listen() { * @return string The url for dismissing the message. */ public function getDismissURL() { - return sprintf( - admin_url( 'index.php?action=%1$s&nonce=%2$s' ), + return \sprintf( + \admin_url( 'index.php?action=%1$s&nonce=%2$s' ), self::ACTION_NAME, - wp_create_nonce( self::ACTION_NAME ) + \wp_create_nonce( self::ACTION_NAME ) ); } } diff --git a/src/exceptions/Whip_EmptyProperty.php b/src/exceptions/Whip_EmptyProperty.php index 06ed367..141d209 100644 --- a/src/exceptions/Whip_EmptyProperty.php +++ b/src/exceptions/Whip_EmptyProperty.php @@ -1,9 +1,8 @@ ', '<=', '>=' ) ) { parent::__construct( - sprintf( + \sprintf( 'Invalid operator of %s used. Please use one of the following operators: %s', $value, - implode( ', ', $validOperators ) + \implode( ', ', $validOperators ) ) ); } diff --git a/src/exceptions/Whip_InvalidType.php b/src/exceptions/Whip_InvalidType.php index ad45e24..1cb13fa 100644 --- a/src/exceptions/Whip_InvalidType.php +++ b/src/exceptions/Whip_InvalidType.php @@ -1,9 +1,8 @@ =5.3. Passed version comparison string: %s', $value ) diff --git a/src/facades/wordpress.php b/src/facades/wordpress.php index 5bee96b..92b636b 100644 --- a/src/facades/wordpress.php +++ b/src/facades/wordpress.php @@ -5,6 +5,12 @@ * @package Yoast\WHIP */ +use Yoast\WHIPv2\Presenters\Whip_WPMessagePresenter; +use Yoast\WHIPv2\Whip_MessageDismisser; +use Yoast\WHIPv2\Whip_RequirementsChecker; +use Yoast\WHIPv2\Whip_VersionRequirement; +use Yoast\WHIPv2\Whip_WPDismissOption; + if ( ! function_exists( 'whip_wp_check_versions' ) ) { /** * Facade to quickly check if version requirements are met. diff --git a/src/interfaces/Whip_DismissStorage.php b/src/interfaces/Whip_DismissStorage.php index 5cf99f5..96a4f46 100644 --- a/src/interfaces/Whip_DismissStorage.php +++ b/src/interfaces/Whip_DismissStorage.php @@ -1,9 +1,6 @@ title() ) . '
'; $message[] = Whip_MessageFormatter::paragraph( Whip_Host::message( $this->messageKey ) ); - return implode( "\n", $message ); + return \implode( "\n", $message ); } /** @@ -56,6 +57,6 @@ public function body() { */ public function title() { /* translators: 1: name. */ - return sprintf( __( 'A message from %1$s', $this->textdomain ), Whip_Host::name() ); + return \sprintf( \__( 'A message from %1$s', $this->textdomain ), Whip_Host::name() ); } } diff --git a/src/messages/Whip_InvalidVersionRequirementMessage.php b/src/messages/Whip_InvalidVersionRequirementMessage.php index 1b33288..1b0c6f8 100644 --- a/src/messages/Whip_InvalidVersionRequirementMessage.php +++ b/src/messages/Whip_InvalidVersionRequirementMessage.php @@ -1,9 +1,9 @@ requirement->component(), $this->detected, diff --git a/src/messages/Whip_NullMessage.php b/src/messages/Whip_NullMessage.php index 1134036..5667d4d 100644 --- a/src/messages/Whip_NullMessage.php +++ b/src/messages/Whip_NullMessage.php @@ -1,9 +1,8 @@ '; - $message[] = Whip_MessageFormatter::paragraph( __( 'Hey, we\'ve noticed that you\'re running an outdated version of PHP. PHP is the programming language that WordPress and all its plugins and themes are built on. The version that is currently used for your site is no longer supported. Newer versions of PHP are both faster and more secure. In fact, your version of PHP no longer receives security updates, which is why we\'re sending you to this notice.', $textdomain ) ); - $message[] = Whip_MessageFormatter::paragraph( __( 'Hosts have the ability to update your PHP version, but sometimes they don\'t dare to do that because they\'re afraid they\'ll break your site.', $textdomain ) ); - $message[] = Whip_MessageFormatter::strongParagraph( __( 'To which version should I update?', $textdomain ) ) . '
'; + $message[] = Whip_MessageFormatter::strongParagraph( \__( 'Your site could be faster and more secure with a newer PHP version.', $textdomain ) ) . '
'; + $message[] = Whip_MessageFormatter::paragraph( \__( 'Hey, we\'ve noticed that you\'re running an outdated version of PHP. PHP is the programming language that WordPress and all its plugins and themes are built on. The version that is currently used for your site is no longer supported. Newer versions of PHP are both faster and more secure. In fact, your version of PHP no longer receives security updates, which is why we\'re sending you to this notice.', $textdomain ) ); + $message[] = Whip_MessageFormatter::paragraph( \__( 'Hosts have the ability to update your PHP version, but sometimes they don\'t dare to do that because they\'re afraid they\'ll break your site.', $textdomain ) ); + $message[] = Whip_MessageFormatter::strongParagraph( \__( 'To which version should I update?', $textdomain ) ) . '
'; $message[] = Whip_MessageFormatter::paragraph( - sprintf( + \sprintf( /* translators: 1: link open tag; 2: link close tag. */ - __( 'You should update your PHP version to either 5.6 or to 7.0 or 7.1. On a normal WordPress site, switching to PHP 5.6 should never cause issues. We would however actually recommend you switch to PHP7. There are some plugins that are not ready for PHP7 though, so do some testing first. We have an article on how to test whether that\'s an option for you %1$shere%2$s. PHP7 is much faster than PHP 5.6. It\'s also the only PHP version still in active development and therefore the better option for your site in the long run.', $textdomain ), + \__( 'You should update your PHP version to either 5.6 or to 7.0 or 7.1. On a normal WordPress site, switching to PHP 5.6 should never cause issues. We would however actually recommend you switch to PHP7. There are some plugins that are not ready for PHP7 though, so do some testing first. We have an article on how to test whether that\'s an option for you %1$shere%2$s. PHP7 is much faster than PHP 5.6. It\'s also the only PHP version still in active development and therefore the better option for your site in the long run.', $textdomain ), '', '' ) @@ -56,31 +57,31 @@ public function body() { $hostingPageUrl = Whip_Host::hostingPageUrl(); - $message[] = Whip_MessageFormatter::strongParagraph( __( 'Can\'t update? Ask your host!', $textdomain ) ) . '
'; + $message[] = Whip_MessageFormatter::strongParagraph( \__( 'Can\'t update? Ask your host!', $textdomain ) ) . '
'; - if ( function_exists( 'apply_filters' ) && apply_filters( Whip_Host::HOSTING_PAGE_FILTER_KEY, false ) ) { + if ( \function_exists( 'apply_filters' ) && \apply_filters( Whip_Host::HOSTING_PAGE_FILTER_KEY, false ) ) { $message[] = Whip_MessageFormatter::paragraph( - sprintf( + \sprintf( /* translators: 1: link open tag; 2: link close tag; 3: link open tag. */ - __( 'If you cannot upgrade your PHP version yourself, you can send an email to your host. We have %1$sexamples here%2$s. If they don\'t want to upgrade your PHP version, we would suggest you switch hosts. Have a look at one of the recommended %3$sWordPress hosting partners%2$s.', $textdomain ), + \__( 'If you cannot upgrade your PHP version yourself, you can send an email to your host. We have %1$sexamples here%2$s. If they don\'t want to upgrade your PHP version, we would suggest you switch hosts. Have a look at one of the recommended %3$sWordPress hosting partners%2$s.', $textdomain ), '', '', - sprintf( '', esc_url( $hostingPageUrl ) ) + \sprintf( '', \esc_url( $hostingPageUrl ) ) ) ); } else { $message[] = Whip_MessageFormatter::paragraph( - sprintf( + \sprintf( /* translators: 1: link open tag; 2: link close tag; 3: link open tag. */ - __( 'If you cannot upgrade your PHP version yourself, you can send an email to your host. We have %1$sexamples here%2$s. If they don\'t want to upgrade your PHP version, we would suggest you switch hosts. Have a look at one of our recommended %3$sWordPress hosting partners%2$s, they\'ve all been vetted by the Yoast support team and provide all the features a modern host should provide.', $textdomain ), + \__( 'If you cannot upgrade your PHP version yourself, you can send an email to your host. We have %1$sexamples here%2$s. If they don\'t want to upgrade your PHP version, we would suggest you switch hosts. Have a look at one of our recommended %3$sWordPress hosting partners%2$s, they\'ve all been vetted by the Yoast support team and provide all the features a modern host should provide.', $textdomain ), '', '', - sprintf( '', esc_url( $hostingPageUrl ) ) + \sprintf( '', \esc_url( $hostingPageUrl ) ) ) ); } - return implode( "\n", $message ); + return \implode( "\n", $message ); } } diff --git a/src/presenters/Whip_WPMessagePresenter.php b/src/presenters/Whip_WPMessagePresenter.php index 17610fd..dedd8a7 100644 --- a/src/presenters/Whip_WPMessagePresenter.php +++ b/src/presenters/Whip_WPMessagePresenter.php @@ -1,9 +1,11 @@ %1$s', - esc_html( $this->dismissMessage ), - esc_url( $dismissListener->getDismissURL() ) + \esc_html( $this->dismissMessage ), + \esc_url( $dismissListener->getDismissURL() ) ); // phpcs:disable WordPress.Security.EscapeOutput.OutputNotEscaped -- output correctly escaped directly above and in the `kses()` method. - printf( + \printf( '

%1$s

%2$s

', $this->kses( $this->message->body() ), $dismissButton @@ -91,7 +93,7 @@ public function renderMessage() { * @return string The cleaned message. */ public function kses( $message ) { - return wp_kses( + return \wp_kses( $message, array( 'a' => array( diff --git a/tests/Unit/BasicMessageTest.php b/tests/Unit/BasicMessageTest.php index ffc3601..b8be6fd 100644 --- a/tests/Unit/BasicMessageTest.php +++ b/tests/Unit/BasicMessageTest.php @@ -2,7 +2,7 @@ namespace Yoast\WHIP\Tests\Unit; -use Whip_BasicMessage; +use Yoast\WHIPv2\Messages\Whip_BasicMessage; /** * Message Unit tests. @@ -12,7 +12,7 @@ final class BasicMessageTest extends TestCase { /** * Tests if Whip_BasicMessage correctly handles a string for its body argument. * - * @covers Whip_BasicMessage::body + * @covers \Yoast\WHIPv2\Messages\Whip_BasicMessage::body * * @return void */ @@ -25,12 +25,12 @@ public function testMessageHasBody() { /** * Tests if an Exception is correctly thrown when an empty string is passed as argument. * - * @covers Whip_BasicMessage::validateParameters + * @covers \Yoast\WHIPv2\Messages\Whip_BasicMessage::validateParameters * * @return void */ public function testMessageCannotBeEmpty() { - $this->expectExceptionHelper( 'Whip_EmptyProperty', 'Message body cannot be empty.' ); + $this->expectExceptionHelper( '\Yoast\WHIPv2\Exceptions\Whip_EmptyProperty', 'Message body cannot be empty.' ); new Whip_BasicMessage( '' ); } @@ -38,12 +38,12 @@ public function testMessageCannotBeEmpty() { /** * Tests if an Exception is correctly thrown when an invalid type is passed as argument. * - * @covers Whip_BasicMessage::validateParameters + * @covers \Yoast\WHIPv2\Messages\Whip_BasicMessage::validateParameters * * @return void */ public function testMessageMustBeString() { - $this->expectExceptionHelper( 'Whip_InvalidType', 'Message body should be of type string. Found integer.' ); + $this->expectExceptionHelper( '\Yoast\WHIPv2\Exceptions\Whip_InvalidType', 'Message body should be of type string. Found integer.' ); new Whip_BasicMessage( 123 ); } diff --git a/tests/Unit/ConfigurationTest.php b/tests/Unit/ConfigurationTest.php index 644ab60..8bfe07f 100644 --- a/tests/Unit/ConfigurationTest.php +++ b/tests/Unit/ConfigurationTest.php @@ -2,7 +2,7 @@ namespace Yoast\WHIP\Tests\Unit; -use Whip_Configuration; +use Yoast\WHIPv2\Whip_Configuration; /** * Configuration unit tests. @@ -12,12 +12,12 @@ final class ConfigurationTest extends TestCase { /** * Tests the creation of a Whip_Configuration with invalid input. * - * @covers Whip_Configuration::__construct + * @covers \Yoast\WHIPv2\Whip_Configuration::__construct * * @return void */ public function testItThrowsAnErrorIfAFaultyConfigurationIsPassed() { - $this->expectExceptionHelper( 'Whip_InvalidType', 'Configuration should be of type array. Found string.' ); + $this->expectExceptionHelper( '\Yoast\WHIPv2\Exceptions\Whip_InvalidType', 'Configuration should be of type array. Found string.' ); new Whip_Configuration( 'Invalid configuration' ); } @@ -25,13 +25,13 @@ public function testItThrowsAnErrorIfAFaultyConfigurationIsPassed() { /** * Tests if Whip_Configuration correctly returns -1 when passed an unknown requirement. * - * @covers Whip_Configuration::configuredVersion + * @covers \Yoast\WHIPv2\Whip_Configuration::configuredVersion * * @return void */ public function testItReturnsANegativeNumberIfRequirementCannotBeFound() { $configuration = new Whip_Configuration( array( 'php' => '5.6' ) ); - $requirement = $this->getMockBuilder( 'Whip_Requirement' ) + $requirement = $this->getMockBuilder( '\Yoast\WHIPv2\Interfaces\Whip_Requirement' ) ->setMethods( array( 'component', 'version', 'operator' ) ) ->getMock(); @@ -46,13 +46,13 @@ public function testItReturnsANegativeNumberIfRequirementCannotBeFound() { /** * Tests if Whip_Configuration correctly returns the version number when passed a valid requirement. * - * @covers Whip_Configuration::configuredVersion + * @covers \Yoast\WHIPv2\Whip_Configuration::configuredVersion * * @return void */ public function testItReturnsAnEntryIfRequirementIsFound() { $configuration = new Whip_Configuration( array( 'php' => '5.6' ) ); - $requirement = $this->getMockBuilder( 'Whip_Requirement' ) + $requirement = $this->getMockBuilder( '\Yoast\WHIPv2\Interfaces\Whip_Requirement' ) ->setMethods( array( 'component', 'version', 'operator' ) ) ->getMock(); @@ -67,13 +67,13 @@ public function testItReturnsAnEntryIfRequirementIsFound() { /** * Tests if hasRequirementConfigures correctly returns true/false when called with valid/invalid values. * - * @covers Whip_Configuration::hasRequirementConfigured + * @covers \Yoast\WHIPv2\Whip_Configuration::hasRequirementConfigured * * @return void */ public function testIfRequirementIsConfigured() { $configuration = new Whip_Configuration( array( 'php' => '5.6' ) ); - $requirement = $this->getMockBuilder( 'Whip_Requirement' ) + $requirement = $this->getMockBuilder( '\Yoast\WHIPv2\Interfaces\Whip_Requirement' ) ->setMethods( array( 'component', 'version', 'operator' ) ) ->getMock(); @@ -82,7 +82,7 @@ public function testIfRequirementIsConfigured() { ->method( 'component' ) ->will( $this->returnValue( 'php' ) ); - $falseRequirement = $this->getMockBuilder( 'Whip_Requirement' ) + $falseRequirement = $this->getMockBuilder( '\Yoast\WHIPv2\Interfaces\Whip_Requirement' ) ->setMethods( array( 'component', 'version', 'operator' ) ) ->getMock(); diff --git a/tests/Unit/Doubles/DismissStorageMock.php b/tests/Unit/Doubles/DismissStorageMock.php index 4fab54b..152a961 100644 --- a/tests/Unit/Doubles/DismissStorageMock.php +++ b/tests/Unit/Doubles/DismissStorageMock.php @@ -2,7 +2,7 @@ namespace Yoast\WHIP\Tests\Unit\Doubles; -use Whip_DismissStorage; +use Yoast\WHIPv2\Interfaces\Whip_DismissStorage; /** * Test helper. diff --git a/tests/Unit/MessageDismisserTest.php b/tests/Unit/MessageDismisserTest.php index 4b76ccb..9fbd374 100644 --- a/tests/Unit/MessageDismisserTest.php +++ b/tests/Unit/MessageDismisserTest.php @@ -2,8 +2,8 @@ namespace Yoast\WHIP\Tests\Unit; -use Whip_MessageDismisser; use Yoast\WHIP\Tests\Unit\Doubles\DismissStorageMock; +use Yoast\WHIPv2\Whip_MessageDismisser; /** * Message Dismisser unit tests. @@ -13,8 +13,8 @@ final class MessageDismisserTest extends TestCase { /** * Tests if Whip_MessageDismisser correctly updates Whip_DismissStorage. * - * @covers Whip_MessageDismisser::__construct - * @covers Whip_MessageDismisser::dismiss + * @covers \Yoast\WHIPv2\Whip_MessageDismisser::__construct + * @covers \Yoast\WHIPv2\Whip_MessageDismisser::dismiss * * @return void */ @@ -35,8 +35,8 @@ public function testDismiss() { * * @dataProvider versionNumbersProvider * - * @covers Whip_MessageDismisser::__construct - * @covers Whip_MessageDismisser::isDismissed + * @covers \Yoast\WHIPv2\Whip_MessageDismisser::__construct + * @covers \Yoast\WHIPv2\Whip_MessageDismisser::isDismissed * * @param int $savedTime The saved time. * @param int $currentTime The current time. diff --git a/tests/Unit/MessagesManagerTest.php b/tests/Unit/MessagesManagerTest.php index a69d27a..7c52b0a 100644 --- a/tests/Unit/MessagesManagerTest.php +++ b/tests/Unit/MessagesManagerTest.php @@ -2,7 +2,7 @@ namespace Yoast\WHIP\Tests\Unit; -use Whip_MessagesManager; +use Yoast\WHIPv2\Whip_MessagesManager; /** * Message Manager unit tests. @@ -13,7 +13,7 @@ final class MessagesManagerTest extends TestCase { * Creates a MessagesManager, calls hasMessages and tests if it returns false * without a message, true when given a message. * - * @covers Whip_MessagesManager::hasMessages + * @covers \Yoast\WHIPv2\Whip_MessagesManager::hasMessages * * @return void */ diff --git a/tests/Unit/RequirementsCheckerTest.php b/tests/Unit/RequirementsCheckerTest.php index 7b750c8..08abc23 100644 --- a/tests/Unit/RequirementsCheckerTest.php +++ b/tests/Unit/RequirementsCheckerTest.php @@ -5,8 +5,8 @@ use Error; use Exception; use stdClass; -use Whip_RequirementsChecker; -use Whip_VersionRequirement; +use Yoast\WHIPv2\Whip_RequirementsChecker; +use Yoast\WHIPv2\Whip_VersionRequirement; /** * Requirements checker unit tests. @@ -16,8 +16,8 @@ final class RequirementsCheckerTest extends TestCase { /** * Tests if Whip_RequirementsChecker is successfully created when given valid arguments. * - * @covers Whip_RequirementsChecker::addRequirement - * @covers Whip_RequirementsChecker::totalRequirements + * @covers \Yoast\WHIPv2\Whip_RequirementsChecker::addRequirement + * @covers \Yoast\WHIPv2\Whip_RequirementsChecker::totalRequirements * * @return void */ @@ -58,7 +58,7 @@ public function testItThrowsAnTypeErrorWhenInvalidRequirementIsPassed() { /** * Tests if Whip_RequirementsChecker throws an error when passed an invalid requirement. * - * @covers Whip_RequirementsChecker::addRequirement + * @covers \Yoast\WHIPv2\Whip_RequirementsChecker::addRequirement * * @return void */ @@ -83,8 +83,8 @@ public function testItThrowsAnTypeErrorWhenInvalidRequirementIsPassedInPHP5() { /** * Tests if Whip_RequirementsChecker only saves unique components. * - * @covers Whip_RequirementsChecker::addRequirement - * @covers Whip_RequirementsChecker::totalRequirements + * @covers \Yoast\WHIPv2\Whip_RequirementsChecker::addRequirement + * @covers \Yoast\WHIPv2\Whip_RequirementsChecker::totalRequirements * * @return void */ @@ -106,8 +106,8 @@ public function testItOnlyContainsUniqueComponents() { * Tests if Whip_RequirementsChecker::requirementExistsForComponent correctly * returns true for existing components. * - * @covers Whip_RequirementsChecker::addRequirement - * @covers Whip_RequirementsChecker::requirementExistsForComponent + * @covers \Yoast\WHIPv2\Whip_RequirementsChecker::addRequirement + * @covers \Yoast\WHIPv2\Whip_RequirementsChecker::requirementExistsForComponent * * @return void */ @@ -126,10 +126,10 @@ public function testIfRequirementExists() { * * Verifies that a php upgrade message is created and successfully transferred to a variable. * - * @covers Whip_RequirementsChecker::addRequirement - * @covers Whip_RequirementsChecker::check - * @covers Whip_RequirementsChecker::hasMessages - * @covers Whip_RequirementsChecker::getMostRecentMessage + * @covers \Yoast\WHIPv2\Whip_RequirementsChecker::addRequirement + * @covers \Yoast\WHIPv2\Whip_RequirementsChecker::check + * @covers \Yoast\WHIPv2\Whip_RequirementsChecker::hasMessages + * @covers \Yoast\WHIPv2\Whip_RequirementsChecker::getMostRecentMessage * * @return void */ @@ -155,15 +155,15 @@ public function testCheckIfPHPRequirementIsNotFulfilled() { } $this->assertFalse( $checker->hasMessages() ); - $this->assertInstanceOf( 'Whip_UpgradePhpMessage', $recentMessage ); + $this->assertInstanceOf( '\Yoast\WHIPv2\Messages\Whip_UpgradePhpMessage', $recentMessage ); } /** * Tests if there no message when the requirement is fulfilled. * - * @covers Whip_RequirementsChecker::addRequirement - * @covers Whip_RequirementsChecker::check - * @covers Whip_RequirementsChecker::getMostRecentMessage + * @covers \Yoast\WHIPv2\Whip_RequirementsChecker::addRequirement + * @covers \Yoast\WHIPv2\Whip_RequirementsChecker::check + * @covers \Yoast\WHIPv2\Whip_RequirementsChecker::getMostRecentMessage * * @return void */ @@ -181,10 +181,10 @@ public function testCheckIfRequirementIsFulfilled() { * * Verifies that an invalid version message is created and successfully transferred to a variable. * - * @covers Whip_RequirementsChecker::addRequirement - * @covers Whip_RequirementsChecker::check - * @covers Whip_RequirementsChecker::getMostRecentMessage - * @covers Whip_RequirementsChecker::hasMessages + * @covers \Yoast\WHIPv2\Whip_RequirementsChecker::addRequirement + * @covers \Yoast\WHIPv2\Whip_RequirementsChecker::check + * @covers \Yoast\WHIPv2\Whip_RequirementsChecker::getMostRecentMessage + * @covers \Yoast\WHIPv2\Whip_RequirementsChecker::hasMessages * * @return void */ @@ -201,16 +201,16 @@ public function testCheckIfRequirementIsNotFulfilled() { $this->assertNotEmpty( $recentMessage ); $this->assertFalse( $checker->hasMessages() ); - $this->assertInstanceOf( 'Whip_InvalidVersionRequirementMessage', $recentMessage ); + $this->assertInstanceOf( '\Yoast\WHIPv2\Messages\Whip_InvalidVersionRequirementMessage', $recentMessage ); $this->assertStringStartsWith( 'Invalid version detected', $recentMessage->body() ); } /** * Tests if a specific comparison with a non-default operator is correctly handled. * - * @covers Whip_RequirementsChecker::addRequirement - * @covers Whip_RequirementsChecker::check - * @covers Whip_RequirementsChecker::hasMessages + * @covers \Yoast\WHIPv2\Whip_RequirementsChecker::addRequirement + * @covers \Yoast\WHIPv2\Whip_RequirementsChecker::check + * @covers \Yoast\WHIPv2\Whip_RequirementsChecker::hasMessages * * @return void */ @@ -226,9 +226,9 @@ public function testCheckIfRequirementIsFulfilledWithSpecificComparison() { /** * Tests if a specific comparison with a non-default operator is correctly handled. * - * @covers Whip_RequirementsChecker::addRequirement - * @covers Whip_RequirementsChecker::check - * @covers Whip_RequirementsChecker::hasMessages + * @covers \Yoast\WHIPv2\Whip_RequirementsChecker::addRequirement + * @covers \Yoast\WHIPv2\Whip_RequirementsChecker::check + * @covers \Yoast\WHIPv2\Whip_RequirementsChecker::hasMessages * * @return void */ diff --git a/tests/Unit/VersionRequirementTest.php b/tests/Unit/VersionRequirementTest.php index 4188f20..2420c9e 100644 --- a/tests/Unit/VersionRequirementTest.php +++ b/tests/Unit/VersionRequirementTest.php @@ -2,7 +2,7 @@ namespace Yoast\WHIP\Tests\Unit; -use Whip_VersionRequirement; +use Yoast\WHIPv2\Whip_VersionRequirement; /** * Version requirements unit tests. @@ -13,8 +13,8 @@ final class VersionRequirementTest extends TestCase { * Creates a new Whip_VersionRequirement with component php and version 5.2 and * tests if this is correctly created. * - * @covers Whip_VersionRequirement::component - * @covers Whip_VersionRequirement::version + * @covers \Yoast\WHIPv2\Whip_VersionRequirement::component + * @covers \Yoast\WHIPv2\Whip_VersionRequirement::version * * @return void */ @@ -29,12 +29,12 @@ public function testNameAndVersionAreNotEmpty() { * Tests if an Exception message is correctly thrown when a Whip_VersionRequirement * is created with an empty component. * - * @covers Whip_VersionRequirement::validateParameters + * @covers \Yoast\WHIPv2\Whip_VersionRequirement::validateParameters * * @return void */ public function testComponentCannotBeEmpty() { - $this->expectExceptionHelper( 'Whip_EmptyProperty', 'Component cannot be empty.' ); + $this->expectExceptionHelper( '\Yoast\WHIPv2\Exceptions\Whip_EmptyProperty', 'Component cannot be empty.' ); new Whip_VersionRequirement( '', '5.2' ); } @@ -43,12 +43,12 @@ public function testComponentCannotBeEmpty() { * Tests if an Exception message is correctly thrown when a Whip_VersionRequirement * is created with an empty version. * - * @covers Whip_VersionRequirement::validateParameters + * @covers \Yoast\WHIPv2\Whip_VersionRequirement::validateParameters * * @return void */ public function testVersionCannotBeEmpty() { - $this->expectExceptionHelper( 'Whip_EmptyProperty', 'Version cannot be empty.' ); + $this->expectExceptionHelper( '\Yoast\WHIPv2\Exceptions\Whip_EmptyProperty', 'Version cannot be empty.' ); new Whip_VersionRequirement( 'php', '' ); } @@ -57,12 +57,12 @@ public function testVersionCannotBeEmpty() { * Tests if an Exception message is correctly thrown when a Whip_VersionRequirement * is created with a false type for a component. * - * @covers Whip_VersionRequirement::validateParameters + * @covers \Yoast\WHIPv2\Whip_VersionRequirement::validateParameters * * @return void */ public function testComponentMustBeString() { - $this->expectExceptionHelper( 'Whip_InvalidType', 'Component should be of type string. Found integer.' ); + $this->expectExceptionHelper( '\Yoast\WHIPv2\Exceptions\Whip_InvalidType', 'Component should be of type string. Found integer.' ); new Whip_VersionRequirement( 123, '5.2' ); } @@ -71,12 +71,12 @@ public function testComponentMustBeString() { * Tests if an Exception message is correctly thrown when a Whip_VersionRequirement * is created with a false type for a version. * - * @covers Whip_VersionRequirement::validateParameters + * @covers \Yoast\WHIPv2\Whip_VersionRequirement::validateParameters * * @return void */ public function testVersionMustBeString() { - $this->expectExceptionHelper( 'Whip_InvalidType', 'Version should be of type string. Found integer.' ); + $this->expectExceptionHelper( '\Yoast\WHIPv2\Exceptions\Whip_InvalidType', 'Version should be of type string. Found integer.' ); new Whip_VersionRequirement( 'php', 123 ); } @@ -85,12 +85,12 @@ public function testVersionMustBeString() { * Tests if an Exception message is correctly thrown when a Whip_VersionRequirement * is created with an empty operator. * - * @covers Whip_VersionRequirement::validateParameters + * @covers \Yoast\WHIPv2\Whip_VersionRequirement::validateParameters * * @return void */ public function testOperatorCannotBeEmpty() { - $this->expectExceptionHelper( 'Whip_EmptyProperty', 'Operator cannot be empty.' ); + $this->expectExceptionHelper( '\Yoast\WHIPv2\Exceptions\Whip_EmptyProperty', 'Operator cannot be empty.' ); new Whip_VersionRequirement( 'php', '5.6', '' ); } @@ -99,12 +99,12 @@ public function testOperatorCannotBeEmpty() { * Tests if an Exception message is correctly thrown when a Whip_VersionRequirement * is created with a false type for an operator. * - * @covers Whip_VersionRequirement::validateParameters + * @covers \Yoast\WHIPv2\Whip_VersionRequirement::validateParameters * * @return void */ public function testOperatorMustBeString() { - $this->expectExceptionHelper( 'Whip_InvalidType', 'Operator should be of type string. Found integer.' ); + $this->expectExceptionHelper( '\Yoast\WHIPv2\Exceptions\Whip_InvalidType', 'Operator should be of type string. Found integer.' ); new Whip_VersionRequirement( 'php', '5.2', 6 ); } @@ -113,13 +113,13 @@ public function testOperatorMustBeString() { * Tests if an Exception message is correctly thrown when a Whip_VersionRequirement * is created with an invalid operator. * - * @covers Whip_VersionRequirement::validateParameters + * @covers \Yoast\WHIPv2\Whip_VersionRequirement::validateParameters * * @return void */ public function testOperatorMustBeValid() { $this->expectExceptionHelper( - 'Whip_InvalidOperatorType', + '\Yoast\WHIPv2\Exceptions\Whip_InvalidOperatorType', 'Invalid operator of -> used. Please use one of the following operators: =, ==, ===, <, >, <=, >=' ); @@ -129,9 +129,9 @@ public function testOperatorMustBeValid() { /** * Creates a new Whip_VersionRequirement and tests if this is correctly created with its given arguments. * - * @covers Whip_VersionRequirement::component - * @covers Whip_VersionRequirement::version - * @covers Whip_VersionRequirement::operator + * @covers \Yoast\WHIPv2\Whip_VersionRequirement::component + * @covers \Yoast\WHIPv2\Whip_VersionRequirement::version + * @covers \Yoast\WHIPv2\Whip_VersionRequirement::operator * * @return void */ @@ -148,9 +148,9 @@ public function testGettingComponentProperties() { * * @dataProvider dataFromCompareString * - * @covers Whip_VersionRequirement::component - * @covers Whip_VersionRequirement::version - * @covers Whip_VersionRequirement::operator + * @covers \Yoast\WHIPv2\Whip_VersionRequirement::component + * @covers \Yoast\WHIPv2\Whip_VersionRequirement::version + * @covers \Yoast\WHIPv2\Whip_VersionRequirement::operator * * @param string $expectation The expected output string. * @param string $component The component for this version requirement. @@ -188,13 +188,13 @@ public static function dataFromCompareString() { * Tests whether fromCompareString() correctly throws an exception when provided * with an invalid comparison string. * - * @covers Whip_VersionRequirement::fromCompareString + * @covers \Yoast\WHIPv2\Whip_VersionRequirement::fromCompareString * * @return void */ public function testFromCompareStringException() { $this->expectExceptionHelper( - 'Whip_InvalidVersionComparisonString', + '\Yoast\WHIPv2\Exceptions\Whip_InvalidVersionComparisonString', 'Invalid version comparison string. Example of a valid version comparison string: >=5.3. Passed version comparison string: > 2.3' ); diff --git a/tests/Unit/WPMessageDismissListenerTest.php b/tests/Unit/WPMessageDismissListenerTest.php index 00ff2ae..9873e7a 100644 --- a/tests/Unit/WPMessageDismissListenerTest.php +++ b/tests/Unit/WPMessageDismissListenerTest.php @@ -2,7 +2,7 @@ namespace Yoast\WHIP\Tests\Unit; -use Whip_WPMessageDismissListener; +use Yoast\WHIPv2\Whip_WPMessageDismissListener; /** * Message Dismiss Listener unit tests. @@ -16,7 +16,7 @@ final class WPMessageDismissListenerTest extends TestCase { /** * Tests the listen method. * - * @covers ::listen + * @covers \Yoast\WHIPv2\Whip_WPMessageDismissListener::listen * * @dataProvider listenProvider * @@ -29,7 +29,7 @@ final class WPMessageDismissListenerTest extends TestCase { * @return void */ public function testDismiss( $action, $nonce, $verifyNonceTimes, $isCorrectNonce, $dismissTimes ) { - $dismisser = $this->getMockBuilder( 'Whip_MessageDismisser' ) + $dismisser = $this->getMockBuilder( '\Yoast\WHIPv2\Whip_MessageDismisser' ) ->disableOriginalConstructor() ->getMock(); From dd55a033fe4552ed2712eef12e1ed763561948e9 Mon Sep 17 00:00:00 2001 From: Enrico Battocchi Date: Tue, 19 Dec 2023 13:22:50 +0100 Subject: [PATCH 2/5] Switch to PSR-4 folder naming and autoloader --- composer.json | 6 +++--- src/{exceptions => Exceptions}/Whip_EmptyProperty.php | 0 src/{exceptions => Exceptions}/Whip_InvalidOperatorType.php | 0 src/{exceptions => Exceptions}/Whip_InvalidType.php | 0 .../Whip_InvalidVersionComparisonString.php | 0 src/{interfaces => Interfaces}/Whip_DismissStorage.php | 0 src/{interfaces => Interfaces}/Whip_Listener.php | 0 src/{interfaces => Interfaces}/Whip_Message.php | 0 src/{interfaces => Interfaces}/Whip_MessagePresenter.php | 0 src/{interfaces => Interfaces}/Whip_Requirement.php | 0 src/{interfaces => Interfaces}/Whip_VersionDetector.php | 0 src/{messages => Messages}/Whip_BasicMessage.php | 0 src/{messages => Messages}/Whip_HostMessage.php | 0 .../Whip_InvalidVersionRequirementMessage.php | 0 src/{messages => Messages}/Whip_NullMessage.php | 0 src/{messages => Messages}/Whip_UpgradePhpMessage.php | 0 src/{presenters => Presenters}/Whip_WPMessagePresenter.php | 0 17 files changed, 3 insertions(+), 3 deletions(-) rename src/{exceptions => Exceptions}/Whip_EmptyProperty.php (100%) rename src/{exceptions => Exceptions}/Whip_InvalidOperatorType.php (100%) rename src/{exceptions => Exceptions}/Whip_InvalidType.php (100%) rename src/{exceptions => Exceptions}/Whip_InvalidVersionComparisonString.php (100%) rename src/{interfaces => Interfaces}/Whip_DismissStorage.php (100%) rename src/{interfaces => Interfaces}/Whip_Listener.php (100%) rename src/{interfaces => Interfaces}/Whip_Message.php (100%) rename src/{interfaces => Interfaces}/Whip_MessagePresenter.php (100%) rename src/{interfaces => Interfaces}/Whip_Requirement.php (100%) rename src/{interfaces => Interfaces}/Whip_VersionDetector.php (100%) rename src/{messages => Messages}/Whip_BasicMessage.php (100%) rename src/{messages => Messages}/Whip_HostMessage.php (100%) rename src/{messages => Messages}/Whip_InvalidVersionRequirementMessage.php (100%) rename src/{messages => Messages}/Whip_NullMessage.php (100%) rename src/{messages => Messages}/Whip_UpgradePhpMessage.php (100%) rename src/{presenters => Presenters}/Whip_WPMessagePresenter.php (100%) diff --git a/composer.json b/composer.json index c407e48..233f511 100644 --- a/composer.json +++ b/composer.json @@ -28,9 +28,9 @@ "minimum-stability": "dev", "prefer-stable": true, "autoload": { - "classmap": [ - "src/" - ], + "psr-4": { + "Yoast\\WHIPv2\\": "src/" + }, "files": [ "src/facades/wordpress.php" ] diff --git a/src/exceptions/Whip_EmptyProperty.php b/src/Exceptions/Whip_EmptyProperty.php similarity index 100% rename from src/exceptions/Whip_EmptyProperty.php rename to src/Exceptions/Whip_EmptyProperty.php diff --git a/src/exceptions/Whip_InvalidOperatorType.php b/src/Exceptions/Whip_InvalidOperatorType.php similarity index 100% rename from src/exceptions/Whip_InvalidOperatorType.php rename to src/Exceptions/Whip_InvalidOperatorType.php diff --git a/src/exceptions/Whip_InvalidType.php b/src/Exceptions/Whip_InvalidType.php similarity index 100% rename from src/exceptions/Whip_InvalidType.php rename to src/Exceptions/Whip_InvalidType.php diff --git a/src/exceptions/Whip_InvalidVersionComparisonString.php b/src/Exceptions/Whip_InvalidVersionComparisonString.php similarity index 100% rename from src/exceptions/Whip_InvalidVersionComparisonString.php rename to src/Exceptions/Whip_InvalidVersionComparisonString.php diff --git a/src/interfaces/Whip_DismissStorage.php b/src/Interfaces/Whip_DismissStorage.php similarity index 100% rename from src/interfaces/Whip_DismissStorage.php rename to src/Interfaces/Whip_DismissStorage.php diff --git a/src/interfaces/Whip_Listener.php b/src/Interfaces/Whip_Listener.php similarity index 100% rename from src/interfaces/Whip_Listener.php rename to src/Interfaces/Whip_Listener.php diff --git a/src/interfaces/Whip_Message.php b/src/Interfaces/Whip_Message.php similarity index 100% rename from src/interfaces/Whip_Message.php rename to src/Interfaces/Whip_Message.php diff --git a/src/interfaces/Whip_MessagePresenter.php b/src/Interfaces/Whip_MessagePresenter.php similarity index 100% rename from src/interfaces/Whip_MessagePresenter.php rename to src/Interfaces/Whip_MessagePresenter.php diff --git a/src/interfaces/Whip_Requirement.php b/src/Interfaces/Whip_Requirement.php similarity index 100% rename from src/interfaces/Whip_Requirement.php rename to src/Interfaces/Whip_Requirement.php diff --git a/src/interfaces/Whip_VersionDetector.php b/src/Interfaces/Whip_VersionDetector.php similarity index 100% rename from src/interfaces/Whip_VersionDetector.php rename to src/Interfaces/Whip_VersionDetector.php diff --git a/src/messages/Whip_BasicMessage.php b/src/Messages/Whip_BasicMessage.php similarity index 100% rename from src/messages/Whip_BasicMessage.php rename to src/Messages/Whip_BasicMessage.php diff --git a/src/messages/Whip_HostMessage.php b/src/Messages/Whip_HostMessage.php similarity index 100% rename from src/messages/Whip_HostMessage.php rename to src/Messages/Whip_HostMessage.php diff --git a/src/messages/Whip_InvalidVersionRequirementMessage.php b/src/Messages/Whip_InvalidVersionRequirementMessage.php similarity index 100% rename from src/messages/Whip_InvalidVersionRequirementMessage.php rename to src/Messages/Whip_InvalidVersionRequirementMessage.php diff --git a/src/messages/Whip_NullMessage.php b/src/Messages/Whip_NullMessage.php similarity index 100% rename from src/messages/Whip_NullMessage.php rename to src/Messages/Whip_NullMessage.php diff --git a/src/messages/Whip_UpgradePhpMessage.php b/src/Messages/Whip_UpgradePhpMessage.php similarity index 100% rename from src/messages/Whip_UpgradePhpMessage.php rename to src/Messages/Whip_UpgradePhpMessage.php diff --git a/src/presenters/Whip_WPMessagePresenter.php b/src/Presenters/Whip_WPMessagePresenter.php similarity index 100% rename from src/presenters/Whip_WPMessagePresenter.php rename to src/Presenters/Whip_WPMessagePresenter.php From a9a14c718fb34794dcdf69404d07b050d2c6b4b4 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Tue, 19 Dec 2023 23:30:11 +0100 Subject: [PATCH 3/5] Composer/PHPCS: update to strictly apply PSR4 to src --- .phpcs.xml.dist | 37 +++++++------------------------------ 1 file changed, 7 insertions(+), 30 deletions(-) diff --git a/.phpcs.xml.dist b/.phpcs.xml.dist index 80fea1b..fc4873e 100644 --- a/.phpcs.xml.dist +++ b/.phpcs.xml.dist @@ -47,6 +47,11 @@ + + + + + @@ -82,34 +87,6 @@ - - - - - - - - - - /tests/*\.php - - - - - - - - - - - - - - - /src/messages/Whip_HostMessage\.php$ - /src/messages/Whip_UpgradePhpMessage\.php$ + /src/Messages/Whip_HostMessage\.php$ + /src/Messages/Whip_UpgradePhpMessage\.php$ From a0409ed6c8f3404c50803a85bc3360fc788f3783 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Tue, 19 Dec 2023 23:30:11 +0100 Subject: [PATCH 4/5] Rename remaining directories --- .phpcs.xml.dist | 5 +++-- composer.json | 2 +- src/{configs => Configs}/default.php | 0 src/{configs => Configs}/version.php | 0 src/{facades => Facades}/wordpress.php | 2 +- src/Whip_MessagesManager.php | 2 +- 6 files changed, 6 insertions(+), 5 deletions(-) rename src/{configs => Configs}/default.php (100%) rename src/{configs => Configs}/version.php (100%) rename src/{facades => Facades}/wordpress.php (96%) diff --git a/.phpcs.xml.dist b/.phpcs.xml.dist index fc4873e..5d60707 100644 --- a/.phpcs.xml.dist +++ b/.phpcs.xml.dist @@ -80,7 +80,7 @@ - /src/facades/wordpress\.php$ + /src/Facades/wordpress\.php$ /tests/Unit/Doubles/WpCoreFunctionsMock\.php$ @@ -101,7 +101,7 @@ - /src/facades/wordpress\.php$ + /src/Facades/wordpress\.php$ - /src/Messages/Whip_HostMessage\.php$ - /src/Messages/Whip_UpgradePhpMessage\.php$ + /src/Messages/HostMessage\.php$ + /src/Messages/UpgradePhpMessage\.php$ - /src/Whip_Host\.php$ + /src/Host\.php$ + /src/Messages/UpgradePhpMessage\.php$ diff --git a/composer.json b/composer.json index 5a1be0a..7aad5d8 100644 --- a/composer.json +++ b/composer.json @@ -56,7 +56,7 @@ "Yoast\\WHIP\\Config\\Composer\\Actions::check_coding_standards" ], "check-cs-thresholds": [ - "@putenv YOASTCS_THRESHOLD_ERRORS=8", + "@putenv YOASTCS_THRESHOLD_ERRORS=10", "@putenv YOASTCS_THRESHOLD_WARNINGS=0", "Yoast\\WHIP\\Config\\Composer\\Actions::check_cs_thresholds" ], diff --git a/src/Whip_Configuration.php b/src/Configuration.php similarity index 61% rename from src/Whip_Configuration.php rename to src/Configuration.php index b853d3c..1d6fdc1 100644 --- a/src/Whip_Configuration.php +++ b/src/Configuration.php @@ -2,13 +2,13 @@ namespace Yoast\WHIPv2; -use Yoast\WHIPv2\Exceptions\Whip_InvalidType; -use Yoast\WHIPv2\Interfaces\Whip_Requirement; +use Yoast\WHIPv2\Exceptions\InvalidType; +use Yoast\WHIPv2\Interfaces\Requirement; /** - * Class Whip_Configuration. + * Class Configuration. */ -class Whip_Configuration { +class Configuration { /** * The configuration to use. @@ -18,15 +18,15 @@ class Whip_Configuration { private $configuration; /** - * Whip_Configuration constructor. + * Configuration constructor. * * @param array $configuration The configuration to use. * - * @throws Whip_InvalidType When the $configuration parameter is not of the expected type. + * @throws InvalidType When the $configuration parameter is not of the expected type. */ public function __construct( $configuration = array() ) { if ( ! \is_array( $configuration ) ) { - throw new Whip_InvalidType( 'Configuration', $configuration, 'array' ); + throw new InvalidType( 'Configuration', $configuration, 'array' ); } $this->configuration = $configuration; @@ -35,12 +35,12 @@ public function __construct( $configuration = array() ) { /** * Retrieves the configured version of a particular requirement. * - * @param Whip_Requirement $requirement The requirement to check. + * @param Requirement $requirement The requirement to check. * * @return string|int The version of the passed requirement that was detected as a string. * If the requirement does not exist, this returns int -1. */ - public function configuredVersion( Whip_Requirement $requirement ) { + public function configuredVersion( Requirement $requirement ) { if ( ! $this->hasRequirementConfigured( $requirement ) ) { return -1; } @@ -51,11 +51,11 @@ public function configuredVersion( Whip_Requirement $requirement ) { /** * Determines whether the passed requirement is present in the configuration. * - * @param Whip_Requirement $requirement The requirement to check. + * @param Requirement $requirement The requirement to check. * * @return bool Whether or not the requirement is present in the configuration. */ - public function hasRequirementConfigured( Whip_Requirement $requirement ) { + public function hasRequirementConfigured( Requirement $requirement ) { return \array_key_exists( $requirement->component(), $this->configuration ); } } diff --git a/src/Exceptions/Whip_EmptyProperty.php b/src/Exceptions/EmptyProperty.php similarity index 87% rename from src/Exceptions/Whip_EmptyProperty.php rename to src/Exceptions/EmptyProperty.php index 141d209..844372b 100644 --- a/src/Exceptions/Whip_EmptyProperty.php +++ b/src/Exceptions/EmptyProperty.php @@ -7,7 +7,7 @@ /** * Class EmptyProperty. */ -class Whip_EmptyProperty extends Exception { +class EmptyProperty extends Exception { /** * EmptyProperty constructor. diff --git a/src/Exceptions/Whip_InvalidOperatorType.php b/src/Exceptions/InvalidOperatorType.php similarity index 91% rename from src/Exceptions/Whip_InvalidOperatorType.php rename to src/Exceptions/InvalidOperatorType.php index b9ea117..7fedcac 100644 --- a/src/Exceptions/Whip_InvalidOperatorType.php +++ b/src/Exceptions/InvalidOperatorType.php @@ -7,7 +7,7 @@ /** * Class InvalidOperatorType. */ -class Whip_InvalidOperatorType extends Exception { +class InvalidOperatorType extends Exception { /** * InvalidOperatorType constructor. diff --git a/src/Exceptions/Whip_InvalidType.php b/src/Exceptions/InvalidType.php similarity index 91% rename from src/Exceptions/Whip_InvalidType.php rename to src/Exceptions/InvalidType.php index 1cb13fa..6ed1daf 100644 --- a/src/Exceptions/Whip_InvalidType.php +++ b/src/Exceptions/InvalidType.php @@ -7,7 +7,7 @@ /** * Class InvalidType. */ -class Whip_InvalidType extends Exception { +class InvalidType extends Exception { /** * InvalidType constructor. diff --git a/src/Exceptions/Whip_InvalidVersionComparisonString.php b/src/Exceptions/InvalidVersionComparisonString.php similarity index 88% rename from src/Exceptions/Whip_InvalidVersionComparisonString.php rename to src/Exceptions/InvalidVersionComparisonString.php index 55a7019..0356fef 100644 --- a/src/Exceptions/Whip_InvalidVersionComparisonString.php +++ b/src/Exceptions/InvalidVersionComparisonString.php @@ -7,7 +7,7 @@ /** * Exception for an invalid version comparison string. */ -class Whip_InvalidVersionComparisonString extends Exception { +class InvalidVersionComparisonString extends Exception { /** * InvalidVersionComparisonString constructor. diff --git a/src/Facades/wordpress.php b/src/Facades/wordpress.php index 2897af2..e5adc44 100644 --- a/src/Facades/wordpress.php +++ b/src/Facades/wordpress.php @@ -5,11 +5,11 @@ * @package Yoast\WHIP */ -use Yoast\WHIPv2\Presenters\Whip_WPMessagePresenter; -use Yoast\WHIPv2\Whip_MessageDismisser; -use Yoast\WHIPv2\Whip_RequirementsChecker; -use Yoast\WHIPv2\Whip_VersionRequirement; -use Yoast\WHIPv2\Whip_WPDismissOption; +use Yoast\WHIPv2\MessageDismisser; +use Yoast\WHIPv2\Presenters\WPMessagePresenter; +use Yoast\WHIPv2\RequirementsChecker; +use Yoast\WHIPv2\VersionRequirement; +use Yoast\WHIPv2\WPDismissOption; if ( ! function_exists( 'whip_wp_check_versions' ) ) { /** @@ -26,10 +26,10 @@ function whip_wp_check_versions( $requirements ) { } $config = include __DIR__ . '/../Configs/default.php'; - $checker = new Whip_RequirementsChecker( $config ); + $checker = new RequirementsChecker( $config ); foreach ( $requirements as $component => $versionComparison ) { - $checker->addRequirement( Whip_VersionRequirement::fromCompareString( $component, $versionComparison ) ); + $checker->addRequirement( VersionRequirement::fromCompareString( $component, $versionComparison ) ); } $checker->check(); @@ -41,9 +41,9 @@ function whip_wp_check_versions( $requirements ) { $dismissThreshold = ( WEEK_IN_SECONDS * 4 ); $dismissMessage = __( 'Remind me again in 4 weeks.', 'default' ); - $dismisser = new Whip_MessageDismisser( time(), $dismissThreshold, new Whip_WPDismissOption() ); + $dismisser = new MessageDismisser( time(), $dismissThreshold, new WPDismissOption() ); - $presenter = new Whip_WPMessagePresenter( $checker->getMostRecentMessage(), $dismisser, $dismissMessage ); + $presenter = new WPMessagePresenter( $checker->getMostRecentMessage(), $dismisser, $dismissMessage ); // Prevent duplicate notices across multiple implementing plugins. if ( ! has_action( 'whip_register_hooks' ) ) { @@ -53,7 +53,7 @@ function whip_wp_check_versions( $requirements ) { /** * Fires during hooks registration for the message presenter. * - * @param Whip_WPMessagePresenter $presenter Message presenter instance. + * @param WPMessagePresenter $presenter Message presenter instance. */ do_action( 'whip_register_hooks', $presenter ); } diff --git a/src/Whip_Host.php b/src/Host.php similarity index 99% rename from src/Whip_Host.php rename to src/Host.php index 22e0e26..fce2013 100644 --- a/src/Whip_Host.php +++ b/src/Host.php @@ -5,7 +5,7 @@ /** * Represents a host. */ -class Whip_Host { +class Host { /** * Key to an environment variable which should be set to the name of the host. diff --git a/src/Interfaces/Whip_DismissStorage.php b/src/Interfaces/DismissStorage.php similarity index 82% rename from src/Interfaces/Whip_DismissStorage.php rename to src/Interfaces/DismissStorage.php index 96a4f46..bd7bd8c 100644 --- a/src/Interfaces/Whip_DismissStorage.php +++ b/src/Interfaces/DismissStorage.php @@ -3,9 +3,9 @@ namespace Yoast\WHIPv2\Interfaces; /** - * Interface Whip_DismissStorage. + * Interface DismissStorage. */ -interface Whip_DismissStorage { +interface DismissStorage { /** * Saves the value. diff --git a/src/Interfaces/Whip_Listener.php b/src/Interfaces/Listener.php similarity index 76% rename from src/Interfaces/Whip_Listener.php rename to src/Interfaces/Listener.php index c124b4c..f7796aa 100644 --- a/src/Interfaces/Whip_Listener.php +++ b/src/Interfaces/Listener.php @@ -3,9 +3,9 @@ namespace Yoast\WHIPv2\Interfaces; /** - * Interface Whip_Listener. + * Interface Listener. */ -interface Whip_Listener { +interface Listener { /** * Method that should implement the listen functionality. diff --git a/src/Interfaces/Whip_Message.php b/src/Interfaces/Message.php similarity index 74% rename from src/Interfaces/Whip_Message.php rename to src/Interfaces/Message.php index 27899b2..a9d2ddf 100644 --- a/src/Interfaces/Whip_Message.php +++ b/src/Interfaces/Message.php @@ -3,9 +3,9 @@ namespace Yoast\WHIPv2\Interfaces; /** - * Interface Whip_Message. + * Interface Message. */ -interface Whip_Message { +interface Message { /** * Retrieves the message body. diff --git a/src/Interfaces/Whip_MessagePresenter.php b/src/Interfaces/MessagePresenter.php similarity index 67% rename from src/Interfaces/Whip_MessagePresenter.php rename to src/Interfaces/MessagePresenter.php index ecbac5b..80ebd99 100644 --- a/src/Interfaces/Whip_MessagePresenter.php +++ b/src/Interfaces/MessagePresenter.php @@ -3,9 +3,9 @@ namespace Yoast\WHIPv2\Interfaces; /** - * Interface Whip_MessagePresenter. + * Interface MessagePresenter. */ -interface Whip_MessagePresenter { +interface MessagePresenter { /** * Renders the message. diff --git a/src/Interfaces/Whip_Requirement.php b/src/Interfaces/Requirement.php similarity index 88% rename from src/Interfaces/Whip_Requirement.php rename to src/Interfaces/Requirement.php index e2d66e4..38e7db9 100644 --- a/src/Interfaces/Whip_Requirement.php +++ b/src/Interfaces/Requirement.php @@ -3,9 +3,9 @@ namespace Yoast\WHIPv2\Interfaces; /** - * Interface Whip_Requirement. + * Interface Requirement. */ -interface Whip_Requirement { +interface Requirement { /** * Retrieves the component name defined for the requirement. diff --git a/src/Interfaces/Whip_VersionDetector.php b/src/Interfaces/VersionDetector.php similarity index 92% rename from src/Interfaces/Whip_VersionDetector.php rename to src/Interfaces/VersionDetector.php index 48f5e95..3cbb172 100644 --- a/src/Interfaces/Whip_VersionDetector.php +++ b/src/Interfaces/VersionDetector.php @@ -5,7 +5,7 @@ /** * An interface that represents a version detector and message. */ -interface Whip_VersionDetector { +interface VersionDetector { /** * Detects the version of the installed software. diff --git a/src/Whip_MessageDismisser.php b/src/MessageDismisser.php similarity index 72% rename from src/Whip_MessageDismisser.php rename to src/MessageDismisser.php index 7db8fd8..2bc6fb3 100644 --- a/src/Whip_MessageDismisser.php +++ b/src/MessageDismisser.php @@ -2,17 +2,17 @@ namespace Yoast\WHIPv2; -use Yoast\WHIPv2\Interfaces\Whip_DismissStorage; +use Yoast\WHIPv2\Interfaces\DismissStorage; /** * A class to dismiss messages. */ -class Whip_MessageDismisser { +class MessageDismisser { /** * Storage object to manage the dismissal state. * - * @var Whip_DismissStorage + * @var DismissStorage */ protected $storage; @@ -31,13 +31,13 @@ class Whip_MessageDismisser { protected $threshold; /** - * Whip_MessageDismisser constructor. + * MessageDismisser constructor. * - * @param int $currentTime The current time. - * @param int $threshold The number of seconds the message will be dismissed. - * @param Whip_DismissStorage $storage Storage object to manage the dismissal state. + * @param int $currentTime The current time. + * @param int $threshold The number of seconds the message will be dismissed. + * @param DismissStorage $storage Storage object to manage the dismissal state. */ - public function __construct( $currentTime, $threshold, Whip_DismissStorage $storage ) { + public function __construct( $currentTime, $threshold, DismissStorage $storage ) { $this->currentTime = $currentTime; $this->threshold = $threshold; $this->storage = $storage; diff --git a/src/Whip_MessageFormatter.php b/src/MessageFormatter.php similarity index 95% rename from src/Whip_MessageFormatter.php rename to src/MessageFormatter.php index 86bb0d4..b94d953 100644 --- a/src/Whip_MessageFormatter.php +++ b/src/MessageFormatter.php @@ -5,7 +5,7 @@ /** * A helper class to format messages. */ -final class Whip_MessageFormatter { +final class MessageFormatter { /** * Wraps a piece of text in HTML strong tags. diff --git a/src/Messages/Whip_BasicMessage.php b/src/Messages/BasicMessage.php similarity index 56% rename from src/Messages/Whip_BasicMessage.php rename to src/Messages/BasicMessage.php index 396cd01..41205b0 100644 --- a/src/Messages/Whip_BasicMessage.php +++ b/src/Messages/BasicMessage.php @@ -2,14 +2,14 @@ namespace Yoast\WHIPv2\Messages; -use Yoast\WHIPv2\Exceptions\Whip_EmptyProperty; -use Yoast\WHIPv2\Exceptions\Whip_InvalidType; -use Yoast\WHIPv2\Interfaces\Whip_Message; +use Yoast\WHIPv2\Exceptions\EmptyProperty; +use Yoast\WHIPv2\Exceptions\InvalidType; +use Yoast\WHIPv2\Interfaces\Message; /** - * Class Whip_Message. + * Class BasicMessage. */ -class Whip_BasicMessage implements Whip_Message { +class BasicMessage implements Message { /** * Message body. @@ -19,7 +19,7 @@ class Whip_BasicMessage implements Whip_Message { private $body; /** - * Whip_Message constructor. + * Message constructor. * * @param string $body Message body. */ @@ -45,16 +45,16 @@ public function body() { * * @return void * - * @throws Whip_EmptyProperty When the $body parameter is empty. - * @throws Whip_InvalidType When the $body parameter is not of the expected type. + * @throws EmptyProperty When the $body parameter is empty. + * @throws InvalidType When the $body parameter is not of the expected type. */ private function validateParameters( $body ) { if ( empty( $body ) ) { - throw new Whip_EmptyProperty( 'Message body' ); + throw new EmptyProperty( 'Message body' ); } if ( ! \is_string( $body ) ) { - throw new Whip_InvalidType( 'Message body', $body, 'string' ); + throw new InvalidType( 'Message body', $body, 'string' ); } } } diff --git a/src/Messages/Whip_HostMessage.php b/src/Messages/HostMessage.php similarity index 69% rename from src/Messages/Whip_HostMessage.php rename to src/Messages/HostMessage.php index ac7265b..90ad290 100644 --- a/src/Messages/Whip_HostMessage.php +++ b/src/Messages/HostMessage.php @@ -2,14 +2,14 @@ namespace Yoast\WHIPv2\Messages; -use Yoast\WHIPv2\Interfaces\Whip_Message; -use Yoast\WHIPv2\Whip_Host; -use Yoast\WHIPv2\Whip_MessageFormatter; +use Yoast\WHIPv2\Host; +use Yoast\WHIPv2\Interfaces\Message; +use Yoast\WHIPv2\MessageFormatter; /** - * Class Whip_HostMessage. + * Class HostMessage. */ -class Whip_HostMessage implements Whip_Message { +class HostMessage implements Message { /** * Text domain to use for translations. @@ -26,7 +26,7 @@ class Whip_HostMessage implements Whip_Message { private $messageKey; /** - * Whip_Message constructor. + * Message constructor. * * @param string $messageKey The environment key to use to retrieve the message from. * @param string $textdomain The text domain to use for translations. @@ -44,8 +44,8 @@ public function __construct( $messageKey, $textdomain ) { public function body() { $message = array(); - $message[] = Whip_MessageFormatter::strong( $this->title() ) . '
'; - $message[] = Whip_MessageFormatter::paragraph( Whip_Host::message( $this->messageKey ) ); + $message[] = MessageFormatter::strong( $this->title() ) . '
'; + $message[] = MessageFormatter::paragraph( Host::message( $this->messageKey ) ); return \implode( "\n", $message ); } @@ -57,6 +57,6 @@ public function body() { */ public function title() { /* translators: 1: name. */ - return \sprintf( \__( 'A message from %1$s', $this->textdomain ), Whip_Host::name() ); + return \sprintf( \__( 'A message from %1$s', $this->textdomain ), Host::name() ); } } diff --git a/src/Messages/Whip_InvalidVersionRequirementMessage.php b/src/Messages/InvalidVersionRequirementMessage.php similarity index 55% rename from src/Messages/Whip_InvalidVersionRequirementMessage.php rename to src/Messages/InvalidVersionRequirementMessage.php index 1b0c6f8..db30012 100644 --- a/src/Messages/Whip_InvalidVersionRequirementMessage.php +++ b/src/Messages/InvalidVersionRequirementMessage.php @@ -2,18 +2,18 @@ namespace Yoast\WHIPv2\Messages; -use Yoast\WHIPv2\Interfaces\Whip_Message; -use Yoast\WHIPv2\Whip_VersionRequirement; +use Yoast\WHIPv2\Interfaces\Message; +use Yoast\WHIPv2\VersionRequirement; /** * Class Whip_InvalidVersionMessage. */ -class Whip_InvalidVersionRequirementMessage implements Whip_Message { +class InvalidVersionRequirementMessage implements Message { /** * Object containing the version requirement for a component. * - * @var Whip_VersionRequirement + * @var VersionRequirement */ private $requirement; @@ -25,12 +25,12 @@ class Whip_InvalidVersionRequirementMessage implements Whip_Message { private $detected; /** - * Whip_InvalidVersionRequirementMessage constructor. + * InvalidVersionRequirementMessage constructor. * - * @param Whip_VersionRequirement $requirement Object containing the version requirement for a component. - * @param string|int $detected Detected version requirement or -1 if not found. + * @param VersionRequirement $requirement Object containing the version requirement for a component. + * @param string|int $detected Detected version requirement or -1 if not found. */ - public function __construct( Whip_VersionRequirement $requirement, $detected ) { + public function __construct( VersionRequirement $requirement, $detected ) { $this->requirement = $requirement; $this->detected = $detected; } diff --git a/src/Messages/Whip_NullMessage.php b/src/Messages/NullMessage.php similarity index 59% rename from src/Messages/Whip_NullMessage.php rename to src/Messages/NullMessage.php index 5667d4d..bbb364c 100644 --- a/src/Messages/Whip_NullMessage.php +++ b/src/Messages/NullMessage.php @@ -2,12 +2,12 @@ namespace Yoast\WHIPv2\Messages; -use Yoast\WHIPv2\Interfaces\Whip_Message; +use Yoast\WHIPv2\Interfaces\Message; /** - * Class Whip_Message. + * Class NullMessage. */ -class Whip_NullMessage implements Whip_Message { +class NullMessage implements Message { /** * Retrieves the message body. diff --git a/src/Messages/Whip_UpgradePhpMessage.php b/src/Messages/UpgradePhpMessage.php similarity index 58% rename from src/Messages/Whip_UpgradePhpMessage.php rename to src/Messages/UpgradePhpMessage.php index 3f3364b..4aa5040 100644 --- a/src/Messages/Whip_UpgradePhpMessage.php +++ b/src/Messages/UpgradePhpMessage.php @@ -2,14 +2,14 @@ namespace Yoast\WHIPv2\Messages; -use Yoast\WHIPv2\Interfaces\Whip_Message; -use Yoast\WHIPv2\Whip_Host; -use Yoast\WHIPv2\Whip_MessageFormatter; +use Yoast\WHIPv2\Host; +use Yoast\WHIPv2\Interfaces\Message; +use Yoast\WHIPv2\MessageFormatter; /** - * Class Whip_UpgradePhpMessage + * Class UpgradePhpMessage */ -class Whip_UpgradePhpMessage implements Whip_Message { +class UpgradePhpMessage implements Message { /** * The text domain to use for the translations. @@ -19,7 +19,7 @@ class Whip_UpgradePhpMessage implements Whip_Message { private $textdomain; /** - * Whip_UpgradePhpMessage constructor. + * UpgradePhpMessage constructor. * * @param string $textdomain The text domain to use for the translations. */ @@ -37,11 +37,11 @@ public function body() { $message = array(); - $message[] = Whip_MessageFormatter::strongParagraph( \__( 'Your site could be faster and more secure with a newer PHP version.', $textdomain ) ) . '
'; - $message[] = Whip_MessageFormatter::paragraph( \__( 'Hey, we\'ve noticed that you\'re running an outdated version of PHP. PHP is the programming language that WordPress and all its plugins and themes are built on. The version that is currently used for your site is no longer supported. Newer versions of PHP are both faster and more secure. In fact, your version of PHP no longer receives security updates, which is why we\'re sending you to this notice.', $textdomain ) ); - $message[] = Whip_MessageFormatter::paragraph( \__( 'Hosts have the ability to update your PHP version, but sometimes they don\'t dare to do that because they\'re afraid they\'ll break your site.', $textdomain ) ); - $message[] = Whip_MessageFormatter::strongParagraph( \__( 'To which version should I update?', $textdomain ) ) . '
'; - $message[] = Whip_MessageFormatter::paragraph( + $message[] = MessageFormatter::strongParagraph( \__( 'Your site could be faster and more secure with a newer PHP version.', $textdomain ) ) . '
'; + $message[] = MessageFormatter::paragraph( \__( 'Hey, we\'ve noticed that you\'re running an outdated version of PHP. PHP is the programming language that WordPress and all its plugins and themes are built on. The version that is currently used for your site is no longer supported. Newer versions of PHP are both faster and more secure. In fact, your version of PHP no longer receives security updates, which is why we\'re sending you to this notice.', $textdomain ) ); + $message[] = MessageFormatter::paragraph( \__( 'Hosts have the ability to update your PHP version, but sometimes they don\'t dare to do that because they\'re afraid they\'ll break your site.', $textdomain ) ); + $message[] = MessageFormatter::strongParagraph( \__( 'To which version should I update?', $textdomain ) ) . '
'; + $message[] = MessageFormatter::paragraph( \sprintf( /* translators: 1: link open tag; 2: link close tag. */ \__( 'You should update your PHP version to either 5.6 or to 7.0 or 7.1. On a normal WordPress site, switching to PHP 5.6 should never cause issues. We would however actually recommend you switch to PHP7. There are some plugins that are not ready for PHP7 though, so do some testing first. We have an article on how to test whether that\'s an option for you %1$shere%2$s. PHP7 is much faster than PHP 5.6. It\'s also the only PHP version still in active development and therefore the better option for your site in the long run.', $textdomain ), @@ -50,17 +50,17 @@ public function body() { ) ); - if ( Whip_Host::name() !== '' ) { - $hostMessage = new Whip_HostMessage( 'WHIP_MESSAGE_FROM_HOST_ABOUT_PHP', $textdomain ); + if ( Host::name() !== '' ) { + $hostMessage = new HostMessage( 'WHIP_MESSAGE_FROM_HOST_ABOUT_PHP', $textdomain ); $message[] = $hostMessage->body(); } - $hostingPageUrl = Whip_Host::hostingPageUrl(); + $hostingPageUrl = Host::hostingPageUrl(); - $message[] = Whip_MessageFormatter::strongParagraph( \__( 'Can\'t update? Ask your host!', $textdomain ) ) . '
'; + $message[] = MessageFormatter::strongParagraph( \__( 'Can\'t update? Ask your host!', $textdomain ) ) . '
'; - if ( \function_exists( 'apply_filters' ) && \apply_filters( Whip_Host::HOSTING_PAGE_FILTER_KEY, false ) ) { - $message[] = Whip_MessageFormatter::paragraph( + if ( \function_exists( 'apply_filters' ) && \apply_filters( Host::HOSTING_PAGE_FILTER_KEY, false ) ) { + $message[] = MessageFormatter::paragraph( \sprintf( /* translators: 1: link open tag; 2: link close tag; 3: link open tag. */ \__( 'If you cannot upgrade your PHP version yourself, you can send an email to your host. We have %1$sexamples here%2$s. If they don\'t want to upgrade your PHP version, we would suggest you switch hosts. Have a look at one of the recommended %3$sWordPress hosting partners%2$s.', $textdomain ), @@ -71,7 +71,7 @@ public function body() { ); } else { - $message[] = Whip_MessageFormatter::paragraph( + $message[] = MessageFormatter::paragraph( \sprintf( /* translators: 1: link open tag; 2: link close tag; 3: link open tag. */ \__( 'If you cannot upgrade your PHP version yourself, you can send an email to your host. We have %1$sexamples here%2$s. If they don\'t want to upgrade your PHP version, we would suggest you switch hosts. Have a look at one of our recommended %3$sWordPress hosting partners%2$s, they\'ve all been vetted by the Yoast support team and provide all the features a modern host should provide.', $textdomain ), diff --git a/src/Whip_MessagesManager.php b/src/MessagesManager.php similarity index 81% rename from src/Whip_MessagesManager.php rename to src/MessagesManager.php index a257582..939c7ac 100644 --- a/src/Whip_MessagesManager.php +++ b/src/MessagesManager.php @@ -2,16 +2,16 @@ namespace Yoast\WHIPv2; -use Yoast\WHIPv2\Interfaces\Whip_Message; -use Yoast\WHIPv2\Messages\Whip_NullMessage; +use Yoast\WHIPv2\Interfaces\Message; +use Yoast\WHIPv2\Messages\NullMessage; /** * Manages messages using a global to prevent duplicate messages. */ -class Whip_MessagesManager { +class MessagesManager { /** - * Whip_MessagesManager constructor. + * MessagesManager constructor. */ public function __construct() { if ( ! \array_key_exists( 'whip_messages', $GLOBALS ) ) { @@ -22,11 +22,11 @@ public function __construct() { /** * Adds a message to the Messages Manager. * - * @param Whip_Message $message The message to add. + * @param Message $message The message to add. * * @return void */ - public function addMessage( Whip_Message $message ) { + public function addMessage( Message $message ) { $whipVersion = require __DIR__ . '/Configs/version.php'; $GLOBALS['whip_messages'][ $whipVersion ] = $message; @@ -62,11 +62,11 @@ public function deleteMessages() { /** * Gets the latest message. * - * @return Whip_Message The message. Returns a NullMessage if none is found. + * @return Message The message. Returns a NullMessage if none is found. */ public function getLatestMessage() { if ( ! $this->hasMessages() ) { - return new Whip_NullMessage(); + return new NullMessage(); } $messages = $this->sortByVersion( $this->listMessages() ); diff --git a/src/Presenters/Whip_WPMessagePresenter.php b/src/Presenters/WPMessagePresenter.php similarity index 69% rename from src/Presenters/Whip_WPMessagePresenter.php rename to src/Presenters/WPMessagePresenter.php index dedd8a7..aa071f6 100644 --- a/src/Presenters/Whip_WPMessagePresenter.php +++ b/src/Presenters/WPMessagePresenter.php @@ -2,15 +2,17 @@ namespace Yoast\WHIPv2\Presenters; -use Yoast\WHIPv2\Interfaces\Whip_Message; -use Yoast\WHIPv2\Interfaces\Whip_MessagePresenter; -use Yoast\WHIPv2\Whip_MessageDismisser; -use Yoast\WHIPv2\Whip_WPMessageDismissListener; +use Yoast\WHIPv2\Interfaces\Message; +use Yoast\WHIPv2\Interfaces\MessagePresenter; +use Yoast\WHIPv2\MessageDismisser; +use Yoast\WHIPv2\WPMessageDismissListener; /** * A message presenter to show a WordPress notice. + * + * @phpcs:disable Yoast.NamingConventions.ObjectNameDepth.MaxExceeded -- Sniff does not count acronyms correctly. */ -class Whip_WPMessagePresenter implements Whip_MessagePresenter { +class WPMessagePresenter implements MessagePresenter { /** * The string to show to dismiss the message. @@ -22,25 +24,25 @@ class Whip_WPMessagePresenter implements Whip_MessagePresenter { /** * The message to be displayed. * - * @var Whip_Message + * @var Message */ private $message; /** * Dismisser object. * - * @var Whip_MessageDismisser + * @var MessageDismisser */ private $dismisser; /** - * Whip_WPMessagePresenter constructor. + * WPMessagePresenter constructor. * - * @param Whip_Message $message The message to use in the presenter. - * @param Whip_MessageDismisser $dismisser Dismisser object. - * @param string $dismissMessage The copy to show to dismiss the message. + * @param Message $message The message to use in the presenter. + * @param MessageDismisser $dismisser Dismisser object. + * @param string $dismissMessage The copy to show to dismiss the message. */ - public function __construct( Whip_Message $message, Whip_MessageDismisser $dismisser, $dismissMessage ) { + public function __construct( Message $message, MessageDismisser $dismisser, $dismissMessage ) { $this->message = $message; $this->dismisser = $dismisser; $this->dismissMessage = $dismissMessage; @@ -63,7 +65,7 @@ public function registerHooks() { * @return void */ public function renderMessage() { - $dismissListener = new Whip_WPMessageDismissListener( $this->dismisser ); + $dismissListener = new WPMessageDismissListener( $this->dismisser ); $dismissListener->listen(); if ( $this->dismisser->isDismissed() ) { diff --git a/src/Whip_RequirementsChecker.php b/src/RequirementsChecker.php similarity index 72% rename from src/Whip_RequirementsChecker.php rename to src/RequirementsChecker.php index 4982780..73f491b 100644 --- a/src/Whip_RequirementsChecker.php +++ b/src/RequirementsChecker.php @@ -2,16 +2,16 @@ namespace Yoast\WHIPv2; -use Yoast\WHIPv2\Exceptions\Whip_InvalidType; -use Yoast\WHIPv2\Interfaces\Whip_Message; -use Yoast\WHIPv2\Interfaces\Whip_Requirement; -use Yoast\WHIPv2\Messages\Whip_InvalidVersionRequirementMessage; -use Yoast\WHIPv2\Messages\Whip_UpgradePhpMessage; +use Yoast\WHIPv2\Exceptions\InvalidType; +use Yoast\WHIPv2\Interfaces\Message; +use Yoast\WHIPv2\Interfaces\Requirement; +use Yoast\WHIPv2\Messages\InvalidVersionRequirementMessage; +use Yoast\WHIPv2\Messages\UpgradePhpMessage; /** * Main controller class to require a certain version of software. */ -class Whip_RequirementsChecker { +class RequirementsChecker { /** * Requirements the environment should comply with. @@ -23,14 +23,14 @@ class Whip_RequirementsChecker { /** * The configuration to check. * - * @var Whip_Configuration + * @var Configuration */ private $configuration; /** * Message Manager. * - * @var Whip_MessagesManager + * @var MessagesManager */ private $messageManager; @@ -42,28 +42,28 @@ class Whip_RequirementsChecker { private $textdomain; /** - * Whip_RequirementsChecker constructor. + * RequirementsChecker constructor. * * @param array $configuration The configuration to check. * @param string $textdomain The text domain to use for translations. * - * @throws Whip_InvalidType When the $configuration parameter is not of the expected type. + * @throws InvalidType When the $configuration parameter is not of the expected type. */ public function __construct( $configuration = array(), $textdomain = 'default' ) { $this->requirements = array(); - $this->configuration = new Whip_Configuration( $configuration ); - $this->messageManager = new Whip_MessagesManager(); + $this->configuration = new Configuration( $configuration ); + $this->messageManager = new MessagesManager(); $this->textdomain = $textdomain; } /** * Adds a requirement to the list of requirements if it doesn't already exist. * - * @param Whip_Requirement $requirement The requirement to add. + * @param Requirement $requirement The requirement to add. * * @return void */ - public function addRequirement( Whip_Requirement $requirement ) { + public function addRequirement( Requirement $requirement ) { // Only allow unique entries to ensure we're not checking specific combinations multiple times. if ( $this->requirementExistsForComponent( $requirement->component() ) ) { return; @@ -110,11 +110,11 @@ public function requirementExistsForComponent( $component ) { /** * Determines whether a requirement has been fulfilled. * - * @param Whip_Requirement $requirement The requirement to check. + * @param Requirement $requirement The requirement to check. * * @return bool Whether or not the requirement is fulfilled. */ - private function requirementIsFulfilled( Whip_Requirement $requirement ) { + private function requirementIsFulfilled( Requirement $requirement ) { $availableVersion = $this->configuration->configuredVersion( $requirement ); $requiredVersion = $requirement->version(); @@ -146,17 +146,17 @@ public function check() { /** * Adds a message to the message manager for requirements that cannot be fulfilled. * - * @param Whip_Requirement $requirement The requirement that cannot be fulfilled. + * @param Requirement $requirement The requirement that cannot be fulfilled. * * @return void */ - private function addMissingRequirementMessage( Whip_Requirement $requirement ) { + private function addMissingRequirementMessage( Requirement $requirement ) { switch ( $requirement->component() ) { case 'php': - $this->messageManager->addMessage( new Whip_UpgradePhpMessage( $this->textdomain ) ); + $this->messageManager->addMessage( new UpgradePhpMessage( $this->textdomain ) ); break; default: - $this->messageManager->addMessage( new Whip_InvalidVersionRequirementMessage( $requirement, $this->configuration->configuredVersion( $requirement ) ) ); + $this->messageManager->addMessage( new InvalidVersionRequirementMessage( $requirement, $this->configuration->configuredVersion( $requirement ) ) ); break; } } @@ -173,7 +173,7 @@ public function hasMessages() { /** * Gets the most recent message from the message manager. * - * @return Whip_Message The latest message. + * @return Message The latest message. */ public function getMostRecentMessage() { return $this->messageManager->getLatestMessage(); diff --git a/src/Whip_VersionRequirement.php b/src/VersionRequirement.php similarity index 66% rename from src/Whip_VersionRequirement.php rename to src/VersionRequirement.php index ae25f8b..f29c641 100644 --- a/src/Whip_VersionRequirement.php +++ b/src/VersionRequirement.php @@ -2,16 +2,16 @@ namespace Yoast\WHIPv2; -use Yoast\WHIPv2\Exceptions\Whip_EmptyProperty; -use Yoast\WHIPv2\Exceptions\Whip_InvalidOperatorType; -use Yoast\WHIPv2\Exceptions\Whip_InvalidType; -use Yoast\WHIPv2\Exceptions\Whip_InvalidVersionComparisonString; -use Yoast\WHIPv2\Interfaces\Whip_Requirement; +use Yoast\WHIPv2\Exceptions\EmptyProperty; +use Yoast\WHIPv2\Exceptions\InvalidOperatorType; +use Yoast\WHIPv2\Exceptions\InvalidType; +use Yoast\WHIPv2\Exceptions\InvalidVersionComparisonString; +use Yoast\WHIPv2\Interfaces\Requirement; /** * A value object containing a version requirement for a component version. */ -class Whip_VersionRequirement implements Whip_Requirement { +class VersionRequirement implements Requirement { /** * The component name. @@ -35,7 +35,7 @@ class Whip_VersionRequirement implements Whip_Requirement { private $operator; /** - * Whip_Requirement constructor. + * Requirement constructor. * * @param string $component The component name. * @param string $version The component version. @@ -82,9 +82,9 @@ public function operator() { * @param string $component The component for this version requirement. * @param string $comparisonString The comparison string for this version requirement. * - * @return Whip_VersionRequirement The parsed version requirement. + * @return VersionRequirement The parsed version requirement. * - * @throws Whip_InvalidVersionComparisonString When an invalid version comparison string is passed. + * @throws InvalidVersionComparisonString When an invalid version comparison string is passed. */ public static function fromCompareString( $component, $comparisonString ) { @@ -98,13 +98,13 @@ public static function fromCompareString( $component, $comparisonString ) { `x'; if ( ! \preg_match( $matcher, $comparisonString, $match ) ) { - throw new Whip_InvalidVersionComparisonString( $comparisonString ); + throw new InvalidVersionComparisonString( $comparisonString ); } $version = $match[2]; $operator = $match[1]; - return new Whip_VersionRequirement( $component, $version, $operator ); + return new VersionRequirement( $component, $version, $operator ); } /** @@ -116,38 +116,38 @@ public static function fromCompareString( $component, $comparisonString ) { * * @return void * - * @throws Whip_EmptyProperty When any of the parameters is empty. - * @throws Whip_InvalidOperatorType When the $operator parameter is invalid. - * @throws Whip_InvalidType When any of the parameters is not of the expected type. + * @throws EmptyProperty When any of the parameters is empty. + * @throws InvalidOperatorType When the $operator parameter is invalid. + * @throws InvalidType When any of the parameters is not of the expected type. */ private function validateParameters( $component, $version, $operator ) { if ( empty( $component ) ) { - throw new Whip_EmptyProperty( 'Component' ); + throw new EmptyProperty( 'Component' ); } if ( ! \is_string( $component ) ) { - throw new Whip_InvalidType( 'Component', $component, 'string' ); + throw new InvalidType( 'Component', $component, 'string' ); } if ( empty( $version ) ) { - throw new Whip_EmptyProperty( 'Version' ); + throw new EmptyProperty( 'Version' ); } if ( ! \is_string( $version ) ) { - throw new Whip_InvalidType( 'Version', $version, 'string' ); + throw new InvalidType( 'Version', $version, 'string' ); } if ( empty( $operator ) ) { - throw new Whip_EmptyProperty( 'Operator' ); + throw new EmptyProperty( 'Operator' ); } if ( ! \is_string( $operator ) ) { - throw new Whip_InvalidType( 'Operator', $operator, 'string' ); + throw new InvalidType( 'Operator', $operator, 'string' ); } $validOperators = array( '=', '==', '===', '<', '>', '<=', '>=' ); if ( ! \in_array( $operator, $validOperators, true ) ) { - throw new Whip_InvalidOperatorType( $operator, $validOperators ); + throw new InvalidOperatorType( $operator, $validOperators ); } } } diff --git a/src/Whip_WPDismissOption.php b/src/WPDismissOption.php similarity index 78% rename from src/Whip_WPDismissOption.php rename to src/WPDismissOption.php index 10a4dc5..aecd9df 100644 --- a/src/Whip_WPDismissOption.php +++ b/src/WPDismissOption.php @@ -2,12 +2,14 @@ namespace Yoast\WHIPv2; -use Yoast\WHIPv2\Interfaces\Whip_DismissStorage; +use Yoast\WHIPv2\Interfaces\DismissStorage; /** * Represents the WordPress option for saving the dismissed messages. + * + * @phpcs:disable Yoast.NamingConventions.ObjectNameDepth.MaxExceeded -- Sniff does not count acronyms correctly. */ -class Whip_WPDismissOption implements Whip_DismissStorage { +class WPDismissOption implements DismissStorage { /** * WordPress option name. diff --git a/src/Whip_WPMessageDismissListener.php b/src/WPMessageDismissListener.php similarity index 79% rename from src/Whip_WPMessageDismissListener.php rename to src/WPMessageDismissListener.php index ae3236a..b3d0bda 100644 --- a/src/Whip_WPMessageDismissListener.php +++ b/src/WPMessageDismissListener.php @@ -2,12 +2,14 @@ namespace Yoast\WHIPv2; -use Yoast\WHIPv2\Interfaces\Whip_Listener; +use Yoast\WHIPv2\Interfaces\Listener; /** * Listener for dismissing a message. + * + * @phpcs:disable Yoast.NamingConventions.ObjectNameDepth.MaxExceeded -- Sniff does not count acronyms correctly. */ -class Whip_WPMessageDismissListener implements Whip_Listener { +class WPMessageDismissListener implements Listener { /** * The name of the dismiss action expected to be passed via $_GET. @@ -19,16 +21,16 @@ class Whip_WPMessageDismissListener implements Whip_Listener { /** * The object for dismissing a message. * - * @var Whip_MessageDismisser + * @var MessageDismisser */ protected $dismisser; /** * Sets the dismisser attribute. * - * @param Whip_MessageDismisser $dismisser The object for dismissing a message. + * @param MessageDismisser $dismisser The object for dismissing a message. */ - public function __construct( Whip_MessageDismisser $dismisser ) { + public function __construct( MessageDismisser $dismisser ) { $this->dismisser = $dismisser; } diff --git a/tests/Unit/BasicMessageTest.php b/tests/Unit/BasicMessageTest.php index b8be6fd..96ef778 100644 --- a/tests/Unit/BasicMessageTest.php +++ b/tests/Unit/BasicMessageTest.php @@ -2,7 +2,7 @@ namespace Yoast\WHIP\Tests\Unit; -use Yoast\WHIPv2\Messages\Whip_BasicMessage; +use Yoast\WHIPv2\Messages\BasicMessage; /** * Message Unit tests. @@ -10,14 +10,14 @@ final class BasicMessageTest extends TestCase { /** - * Tests if Whip_BasicMessage correctly handles a string for its body argument. + * Tests if BasicMessage correctly handles a string for its body argument. * - * @covers \Yoast\WHIPv2\Messages\Whip_BasicMessage::body + * @covers \Yoast\WHIPv2\Messages\BasicMessage::body * * @return void */ public function testMessageHasBody() { - $message = new Whip_BasicMessage( 'This is a message' ); + $message = new BasicMessage( 'This is a message' ); $this->assertNotEmpty( $message->body() ); } @@ -25,26 +25,26 @@ public function testMessageHasBody() { /** * Tests if an Exception is correctly thrown when an empty string is passed as argument. * - * @covers \Yoast\WHIPv2\Messages\Whip_BasicMessage::validateParameters + * @covers \Yoast\WHIPv2\Messages\BasicMessage::validateParameters * * @return void */ public function testMessageCannotBeEmpty() { - $this->expectExceptionHelper( '\Yoast\WHIPv2\Exceptions\Whip_EmptyProperty', 'Message body cannot be empty.' ); + $this->expectExceptionHelper( '\Yoast\WHIPv2\Exceptions\EmptyProperty', 'Message body cannot be empty.' ); - new Whip_BasicMessage( '' ); + new BasicMessage( '' ); } /** * Tests if an Exception is correctly thrown when an invalid type is passed as argument. * - * @covers \Yoast\WHIPv2\Messages\Whip_BasicMessage::validateParameters + * @covers \Yoast\WHIPv2\Messages\BasicMessage::validateParameters * * @return void */ public function testMessageMustBeString() { - $this->expectExceptionHelper( '\Yoast\WHIPv2\Exceptions\Whip_InvalidType', 'Message body should be of type string. Found integer.' ); + $this->expectExceptionHelper( '\Yoast\WHIPv2\Exceptions\InvalidType', 'Message body should be of type string. Found integer.' ); - new Whip_BasicMessage( 123 ); + new BasicMessage( 123 ); } } diff --git a/tests/Unit/ConfigurationTest.php b/tests/Unit/ConfigurationTest.php index 8bfe07f..2f81818 100644 --- a/tests/Unit/ConfigurationTest.php +++ b/tests/Unit/ConfigurationTest.php @@ -2,7 +2,7 @@ namespace Yoast\WHIP\Tests\Unit; -use Yoast\WHIPv2\Whip_Configuration; +use Yoast\WHIPv2\Configuration; /** * Configuration unit tests. @@ -10,28 +10,28 @@ final class ConfigurationTest extends TestCase { /** - * Tests the creation of a Whip_Configuration with invalid input. + * Tests the creation of a Configuration with invalid input. * - * @covers \Yoast\WHIPv2\Whip_Configuration::__construct + * @covers \Yoast\WHIPv2\Configuration::__construct * * @return void */ public function testItThrowsAnErrorIfAFaultyConfigurationIsPassed() { - $this->expectExceptionHelper( '\Yoast\WHIPv2\Exceptions\Whip_InvalidType', 'Configuration should be of type array. Found string.' ); + $this->expectExceptionHelper( '\Yoast\WHIPv2\Exceptions\InvalidType', 'Configuration should be of type array. Found string.' ); - new Whip_Configuration( 'Invalid configuration' ); + new Configuration( 'Invalid configuration' ); } /** - * Tests if Whip_Configuration correctly returns -1 when passed an unknown requirement. + * Tests if Configuration correctly returns -1 when passed an unknown requirement. * - * @covers \Yoast\WHIPv2\Whip_Configuration::configuredVersion + * @covers \Yoast\WHIPv2\Configuration::configuredVersion * * @return void */ public function testItReturnsANegativeNumberIfRequirementCannotBeFound() { - $configuration = new Whip_Configuration( array( 'php' => '5.6' ) ); - $requirement = $this->getMockBuilder( '\Yoast\WHIPv2\Interfaces\Whip_Requirement' ) + $configuration = new Configuration( array( 'php' => '5.6' ) ); + $requirement = $this->getMockBuilder( '\Yoast\WHIPv2\Interfaces\Requirement' ) ->setMethods( array( 'component', 'version', 'operator' ) ) ->getMock(); @@ -44,15 +44,15 @@ public function testItReturnsANegativeNumberIfRequirementCannotBeFound() { } /** - * Tests if Whip_Configuration correctly returns the version number when passed a valid requirement. + * Tests if Configuration correctly returns the version number when passed a valid requirement. * - * @covers \Yoast\WHIPv2\Whip_Configuration::configuredVersion + * @covers \Yoast\WHIPv2\Configuration::configuredVersion * * @return void */ public function testItReturnsAnEntryIfRequirementIsFound() { - $configuration = new Whip_Configuration( array( 'php' => '5.6' ) ); - $requirement = $this->getMockBuilder( '\Yoast\WHIPv2\Interfaces\Whip_Requirement' ) + $configuration = new Configuration( array( 'php' => '5.6' ) ); + $requirement = $this->getMockBuilder( '\Yoast\WHIPv2\Interfaces\Requirement' ) ->setMethods( array( 'component', 'version', 'operator' ) ) ->getMock(); @@ -67,13 +67,13 @@ public function testItReturnsAnEntryIfRequirementIsFound() { /** * Tests if hasRequirementConfigures correctly returns true/false when called with valid/invalid values. * - * @covers \Yoast\WHIPv2\Whip_Configuration::hasRequirementConfigured + * @covers \Yoast\WHIPv2\Configuration::hasRequirementConfigured * * @return void */ public function testIfRequirementIsConfigured() { - $configuration = new Whip_Configuration( array( 'php' => '5.6' ) ); - $requirement = $this->getMockBuilder( '\Yoast\WHIPv2\Interfaces\Whip_Requirement' ) + $configuration = new Configuration( array( 'php' => '5.6' ) ); + $requirement = $this->getMockBuilder( '\Yoast\WHIPv2\Interfaces\Requirement' ) ->setMethods( array( 'component', 'version', 'operator' ) ) ->getMock(); @@ -82,7 +82,7 @@ public function testIfRequirementIsConfigured() { ->method( 'component' ) ->will( $this->returnValue( 'php' ) ); - $falseRequirement = $this->getMockBuilder( '\Yoast\WHIPv2\Interfaces\Whip_Requirement' ) + $falseRequirement = $this->getMockBuilder( '\Yoast\WHIPv2\Interfaces\Requirement' ) ->setMethods( array( 'component', 'version', 'operator' ) ) ->getMock(); diff --git a/tests/Unit/Doubles/DismissStorageMock.php b/tests/Unit/Doubles/DismissStorageMock.php index 152a961..b91c627 100644 --- a/tests/Unit/Doubles/DismissStorageMock.php +++ b/tests/Unit/Doubles/DismissStorageMock.php @@ -2,12 +2,12 @@ namespace Yoast\WHIP\Tests\Unit\Doubles; -use Yoast\WHIPv2\Interfaces\Whip_DismissStorage; +use Yoast\WHIPv2\Interfaces\DismissStorage; /** * Test helper. */ -final class DismissStorageMock implements Whip_DismissStorage { +final class DismissStorageMock implements DismissStorage { /** * Holds the dismissed state. diff --git a/tests/Unit/MessageDismisserTest.php b/tests/Unit/MessageDismisserTest.php index 9fbd374..04cf022 100644 --- a/tests/Unit/MessageDismisserTest.php +++ b/tests/Unit/MessageDismisserTest.php @@ -3,7 +3,7 @@ namespace Yoast\WHIP\Tests\Unit; use Yoast\WHIP\Tests\Unit\Doubles\DismissStorageMock; -use Yoast\WHIPv2\Whip_MessageDismisser; +use Yoast\WHIPv2\MessageDismisser; /** * Message Dismisser unit tests. @@ -11,17 +11,17 @@ final class MessageDismisserTest extends TestCase { /** - * Tests if Whip_MessageDismisser correctly updates Whip_DismissStorage. + * Tests if MessageDismisser correctly updates DismissStorage. * - * @covers \Yoast\WHIPv2\Whip_MessageDismisser::__construct - * @covers \Yoast\WHIPv2\Whip_MessageDismisser::dismiss + * @covers \Yoast\WHIPv2\MessageDismisser::__construct + * @covers \Yoast\WHIPv2\MessageDismisser::dismiss * * @return void */ public function testDismiss() { $currentTime = \time(); $storage = new DismissStorageMock(); - $dismisser = new Whip_MessageDismisser( $currentTime, ( \WEEK_IN_SECONDS * 4 ), $storage ); + $dismisser = new MessageDismisser( $currentTime, ( \WEEK_IN_SECONDS * 4 ), $storage ); $this->assertSame( 0, $storage->get() ); @@ -35,8 +35,8 @@ public function testDismiss() { * * @dataProvider versionNumbersProvider * - * @covers \Yoast\WHIPv2\Whip_MessageDismisser::__construct - * @covers \Yoast\WHIPv2\Whip_MessageDismisser::isDismissed + * @covers \Yoast\WHIPv2\MessageDismisser::__construct + * @covers \Yoast\WHIPv2\MessageDismisser::isDismissed * * @param int $savedTime The saved time. * @param int $currentTime The current time. @@ -47,7 +47,7 @@ public function testDismiss() { public function testIsDismissibleWithVersions( $savedTime, $currentTime, $expected ) { $storage = new DismissStorageMock(); $storage->set( $savedTime ); - $dismisser = new Whip_MessageDismisser( $currentTime, ( \WEEK_IN_SECONDS * 4 ), $storage ); + $dismisser = new MessageDismisser( $currentTime, ( \WEEK_IN_SECONDS * 4 ), $storage ); $this->assertSame( $expected, $dismisser->isDismissed() ); } diff --git a/tests/Unit/MessagesManagerTest.php b/tests/Unit/MessagesManagerTest.php index 7c52b0a..3fc7f95 100644 --- a/tests/Unit/MessagesManagerTest.php +++ b/tests/Unit/MessagesManagerTest.php @@ -2,7 +2,7 @@ namespace Yoast\WHIP\Tests\Unit; -use Yoast\WHIPv2\Whip_MessagesManager; +use Yoast\WHIPv2\MessagesManager; /** * Message Manager unit tests. @@ -13,12 +13,12 @@ final class MessagesManagerTest extends TestCase { * Creates a MessagesManager, calls hasMessages and tests if it returns false * without a message, true when given a message. * - * @covers \Yoast\WHIPv2\Whip_MessagesManager::hasMessages + * @covers \Yoast\WHIPv2\MessagesManager::hasMessages * * @return void */ public function testHasMessages() { - $manager = new Whip_MessagesManager(); + $manager = new MessagesManager(); $this->assertFalse( $manager->hasMessages() ); diff --git a/tests/Unit/RequirementsCheckerTest.php b/tests/Unit/RequirementsCheckerTest.php index 08abc23..e51c824 100644 --- a/tests/Unit/RequirementsCheckerTest.php +++ b/tests/Unit/RequirementsCheckerTest.php @@ -5,8 +5,8 @@ use Error; use Exception; use stdClass; -use Yoast\WHIPv2\Whip_RequirementsChecker; -use Yoast\WHIPv2\Whip_VersionRequirement; +use Yoast\WHIPv2\RequirementsChecker; +use Yoast\WHIPv2\VersionRequirement; /** * Requirements checker unit tests. @@ -14,25 +14,25 @@ final class RequirementsCheckerTest extends TestCase { /** - * Tests if Whip_RequirementsChecker is successfully created when given valid arguments. + * Tests if RequirementsChecker is successfully created when given valid arguments. * - * @covers \Yoast\WHIPv2\Whip_RequirementsChecker::addRequirement - * @covers \Yoast\WHIPv2\Whip_RequirementsChecker::totalRequirements + * @covers \Yoast\WHIPv2\RequirementsChecker::addRequirement + * @covers \Yoast\WHIPv2\RequirementsChecker::totalRequirements * * @return void */ public function testItReceivesAUsableRequirementObject() { - $checker = new Whip_RequirementsChecker(); - $checker->addRequirement( new Whip_VersionRequirement( 'php', '5.2' ) ); + $checker = new RequirementsChecker(); + $checker->addRequirement( new VersionRequirement( 'php', '5.2' ) ); $this->assertTrue( $checker->hasRequirements() ); $this->assertSame( 1, $checker->totalRequirements() ); } /** - * Tests if Whip_RequirementsChecker throws an error when passed an invalid requirement. + * Tests if RequirementsChecker throws an error when passed an invalid requirement. * - * @covers Whip_RequirementsChecker::addRequirement + * @covers RequirementsChecker::addRequirement * @requires PHP 7 * * @return void @@ -44,7 +44,7 @@ public function testItThrowsAnTypeErrorWhenInvalidRequirementIsPassed() { $exceptionCaught = false; - $checker = new Whip_RequirementsChecker(); + $checker = new RequirementsChecker(); try { $checker->addRequirement( new stdClass() ); @@ -56,9 +56,9 @@ public function testItThrowsAnTypeErrorWhenInvalidRequirementIsPassed() { } /** - * Tests if Whip_RequirementsChecker throws an error when passed an invalid requirement. + * Tests if RequirementsChecker throws an error when passed an invalid requirement. * - * @covers \Yoast\WHIPv2\Whip_RequirementsChecker::addRequirement + * @covers \Yoast\WHIPv2\RequirementsChecker::addRequirement * * @return void */ @@ -69,7 +69,7 @@ public function testItThrowsAnTypeErrorWhenInvalidRequirementIsPassedInPHP5() { $exceptionCaught = false; - $checker = new Whip_RequirementsChecker(); + $checker = new RequirementsChecker(); try { $checker->addRequirement( new stdClass() ); @@ -81,41 +81,41 @@ public function testItThrowsAnTypeErrorWhenInvalidRequirementIsPassedInPHP5() { } /** - * Tests if Whip_RequirementsChecker only saves unique components. + * Tests if RequirementsChecker only saves unique components. * - * @covers \Yoast\WHIPv2\Whip_RequirementsChecker::addRequirement - * @covers \Yoast\WHIPv2\Whip_RequirementsChecker::totalRequirements + * @covers \Yoast\WHIPv2\RequirementsChecker::addRequirement + * @covers \Yoast\WHIPv2\RequirementsChecker::totalRequirements * * @return void */ public function testItOnlyContainsUniqueComponents() { - $checker = new Whip_RequirementsChecker(); + $checker = new RequirementsChecker(); - $checker->addRequirement( new Whip_VersionRequirement( 'php', '5.2' ) ); - $checker->addRequirement( new Whip_VersionRequirement( 'mysql', '5.6' ) ); + $checker->addRequirement( new VersionRequirement( 'php', '5.2' ) ); + $checker->addRequirement( new VersionRequirement( 'mysql', '5.6' ) ); $this->assertTrue( $checker->hasRequirements() ); $this->assertSame( 2, $checker->totalRequirements() ); - $checker->addRequirement( new Whip_VersionRequirement( 'php', '6' ) ); + $checker->addRequirement( new VersionRequirement( 'php', '6' ) ); $this->assertSame( 2, $checker->totalRequirements() ); } /** - * Tests if Whip_RequirementsChecker::requirementExistsForComponent correctly + * Tests if RequirementsChecker::requirementExistsForComponent correctly * returns true for existing components. * - * @covers \Yoast\WHIPv2\Whip_RequirementsChecker::addRequirement - * @covers \Yoast\WHIPv2\Whip_RequirementsChecker::requirementExistsForComponent + * @covers \Yoast\WHIPv2\RequirementsChecker::addRequirement + * @covers \Yoast\WHIPv2\RequirementsChecker::requirementExistsForComponent * * @return void */ public function testIfRequirementExists() { - $checker = new Whip_RequirementsChecker(); + $checker = new RequirementsChecker(); - $checker->addRequirement( new Whip_VersionRequirement( 'php', '5.2' ) ); - $checker->addRequirement( new Whip_VersionRequirement( 'mysql', '5.6' ) ); + $checker->addRequirement( new VersionRequirement( 'php', '5.2' ) ); + $checker->addRequirement( new VersionRequirement( 'mysql', '5.6' ) ); $this->assertTrue( $checker->requirementExistsForComponent( 'php' ) ); $this->assertFalse( $checker->requirementExistsForComponent( 'mongodb' ) ); @@ -126,17 +126,17 @@ public function testIfRequirementExists() { * * Verifies that a php upgrade message is created and successfully transferred to a variable. * - * @covers \Yoast\WHIPv2\Whip_RequirementsChecker::addRequirement - * @covers \Yoast\WHIPv2\Whip_RequirementsChecker::check - * @covers \Yoast\WHIPv2\Whip_RequirementsChecker::hasMessages - * @covers \Yoast\WHIPv2\Whip_RequirementsChecker::getMostRecentMessage + * @covers \Yoast\WHIPv2\RequirementsChecker::addRequirement + * @covers \Yoast\WHIPv2\RequirementsChecker::check + * @covers \Yoast\WHIPv2\RequirementsChecker::hasMessages + * @covers \Yoast\WHIPv2\RequirementsChecker::getMostRecentMessage * * @return void */ public function testCheckIfPHPRequirementIsNotFulfilled() { - $checker = new Whip_RequirementsChecker( array( 'php' => 4 ) ); + $checker = new RequirementsChecker( array( 'php' => 4 ) ); - $checker->addRequirement( new Whip_VersionRequirement( 'php', '5.6' ) ); + $checker->addRequirement( new VersionRequirement( 'php', '5.6' ) ); $checker->check(); $this->assertTrue( $checker->hasMessages() ); @@ -155,22 +155,22 @@ public function testCheckIfPHPRequirementIsNotFulfilled() { } $this->assertFalse( $checker->hasMessages() ); - $this->assertInstanceOf( '\Yoast\WHIPv2\Messages\Whip_UpgradePhpMessage', $recentMessage ); + $this->assertInstanceOf( '\Yoast\WHIPv2\Messages\UpgradePhpMessage', $recentMessage ); } /** * Tests if there no message when the requirement is fulfilled. * - * @covers \Yoast\WHIPv2\Whip_RequirementsChecker::addRequirement - * @covers \Yoast\WHIPv2\Whip_RequirementsChecker::check - * @covers \Yoast\WHIPv2\Whip_RequirementsChecker::getMostRecentMessage + * @covers \Yoast\WHIPv2\RequirementsChecker::addRequirement + * @covers \Yoast\WHIPv2\RequirementsChecker::check + * @covers \Yoast\WHIPv2\RequirementsChecker::getMostRecentMessage * * @return void */ public function testCheckIfRequirementIsFulfilled() { - $checker = new Whip_RequirementsChecker( array( 'php' => \phpversion() ) ); + $checker = new RequirementsChecker( array( 'php' => \phpversion() ) ); - $checker->addRequirement( new Whip_VersionRequirement( 'php', '5.2' ) ); + $checker->addRequirement( new VersionRequirement( 'php', '5.2' ) ); $checker->check(); $this->assertEmpty( $checker->getMostRecentMessage()->body() ); @@ -181,17 +181,17 @@ public function testCheckIfRequirementIsFulfilled() { * * Verifies that an invalid version message is created and successfully transferred to a variable. * - * @covers \Yoast\WHIPv2\Whip_RequirementsChecker::addRequirement - * @covers \Yoast\WHIPv2\Whip_RequirementsChecker::check - * @covers \Yoast\WHIPv2\Whip_RequirementsChecker::getMostRecentMessage - * @covers \Yoast\WHIPv2\Whip_RequirementsChecker::hasMessages + * @covers \Yoast\WHIPv2\RequirementsChecker::addRequirement + * @covers \Yoast\WHIPv2\RequirementsChecker::check + * @covers \Yoast\WHIPv2\RequirementsChecker::getMostRecentMessage + * @covers \Yoast\WHIPv2\RequirementsChecker::hasMessages * * @return void */ public function testCheckIfRequirementIsNotFulfilled() { - $checker = new Whip_RequirementsChecker( array( 'mysql' => 4 ) ); + $checker = new RequirementsChecker( array( 'mysql' => 4 ) ); - $checker->addRequirement( new Whip_VersionRequirement( 'mysql', '5.6' ) ); + $checker->addRequirement( new VersionRequirement( 'mysql', '5.6' ) ); $checker->check(); $this->assertTrue( $checker->hasMessages() ); @@ -201,23 +201,23 @@ public function testCheckIfRequirementIsNotFulfilled() { $this->assertNotEmpty( $recentMessage ); $this->assertFalse( $checker->hasMessages() ); - $this->assertInstanceOf( '\Yoast\WHIPv2\Messages\Whip_InvalidVersionRequirementMessage', $recentMessage ); + $this->assertInstanceOf( '\Yoast\WHIPv2\Messages\InvalidVersionRequirementMessage', $recentMessage ); $this->assertStringStartsWith( 'Invalid version detected', $recentMessage->body() ); } /** * Tests if a specific comparison with a non-default operator is correctly handled. * - * @covers \Yoast\WHIPv2\Whip_RequirementsChecker::addRequirement - * @covers \Yoast\WHIPv2\Whip_RequirementsChecker::check - * @covers \Yoast\WHIPv2\Whip_RequirementsChecker::hasMessages + * @covers \Yoast\WHIPv2\RequirementsChecker::addRequirement + * @covers \Yoast\WHIPv2\RequirementsChecker::check + * @covers \Yoast\WHIPv2\RequirementsChecker::hasMessages * * @return void */ public function testCheckIfRequirementIsFulfilledWithSpecificComparison() { - $checker = new Whip_RequirementsChecker( array( 'php' => 4 ) ); + $checker = new RequirementsChecker( array( 'php' => 4 ) ); - $checker->addRequirement( new Whip_VersionRequirement( 'php', '5.2', '<' ) ); + $checker->addRequirement( new VersionRequirement( 'php', '5.2', '<' ) ); $checker->check(); $this->assertFalse( $checker->hasMessages() ); @@ -226,16 +226,16 @@ public function testCheckIfRequirementIsFulfilledWithSpecificComparison() { /** * Tests if a specific comparison with a non-default operator is correctly handled. * - * @covers \Yoast\WHIPv2\Whip_RequirementsChecker::addRequirement - * @covers \Yoast\WHIPv2\Whip_RequirementsChecker::check - * @covers \Yoast\WHIPv2\Whip_RequirementsChecker::hasMessages + * @covers \Yoast\WHIPv2\RequirementsChecker::addRequirement + * @covers \Yoast\WHIPv2\RequirementsChecker::check + * @covers \Yoast\WHIPv2\RequirementsChecker::hasMessages * * @return void */ public function testCheckIfRequirementIsNotFulfilledWithSpecificComparison() { - $checker = new Whip_RequirementsChecker( array( 'php' => 4 ) ); + $checker = new RequirementsChecker( array( 'php' => 4 ) ); - $checker->addRequirement( new Whip_VersionRequirement( 'php', '5.2', '>=' ) ); + $checker->addRequirement( new VersionRequirement( 'php', '5.2', '>=' ) ); $checker->check(); $this->assertTrue( $checker->hasMessages() ); diff --git a/tests/Unit/VersionRequirementTest.php b/tests/Unit/VersionRequirementTest.php index 2420c9e..1add33a 100644 --- a/tests/Unit/VersionRequirementTest.php +++ b/tests/Unit/VersionRequirementTest.php @@ -2,7 +2,7 @@ namespace Yoast\WHIP\Tests\Unit; -use Yoast\WHIPv2\Whip_VersionRequirement; +use Yoast\WHIPv2\VersionRequirement; /** * Version requirements unit tests. @@ -10,133 +10,133 @@ final class VersionRequirementTest extends TestCase { /** - * Creates a new Whip_VersionRequirement with component php and version 5.2 and + * Creates a new VersionRequirement with component php and version 5.2 and * tests if this is correctly created. * - * @covers \Yoast\WHIPv2\Whip_VersionRequirement::component - * @covers \Yoast\WHIPv2\Whip_VersionRequirement::version + * @covers \Yoast\WHIPv2\VersionRequirement::component + * @covers \Yoast\WHIPv2\VersionRequirement::version * * @return void */ public function testNameAndVersionAreNotEmpty() { - $requirement = new Whip_VersionRequirement( 'php', '5.2' ); + $requirement = new VersionRequirement( 'php', '5.2' ); $this->assertNotEmpty( $requirement->component() ); $this->assertNotEmpty( $requirement->version() ); } /** - * Tests if an Exception message is correctly thrown when a Whip_VersionRequirement + * Tests if an Exception message is correctly thrown when a VersionRequirement * is created with an empty component. * - * @covers \Yoast\WHIPv2\Whip_VersionRequirement::validateParameters + * @covers \Yoast\WHIPv2\VersionRequirement::validateParameters * * @return void */ public function testComponentCannotBeEmpty() { - $this->expectExceptionHelper( '\Yoast\WHIPv2\Exceptions\Whip_EmptyProperty', 'Component cannot be empty.' ); + $this->expectExceptionHelper( '\Yoast\WHIPv2\Exceptions\EmptyProperty', 'Component cannot be empty.' ); - new Whip_VersionRequirement( '', '5.2' ); + new VersionRequirement( '', '5.2' ); } /** - * Tests if an Exception message is correctly thrown when a Whip_VersionRequirement + * Tests if an Exception message is correctly thrown when a VersionRequirement * is created with an empty version. * - * @covers \Yoast\WHIPv2\Whip_VersionRequirement::validateParameters + * @covers \Yoast\WHIPv2\VersionRequirement::validateParameters * * @return void */ public function testVersionCannotBeEmpty() { - $this->expectExceptionHelper( '\Yoast\WHIPv2\Exceptions\Whip_EmptyProperty', 'Version cannot be empty.' ); + $this->expectExceptionHelper( '\Yoast\WHIPv2\Exceptions\EmptyProperty', 'Version cannot be empty.' ); - new Whip_VersionRequirement( 'php', '' ); + new VersionRequirement( 'php', '' ); } /** - * Tests if an Exception message is correctly thrown when a Whip_VersionRequirement + * Tests if an Exception message is correctly thrown when a VersionRequirement * is created with a false type for a component. * - * @covers \Yoast\WHIPv2\Whip_VersionRequirement::validateParameters + * @covers \Yoast\WHIPv2\VersionRequirement::validateParameters * * @return void */ public function testComponentMustBeString() { - $this->expectExceptionHelper( '\Yoast\WHIPv2\Exceptions\Whip_InvalidType', 'Component should be of type string. Found integer.' ); + $this->expectExceptionHelper( '\Yoast\WHIPv2\Exceptions\InvalidType', 'Component should be of type string. Found integer.' ); - new Whip_VersionRequirement( 123, '5.2' ); + new VersionRequirement( 123, '5.2' ); } /** - * Tests if an Exception message is correctly thrown when a Whip_VersionRequirement + * Tests if an Exception message is correctly thrown when a VersionRequirement * is created with a false type for a version. * - * @covers \Yoast\WHIPv2\Whip_VersionRequirement::validateParameters + * @covers \Yoast\WHIPv2\VersionRequirement::validateParameters * * @return void */ public function testVersionMustBeString() { - $this->expectExceptionHelper( '\Yoast\WHIPv2\Exceptions\Whip_InvalidType', 'Version should be of type string. Found integer.' ); + $this->expectExceptionHelper( '\Yoast\WHIPv2\Exceptions\InvalidType', 'Version should be of type string. Found integer.' ); - new Whip_VersionRequirement( 'php', 123 ); + new VersionRequirement( 'php', 123 ); } /** - * Tests if an Exception message is correctly thrown when a Whip_VersionRequirement + * Tests if an Exception message is correctly thrown when a VersionRequirement * is created with an empty operator. * - * @covers \Yoast\WHIPv2\Whip_VersionRequirement::validateParameters + * @covers \Yoast\WHIPv2\VersionRequirement::validateParameters * * @return void */ public function testOperatorCannotBeEmpty() { - $this->expectExceptionHelper( '\Yoast\WHIPv2\Exceptions\Whip_EmptyProperty', 'Operator cannot be empty.' ); + $this->expectExceptionHelper( '\Yoast\WHIPv2\Exceptions\EmptyProperty', 'Operator cannot be empty.' ); - new Whip_VersionRequirement( 'php', '5.6', '' ); + new VersionRequirement( 'php', '5.6', '' ); } /** - * Tests if an Exception message is correctly thrown when a Whip_VersionRequirement + * Tests if an Exception message is correctly thrown when a VersionRequirement * is created with a false type for an operator. * - * @covers \Yoast\WHIPv2\Whip_VersionRequirement::validateParameters + * @covers \Yoast\WHIPv2\VersionRequirement::validateParameters * * @return void */ public function testOperatorMustBeString() { - $this->expectExceptionHelper( '\Yoast\WHIPv2\Exceptions\Whip_InvalidType', 'Operator should be of type string. Found integer.' ); + $this->expectExceptionHelper( '\Yoast\WHIPv2\Exceptions\InvalidType', 'Operator should be of type string. Found integer.' ); - new Whip_VersionRequirement( 'php', '5.2', 6 ); + new VersionRequirement( 'php', '5.2', 6 ); } /** - * Tests if an Exception message is correctly thrown when a Whip_VersionRequirement + * Tests if an Exception message is correctly thrown when a VersionRequirement * is created with an invalid operator. * - * @covers \Yoast\WHIPv2\Whip_VersionRequirement::validateParameters + * @covers \Yoast\WHIPv2\VersionRequirement::validateParameters * * @return void */ public function testOperatorMustBeValid() { $this->expectExceptionHelper( - '\Yoast\WHIPv2\Exceptions\Whip_InvalidOperatorType', + '\Yoast\WHIPv2\Exceptions\InvalidOperatorType', 'Invalid operator of -> used. Please use one of the following operators: =, ==, ===, <, >, <=, >=' ); - new Whip_VersionRequirement( 'php', '5.2', '->' ); + new VersionRequirement( 'php', '5.2', '->' ); } /** - * Creates a new Whip_VersionRequirement and tests if this is correctly created with its given arguments. + * Creates a new VersionRequirement and tests if this is correctly created with its given arguments. * - * @covers \Yoast\WHIPv2\Whip_VersionRequirement::component - * @covers \Yoast\WHIPv2\Whip_VersionRequirement::version - * @covers \Yoast\WHIPv2\Whip_VersionRequirement::operator + * @covers \Yoast\WHIPv2\VersionRequirement::component + * @covers \Yoast\WHIPv2\VersionRequirement::version + * @covers \Yoast\WHIPv2\VersionRequirement::operator * * @return void */ public function testGettingComponentProperties() { - $requirement = new Whip_VersionRequirement( 'php', '5.6' ); + $requirement = new VersionRequirement( 'php', '5.6' ); $this->assertSame( 'php', $requirement->component() ); $this->assertSame( '5.6', $requirement->version() ); @@ -148,9 +148,9 @@ public function testGettingComponentProperties() { * * @dataProvider dataFromCompareString * - * @covers \Yoast\WHIPv2\Whip_VersionRequirement::component - * @covers \Yoast\WHIPv2\Whip_VersionRequirement::version - * @covers \Yoast\WHIPv2\Whip_VersionRequirement::operator + * @covers \Yoast\WHIPv2\VersionRequirement::component + * @covers \Yoast\WHIPv2\VersionRequirement::version + * @covers \Yoast\WHIPv2\VersionRequirement::operator * * @param string $expectation The expected output string. * @param string $component The component for this version requirement. @@ -159,7 +159,7 @@ public function testGettingComponentProperties() { * @return void */ public function testFromCompareString( $expectation, $component, $compareString ) { - $requirement = Whip_VersionRequirement::fromCompareString( $component, $compareString ); + $requirement = VersionRequirement::fromCompareString( $component, $compareString ); $this->assertSame( $expectation[0], $requirement->component() ); $this->assertSame( $expectation[1], $requirement->version() ); @@ -188,16 +188,16 @@ public static function dataFromCompareString() { * Tests whether fromCompareString() correctly throws an exception when provided * with an invalid comparison string. * - * @covers \Yoast\WHIPv2\Whip_VersionRequirement::fromCompareString + * @covers \Yoast\WHIPv2\VersionRequirement::fromCompareString * * @return void */ public function testFromCompareStringException() { $this->expectExceptionHelper( - '\Yoast\WHIPv2\Exceptions\Whip_InvalidVersionComparisonString', + '\Yoast\WHIPv2\Exceptions\InvalidVersionComparisonString', 'Invalid version comparison string. Example of a valid version comparison string: >=5.3. Passed version comparison string: > 2.3' ); - Whip_VersionRequirement::fromCompareString( 'php', '> 2.3' ); + VersionRequirement::fromCompareString( 'php', '> 2.3' ); } } diff --git a/tests/Unit/WPMessageDismissListenerTest.php b/tests/Unit/WPMessageDismissListenerTest.php index 9873e7a..964d2dc 100644 --- a/tests/Unit/WPMessageDismissListenerTest.php +++ b/tests/Unit/WPMessageDismissListenerTest.php @@ -2,12 +2,12 @@ namespace Yoast\WHIP\Tests\Unit; -use Yoast\WHIPv2\Whip_WPMessageDismissListener; +use Yoast\WHIPv2\WPMessageDismissListener; /** * Message Dismiss Listener unit tests. * - * @coversDefaultClass Whip_WPMessageDismissListener + * @coversDefaultClass WPMessageDismissListener * * @phpcs:disable Yoast.NamingConventions.ObjectNameDepth.MaxExceeded -- Acronym throws the count off. */ @@ -16,7 +16,7 @@ final class WPMessageDismissListenerTest extends TestCase { /** * Tests the listen method. * - * @covers \Yoast\WHIPv2\Whip_WPMessageDismissListener::listen + * @covers \Yoast\WHIPv2\WPMessageDismissListener::listen * * @dataProvider listenProvider * @@ -29,11 +29,11 @@ final class WPMessageDismissListenerTest extends TestCase { * @return void */ public function testDismiss( $action, $nonce, $verifyNonceTimes, $isCorrectNonce, $dismissTimes ) { - $dismisser = $this->getMockBuilder( '\Yoast\WHIPv2\Whip_MessageDismisser' ) + $dismisser = $this->getMockBuilder( '\Yoast\WHIPv2\MessageDismisser' ) ->disableOriginalConstructor() ->getMock(); - $instance = new Whip_WPMessageDismissListener( $dismisser ); + $instance = new WPMessageDismissListener( $dismisser ); $_GET['action'] = $action; $_GET['nonce'] = $nonce; @@ -57,7 +57,7 @@ public function testDismiss( $action, $nonce, $verifyNonceTimes, $isCorrectNonce public static function listenProvider() { return array( 'correct action and nonce' => array( - 'action' => Whip_WPMessageDismissListener::ACTION_NAME, + 'action' => WPMessageDismissListener::ACTION_NAME, 'nonce' => 'the_right_nonce', 'verifyNonceTimes' => 1, 'isCorrectNonce' => true, @@ -71,7 +71,7 @@ public static function listenProvider() { 'dismissTimes' => 0, ), 'correct action incorrect nonce' => array( - 'action' => Whip_WPMessageDismissListener::ACTION_NAME, + 'action' => WPMessageDismissListener::ACTION_NAME, 'nonce' => 'wrong_nonce', 'verifyNonceTimes' => 1, 'isCorrectNonce' => false,