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 53dbb22..eb68aa6 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(
'
',
$this->kses( $this->message->body() ),
$dismissButton
@@ -106,7 +108,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();