diff --git a/RoboFile.php b/RoboFile.php index a2ad1421bd..1540b311f0 100644 --- a/RoboFile.php +++ b/RoboFile.php @@ -17,7 +17,7 @@ class RoboFile extends \Robo\Tasks { $dotenv->load(); } - function install() { + public function install() { return $this->taskExecStack() ->stopOnFail() ->exec('./tools/vendor/composer.phar install') @@ -25,7 +25,7 @@ class RoboFile extends \Robo\Tasks { ->run(); } - function update() { + public function update() { return $this->taskExecStack() ->stopOnFail() ->exec('./tools/vendor/composer.phar update') @@ -33,7 +33,7 @@ class RoboFile extends \Robo\Tasks { ->run(); } - function watch() { + public function watch() { $this->say('Warning: this lints and compiles all files, not just the changed one. Use separate tasks watch:js and watch:css for faster and more efficient watching.'); $css_files = $this->rsearch('assets/css/src/', ['scss']); $js_files = $this->rsearch('assets/js/src/', ['js', 'jsx']); @@ -48,7 +48,7 @@ class RoboFile extends \Robo\Tasks { ->run(); } - function watchCss() { + public function watchCss() { $css_files = $this->rsearch('assets/css/src/', ['scss']); $this->taskWatch() ->monitor($css_files, function($changedFile) { @@ -63,11 +63,11 @@ class RoboFile extends \Robo\Tasks { ->run(); } - function watchJs() { + public function watchJs() { $this->_exec('./node_modules/webpack/bin/webpack.js --watch'); } - function compileAll($opts = ['env' => null]) { + public function compileAll($opts = ['env' => null]) { $collection = $this->collectionBuilder(); $collection->addCode(function() use ($opts) { return call_user_func([$this, 'compileJs'], $opts); @@ -78,7 +78,7 @@ class RoboFile extends \Robo\Tasks { return $collection->run(); } - function compileJs($opts = ['env' => null]) { + public function compileJs($opts = ['env' => null]) { if (!is_dir('assets/dist/js')) { mkdir('assets/dist/js', 0777, true); } @@ -88,7 +88,7 @@ class RoboFile extends \Robo\Tasks { return $this->_exec($env . ' ./node_modules/webpack/bin/webpack.js --bail'); } - function compileCss($opts = ['env' => null]) { + public function compileCss($opts = ['env' => null]) { if (!is_dir('assets/dist/css')) { mkdir('assets/dist/css', 0777, true); } @@ -119,33 +119,33 @@ class RoboFile extends \Robo\Tasks { return $compilation_result; } - function translationsInit() { + public function translationsInit() { // Define WP_TRANSIFEX_API_TOKEN env. variable return $this->_exec('./tasks/transifex_init.sh'); } - function translationsBuild() { + public function translationsBuild() { return $this->_exec('./node_modules/.bin/grunt makepot' . ' --gruntfile=' . __DIR__ . '/tasks/makepot/makepot.js' . ' --base_path=' . __DIR__ ); } - function translationsPack() { + public function translationsPack() { return $this->collectionBuilder() ->addCode([$this, 'translationsInit']) ->taskExec('./tasks/pack_translations.sh') ->run(); } - function translationsPush() { + public function translationsPush() { return $this->collectionBuilder() ->addCode([$this, 'translationsInit']) ->taskExec('tx push -s') ->run(); } - function testUnit(array $opts=['file' => null, 'xml' => false, 'multisite' => false, 'debug' => false]) { + public function testUnit(array $opts=['file' => null, 'xml' => false, 'multisite' => false, 'debug' => false]) { $command = 'vendor/bin/codecept run unit'; if ($opts['file']) { @@ -163,7 +163,7 @@ class RoboFile extends \Robo\Tasks { return $this->_exec($command); } - function testIntegration(array $opts=['file' => null, 'xml' => false, 'multisite' => false, 'debug' => false]) { + public function testIntegration(array $opts=['file' => null, 'xml' => false, 'multisite' => false, 'debug' => false]) { $command = 'vendor/bin/codecept run integration'; if ($opts['multisite']) { @@ -185,11 +185,11 @@ class RoboFile extends \Robo\Tasks { return $this->_exec($command); } - function testMultisiteIntegration($opts=['file' => null, 'xml' => false, 'multisite' => true]) { + public function testMultisiteIntegration($opts=['file' => null, 'xml' => false, 'multisite' => true]) { return $this->testIntegration($opts); } - function testCoverage($opts=['file' => null, 'xml' => false]) { + public function testCoverage($opts=['file' => null, 'xml' => false]) { $command = join(' ', [ 'vendor/bin/codecept run -s acceptance', (($opts['file']) ? $opts['file'] : ''), @@ -204,7 +204,7 @@ class RoboFile extends \Robo\Tasks { return $this->execWithXDebug($command); } - function testNewsletterEditor($xml_output_file = null) { + public function testNewsletterEditor($xml_output_file = null) { $this->compileJs(); $command = join(' ', [ @@ -223,7 +223,7 @@ class RoboFile extends \Robo\Tasks { return $this->_exec($command); } - function testJavascript($xml_output_file = null) { + public function testJavascript($xml_output_file = null) { $command = './node_modules/.bin/mocha --require @babel/register tests/javascript/**/*.spec.js'; if (!empty($xml_output_file)) { @@ -236,22 +236,22 @@ class RoboFile extends \Robo\Tasks { return $this->_exec($command); } - function securityComposer() { + public function securityComposer() { return $this->collectionBuilder() ->taskExec('vendor/bin/security-checker security:check --format=simple') ->taskExec('vendor/bin/security-checker security:check --format=simple prefixer/composer.lock') ->run(); } - function testDebugUnit($opts=['file' => null, 'xml' => false, 'debug' => true]) { + public function testDebugUnit($opts=['file' => null, 'xml' => false, 'debug' => true]) { return $this->testUnit($opts); } - function testDebugIntegration($opts=['file' => null, 'xml' => false, 'debug' => true]) { + public function testDebugIntegration($opts=['file' => null, 'xml' => false, 'debug' => true]) { return $this->testIntegration($opts); } - function testAcceptance($opts=['file' => null, 'skip-deps' => false, 'timeout' => null]) { + public function testAcceptance($opts=['file' => null, 'skip-deps' => false, 'timeout' => null]) { return $this->taskExec( 'COMPOSE_HTTP_TIMEOUT=200 docker-compose run ' . ($opts['skip-deps'] ? '-e SKIP_DEPS=1 ' : '') . @@ -261,7 +261,7 @@ class RoboFile extends \Robo\Tasks { )->dir(__DIR__ . '/tests/docker')->run(); } - function testAcceptanceMultisite($opts=['file' => null, 'skip-deps' => false, 'timeout' => null]) { + public function testAcceptanceMultisite($opts=['file' => null, 'skip-deps' => false, 'timeout' => null]) { return $this->taskExec( 'COMPOSE_HTTP_TIMEOUT=200 docker-compose run ' . ($opts['skip-deps'] ? '-e SKIP_DEPS=1 ' : '') . @@ -272,23 +272,23 @@ class RoboFile extends \Robo\Tasks { )->dir(__DIR__ . '/tests/docker')->run(); } - function deleteDocker() { + public function deleteDocker() { return $this->taskExec( 'docker-compose down -v --remove-orphans --rmi all' )->dir(__DIR__ . '/tests/docker')->run(); } - function testFailedUnit() { + public function testFailedUnit() { $this->_exec('vendor/bin/codecept build'); return $this->_exec('vendor/bin/codecept run unit -g failed'); } - function testFailedIntegration() { + public function testFailedIntegration() { $this->_exec('vendor/bin/codecept build'); return $this->_exec('vendor/bin/codecept run integration -g failed'); } - function containerDump() { + public function containerDump() { define('ABSPATH', getenv('WP_ROOT') . '/'); if (!file_exists(ABSPATH . 'wp-config.php')) { $this->yell('WP_ROOT env variable does not contain valid path to wordpress root.', 40, 'red'); @@ -313,7 +313,7 @@ class RoboFile extends \Robo\Tasks { ); } - function doctrineGenerateMetadata() { + public function doctrineGenerateMetadata() { $doctrine_metadata_dir = \MailPoet\Doctrine\ConfigurationFactory::METADATA_DIR; $validator_metadata_dir = \MailPoet\Doctrine\Validator\ValidatorFactory::METADATA_DIR; $this->_exec("rm -rf $doctrine_metadata_dir"); @@ -334,7 +334,7 @@ class RoboFile extends \Robo\Tasks { $this->say("Validator metadata generated to: $validator_metadata_dir"); } - function doctrineGenerateProxies() { + public function doctrineGenerateProxies() { $proxy_dir = \MailPoet\Doctrine\ConfigurationFactory::PROXY_DIR; $this->_exec("rm -rf $proxy_dir"); @@ -347,7 +347,7 @@ class RoboFile extends \Robo\Tasks { $this->say("Doctrine proxies generated to: $proxy_dir"); } - function qa() { + public function qa() { $collection = $this->collectionBuilder(); $collection->addCode([$this, 'qaLint']); $collection->addCode(function() { @@ -358,19 +358,19 @@ class RoboFile extends \Robo\Tasks { return $collection->run(); } - function qaLint() { + public function qaLint() { return $this->_exec('./tasks/code_sniffer/vendor/bin/parallel-lint lib/ tests/ mailpoet.php'); } - function qaLintJavascript() { + public function qaLintJavascript() { return $this->_exec('npm run lint'); } - function qaLintCss() { + public function qaLintCss() { return $this->_exec('npm run stylelint -- "assets/css/src/components/**/*.scss"'); } - function qaCodeSniffer($severity='errors') { + public function qaCodeSniffer($severity='errors') { $severityFlag = $severity === 'all' ? '-w' : '-n'; $task = implode(' ', [ './tasks/code_sniffer/vendor/bin/phpcs', @@ -422,7 +422,7 @@ class RoboFile extends \Robo\Tasks { ->run(); } - function qaFixFile($filePath) { + public function qaFixFile($filePath) { if (substr($filePath, -4) === '.php') { // fix PHPCS rules return $this->collectionBuilder() @@ -469,7 +469,7 @@ class RoboFile extends \Robo\Tasks { } } - function qaPhpstan() { + public function qaPhpstan() { $dir = __DIR__; $task = implode(' ', [ 'WP_ROOT="' . getenv('WP_ROOT') . '"', @@ -501,7 +501,7 @@ class RoboFile extends \Robo\Tasks { ->run(); } - function svnCheckout() { + public function svnCheckout() { $svn_dir = ".mp_svn"; $collection = $this->collectionBuilder(); @@ -524,7 +524,7 @@ class RoboFile extends \Robo\Tasks { ->run(); } - function svnPushTemplates() { + public function svnPushTemplates() { $collection = $this->collectionBuilder(); $this->svnCheckout(); $awkCmd = '{print " --force \""$2"\""}'; @@ -539,7 +539,7 @@ class RoboFile extends \Robo\Tasks { ->run(); } - function svnPublish() { + public function svnPublish() { $svn_dir = ".mp_svn"; $plugin_version = $this->getPluginVersion('mailpoet.php'); $plugin_dist_name = 'mailpoet'; @@ -825,13 +825,13 @@ class RoboFile extends \Robo\Tasks { ->run(); } - function releaseChangelogGet($version = null) { + public function releaseChangelogGet($version = null) { $outputs = $this->getChangelogController()->get($version); $this->say("Changelog \n{$outputs[0]} \n{$outputs[1]}\n"); $this->say("IMPORTANT NOTES \n" . ($outputs[2] ?: 'none')); } - function releaseChangelogWrite($version = null) { + public function releaseChangelogWrite($version = null) { $this->say("Updating changelog"); $outputs = $this->getChangelogController()->update($version); $this->say("Changelog \n{$outputs[0]} \n{$outputs[1]}\n\n"); diff --git a/lib/API/API.php b/lib/API/API.php index 74cf971041..abff538350 100644 --- a/lib/API/API.php +++ b/lib/API/API.php @@ -12,7 +12,7 @@ class API { * @return \MailPoet\API\MP\v1\API * @throws \Exception */ - static function MP($version) { + public static function MP($version) { $api_class = sprintf('%s\MP\%s\API', __NAMESPACE__, $version); try { return ContainerWrapper::getInstance()->get($api_class); diff --git a/lib/API/JSON/API.php b/lib/API/JSON/API.php index 662c4d8ca8..fa52b69f2a 100644 --- a/lib/API/JSON/API.php +++ b/lib/API/JSON/API.php @@ -42,7 +42,7 @@ class API { const CURRENT_VERSION = 'v1'; - function __construct( + public function __construct( ContainerInterface $container, AccessControl $access_control, SettingsController $settings, @@ -60,7 +60,7 @@ class API { } } - function init() { + public function init() { // admin security token and API version WPFunctions::get()->addAction( 'admin_head', @@ -80,7 +80,7 @@ class API { ); } - function setupAjax() { + public function setupAjax() { $this->wp->doAction('mailpoet_api_setup', [$this]); if (isset($_POST['api_version'])) { @@ -105,7 +105,7 @@ class API { $response->send(); } - function setRequestData($data, $request_type) { + public function setRequestData($data, $request_type) { $this->_request_api_version = !empty($data['api_version']) ? $data['api_version'] : false; $this->_request_endpoint = isset($data['endpoint']) @@ -162,7 +162,7 @@ class API { } } - function processRoute() { + public function processRoute() { try { if (empty($this->_request_endpoint_class) || !$this->container->has($this->_request_endpoint_class) @@ -203,18 +203,18 @@ class API { } } - function validatePermissions($request_method, $permissions) { + public function validatePermissions($request_method, $permissions) { // validate method permission if defined, otherwise validate global permission return(!empty($permissions['methods'][$request_method])) ? $this->access_control->validatePermission($permissions['methods'][$request_method]) : $this->access_control->validatePermission($permissions['global']); } - function checkToken() { + public function checkToken() { return WPFunctions::get()->wpVerifyNonce($this->_request_token, 'mailpoet_token'); } - function setTokenAndAPIVersion() { + public function setTokenAndAPIVersion() { $global = '' . "\n" @@ -48,7 +48,7 @@ class AssetsTest extends \MailPoetTest { ); } - function testItGeneratesStylesheetTagsForAssetsUsingManifestFile() { + public function testItGeneratesStylesheetTagsForAssetsUsingManifestFile() { $manifest = [ 'style1.css' => 'style1.hash.css', 'style2.css' => 'style2.hash.css', @@ -69,7 +69,7 @@ class AssetsTest extends \MailPoetTest { ); } - function testItGeneratesStylesheetTagsWhenManifestFileDoesNotExist() { + public function testItGeneratesStylesheetTagsWhenManifestFileDoesNotExist() { expect($this->assets_extension->generateStylesheet('style1.css', 'style2.css'))->equals( '' . "\n" @@ -77,13 +77,13 @@ class AssetsTest extends \MailPoetTest { ); } - function testItGeneratesImageUrls() { + public function testItGeneratesImageUrls() { expect($this->assets_extension->generateImageUrl('image1.png'))->equals( $this->assets_url . '/img/image1.png?mailpoet_version=' . $this->version ); } - function testItAppendsVersionToUrl() { + public function testItAppendsVersionToUrl() { $without_file = 'http://url.com/'; expect($this->assets_extension->appendVersionToUrl($without_file))->equals( $without_file . '?mailpoet_version=' . $this->version diff --git a/tests/integration/Twig/FunctionsTest.php b/tests/integration/Twig/FunctionsTest.php index 3389512063..c8921afae5 100644 --- a/tests/integration/Twig/FunctionsTest.php +++ b/tests/integration/Twig/FunctionsTest.php @@ -7,7 +7,7 @@ use MailPoet\Twig\Functions; use MailPoet\WP\Functions as WPFunctions; class FunctionsTest extends \MailPoetTest { - function testItExecutesIsRtlFunction() { + public function testItExecutesIsRtlFunction() { $template = ['template' => '{% if is_rtl() %}rtl{% endif %}']; $twig = new \MailPoetVendor\Twig_Environment(new \MailPoetVendor\Twig_Loader_Array($template)); WPFunctions::set(Stub::make(new WPFunctions, [ @@ -21,7 +21,7 @@ class FunctionsTest extends \MailPoetTest { expect($result_no_rtl)->isEmpty(); } - function _after() { + public function _after() { WPFunctions::set(new WPFunctions); } } diff --git a/tests/integration/Util/ConflictResolverTest.php b/tests/integration/Util/ConflictResolverTest.php index c40a207618..e180e24f21 100644 --- a/tests/integration/Util/ConflictResolverTest.php +++ b/tests/integration/Util/ConflictResolverTest.php @@ -9,7 +9,7 @@ class ConflictResolverTest extends \MailPoetTest { public $conflict_resolver; public $wp_filter; - function __construct() { + public function __construct() { parent::__construct(); $this->conflict_resolver = new ConflictResolver(); $this->conflict_resolver->init(); @@ -17,7 +17,7 @@ class ConflictResolverTest extends \MailPoetTest { $this->wp_filter = $wp_filter; } - function testItResolvesRouterUrlQueryParametersConflict() { + public function testItResolvesRouterUrlQueryParametersConflict() { expect(!empty($this->wp_filter['mailpoet_conflict_resolver_router_url_query_parameters']))->true(); // it should unset action & endpoint GET variables $_GET['endpoint'] = $_GET['action'] = $_GET['test'] = 'test'; @@ -27,7 +27,7 @@ class ConflictResolverTest extends \MailPoetTest { expect(empty($_GET['test']))->false(); } - function testItUnloadsAllStylesFromLocationsNotOnPermittedList() { + public function testItUnloadsAllStylesFromLocationsNotOnPermittedList() { expect(!empty($this->wp_filter['mailpoet_conflict_resolver_styles']))->true(); // grab a random permitted style location $permitted_asset_location = $this->conflict_resolver->permitted_assets_locations['styles'][array_rand($this->conflict_resolver->permitted_assets_locations['styles'], 1)]; @@ -45,7 +45,7 @@ class ConflictResolverTest extends \MailPoetTest { expect(in_array('permitted_style', $wp_styles->queue))->true(); } - function testItWhitelistsStyles() { + public function testItWhitelistsStyles() { wp_enqueue_style('select2', '/wp-content/some/offending/plugin/select2.css'); $wp = new WPFunctions; $wp->addFilter( @@ -65,7 +65,7 @@ class ConflictResolverTest extends \MailPoetTest { expect(in_array('select2', $wp_styles->queue))->true(); } - function testItUnloadsAllScriptsFromLocationsNotOnPermittedList() { + public function testItUnloadsAllScriptsFromLocationsNotOnPermittedList() { expect(!empty($this->wp_filter['mailpoet_conflict_resolver_scripts']))->true(); // grab a random permitted script location $permitted_asset_location = $this->conflict_resolver->permitted_assets_locations['scripts'][array_rand($this->conflict_resolver->permitted_assets_locations['scripts'], 1)]; @@ -83,7 +83,7 @@ class ConflictResolverTest extends \MailPoetTest { expect(in_array('permitted_script', $wp_scripts->queue))->true(); } - function testItWhitelistsScripts() { + public function testItWhitelistsScripts() { wp_enqueue_script('select2', '/wp-content/some/offending/plugin/select2.js'); $wp = new WPFunctions; $wp->addFilter( @@ -101,6 +101,6 @@ class ConflictResolverTest extends \MailPoetTest { expect(in_array('select2', $wp_scripts->queue))->true(); } - function _after() { + public function _after() { } } \ No newline at end of file diff --git a/tests/integration/Util/Notices/InactiveSubscribersNoticeTest.php b/tests/integration/Util/Notices/InactiveSubscribersNoticeTest.php index b44bffb4a9..8ac45635a2 100644 --- a/tests/integration/Util/Notices/InactiveSubscribersNoticeTest.php +++ b/tests/integration/Util/Notices/InactiveSubscribersNoticeTest.php @@ -11,7 +11,7 @@ use MailPoet\WP\Functions as WPFunctions; use MailPoetVendor\Idiorm\ORM; class InactiveSubscribersNoticeTest extends \MailPoetTest { - function testItDisplays() { + public function testItDisplays() { $this->createSubscribers(50); $notice = new InactiveSubscribersNotice(SettingsController::getInstance(), new WPFunctions()); @@ -21,7 +21,7 @@ class InactiveSubscribersNoticeTest extends \MailPoetTest { expect($result)->contains('Go to the Advanced Settings'); } - function testItDoesntDisplayWhenDisabled() { + public function testItDoesntDisplayWhenDisabled() { $this->createSubscribers(50); $notice = new InactiveSubscribersNotice(SettingsController::getInstance(), new WPFunctions()); @@ -30,7 +30,7 @@ class InactiveSubscribersNoticeTest extends \MailPoetTest { expect($result)->null(); } - function testItDoesntDisplayWhenInactiveTimeRangeChanged() { + public function testItDoesntDisplayWhenInactiveTimeRangeChanged() { $this->createSubscribers(50); $settings_factory = new Settings(); @@ -41,7 +41,7 @@ class InactiveSubscribersNoticeTest extends \MailPoetTest { expect($result)->null(); } - function testItDoesntDisplayWhenNotEnoughInactiveSubscribers() { + public function testItDoesntDisplayWhenNotEnoughInactiveSubscribers() { $this->createSubscribers(49); $notice = new InactiveSubscribersNotice(SettingsController::getInstance(), new WPFunctions()); @@ -49,12 +49,12 @@ class InactiveSubscribersNoticeTest extends \MailPoetTest { expect($result)->null(); } - function _before() { + public function _before() { parent::_before(); $this->cleanup(); } - function _after() { + public function _after() { parent::_after(); $this->cleanup(); } diff --git a/tests/integration/Util/Notices/PHPVersionWarningsTest.php b/tests/integration/Util/Notices/PHPVersionWarningsTest.php index 9a2f9a36fc..12bc4b54c8 100644 --- a/tests/integration/Util/Notices/PHPVersionWarningsTest.php +++ b/tests/integration/Util/Notices/PHPVersionWarningsTest.php @@ -7,45 +7,45 @@ class PHPVersionWarningsTest extends \MailPoetTest { /** @var PHPVersionWarnings */ private $phpVersionWarning; - function _before() { + public function _before() { parent::_before(); $this->phpVersionWarning = new PHPVersionWarnings(); delete_transient('dismissed-php-version-outdated-notice'); } - function _after() { + public function _after() { delete_transient('dismissed-php-version-outdated-notice'); } - function testPHP55IsOutdated() { + public function testPHP55IsOutdated() { expect($this->phpVersionWarning->isOutdatedPHPVersion('5.5.3'))->true(); } - function testPHP56IsOutdated() { + public function testPHP56IsOutdated() { expect($this->phpVersionWarning->isOutdatedPHPVersion('5.6.3'))->true(); } - function testPHP72IsNotOutdated() { + public function testPHP72IsNotOutdated() { expect($this->phpVersionWarning->isOutdatedPHPVersion('7.2'))->false(); } - function testItPrintsWarningFor56() { + public function testItPrintsWarningFor56() { $warning = $this->phpVersionWarning->init('5.6.3', true); expect($warning->getMessage())->contains('Your website is running on PHP 5.6.3'); expect($warning->getMessage())->contains('https://www.mailpoet.com/let-us-handle-your-php-upgrade/'); } - function testItPrintsNoWarningFor70() { + public function testItPrintsNoWarningFor70() { $warning = $this->phpVersionWarning->init('7.0', true); expect($warning)->null(); } - function testItPrintsNoWarningWhenDisabled() { + public function testItPrintsNoWarningWhenDisabled() { $warning = $this->phpVersionWarning->init('5.5.3', false); expect($warning)->null(); } - function testItPrintsNoWarningWhenDismised() { + public function testItPrintsNoWarningWhenDismised() { $this->phpVersionWarning->init('5.5.3', true); $this->phpVersionWarning->disable(); $warning = $this->phpVersionWarning->init('5.5.3', true); diff --git a/tests/integration/WP/EmojiTest.php b/tests/integration/WP/EmojiTest.php index 367f2ddc50..5a36020073 100644 --- a/tests/integration/WP/EmojiTest.php +++ b/tests/integration/WP/EmojiTest.php @@ -8,7 +8,7 @@ use MailPoet\WP\Emoji; use MailPoetVendor\Idiorm\ORM; class EmojiTest extends \MailPoetTest { - function _before() { + public function _before() { parent::_before(); $this->data_encoded = "Emojis: 😃😵💪, not emojis: .Ž"; $this->data_decoded = "Emojis: 😃😵💪, not emojis: .Ž"; @@ -17,7 +17,7 @@ class EmojiTest extends \MailPoetTest { $this->emoji = new Emoji(); } - function testItCanEncodeNewsletterRenderedBody() { + public function testItCanEncodeNewsletterRenderedBody() { $emoji = $this->make( Emoji::class, ['encodeForUTF8Column' => Expected::exactly(3, function ($params) { @@ -29,7 +29,7 @@ class EmojiTest extends \MailPoetTest { $emoji->encodeEmojisInBody('string, call 3'); } - function testItCanDecodeNewsletterBody() { + public function testItCanDecodeNewsletterBody() { $emoji = $this->make( Emoji::class, ['decodeEntities' => Expected::exactly(3, function ($params) { @@ -41,7 +41,7 @@ class EmojiTest extends \MailPoetTest { $emoji->decodeEmojisInBody('string, call 3'); } - function testItCanEncodeForUTF8Column() { + public function testItCanEncodeForUTF8Column() { $table = Env::$db_prefix . 'dummytable_utf8'; $this->createTable($table, 'utf8'); @@ -51,7 +51,7 @@ class EmojiTest extends \MailPoetTest { $this->dropTable($table); } - function testItDoesNotEncodeForUTF8MB4Column() { + public function testItDoesNotEncodeForUTF8MB4Column() { $table = Env::$db_prefix . 'dummytable_utf8mb4'; $this->createTable($table, 'utf8mb4'); @@ -61,7 +61,7 @@ class EmojiTest extends \MailPoetTest { $this->dropTable($table); } - function testItCanDecodeEntities() { + public function testItCanDecodeEntities() { $result = $this->emoji->decodeEntities($this->data_encoded); expect($result)->equals($this->data_decoded); } diff --git a/tests/integration/WP/FunctionsTest.php b/tests/integration/WP/FunctionsTest.php index 6eb0acbd78..9a833db0d7 100644 --- a/tests/integration/WP/FunctionsTest.php +++ b/tests/integration/WP/FunctionsTest.php @@ -5,7 +5,7 @@ namespace MailPoet\Test\WP; use MailPoet\WP\Functions as WPFunctions; class FunctionsTest extends \MailPoetTest { - function _before() { + public function _before() { parent::_before(); global $content_width; $this->_content_width = $content_width; @@ -15,7 +15,7 @@ class FunctionsTest extends \MailPoetTest { $this->wp = new WPFunctions; } - function makeAttachment($upload, $parent_post_id = 0) { + public function makeAttachment($upload, $parent_post_id = 0) { $type = ''; if (!empty($upload['type'])) { $type = $upload['type']; @@ -42,7 +42,7 @@ class FunctionsTest extends \MailPoetTest { return $this->ids[] = $id; } - function testItCanProcessActions() { + public function testItCanProcessActions() { $test_value = ['abc', 'def']; $test_value2 = new \stdClass; $called = false; @@ -64,7 +64,7 @@ class FunctionsTest extends \MailPoetTest { expect($called)->false(); } - function testItCanProcessFilters() { + public function testItCanProcessFilters() { $test_value = ['abc', 'def']; $called = false; @@ -86,7 +86,7 @@ class FunctionsTest extends \MailPoetTest { expect($called)->false(); } - function _after() { + public function _after() { global $content_width; $content_width = $this->_content_width; } diff --git a/tests/integration/WooCommerce/SubscriptionTest.php b/tests/integration/WooCommerce/SubscriptionTest.php index 73cf0458b4..2400838c68 100644 --- a/tests/integration/WooCommerce/SubscriptionTest.php +++ b/tests/integration/WooCommerce/SubscriptionTest.php @@ -28,7 +28,7 @@ class SubscriptionTest extends \MailPoetTest { /** @var Subscriber */ private $subscriber; - function _before() { + public function _before() { $this->order_id = 123; // dummy $this->subscription = ContainerWrapper::getInstance()->get(Subscription::class); $this->settings = SettingsController::getInstance(); @@ -44,7 +44,7 @@ class SubscriptionTest extends \MailPoetTest { $this->original_settings = $this->settings->get('woocommerce'); } - function testItDisplaysACheckedCheckboxIfCurrentUserIsSubscribed() { + public function testItDisplaysACheckedCheckboxIfCurrentUserIsSubscribed() { WP::synchronizeUsers(); $wp_users = get_users(); wp_set_current_user($wp_users[0]->ID); @@ -56,7 +56,7 @@ class SubscriptionTest extends \MailPoetTest { expect($this->getRenderedOptinField())->contains('checked'); } - function testItDisplaysAnUncheckedCheckboxIfCurrentUserIsNotSubscribed() { + public function testItDisplaysAnUncheckedCheckboxIfCurrentUserIsNotSubscribed() { WP::synchronizeUsers(); $wp_users = get_users(); wp_set_current_user($wp_users[0]->ID); @@ -68,18 +68,18 @@ class SubscriptionTest extends \MailPoetTest { expect($this->getRenderedOptinField())->notContains('checked'); } - function testItDisplaysAnUncheckedCheckboxIfCurrentUserIsNotLoggedIn() { + public function testItDisplaysAnUncheckedCheckboxIfCurrentUserIsNotLoggedIn() { wp_set_current_user(0); expect($this->getRenderedOptinField())->notContains('checked'); } - function testItDisplaysCheckboxOptinMessageFromSettings() { + public function testItDisplaysCheckboxOptinMessageFromSettings() { $new_message = 'This is a test message.'; $this->settings->set(Subscription::OPTIN_MESSAGE_SETTING_NAME, $new_message); expect($this->getRenderedOptinField())->contains($new_message); } - function testItsTemplateCanBeOverriddenByAHook() { + public function testItsTemplateCanBeOverriddenByAHook() { $new_template = 'This is a new template'; add_filter( 'mailpoet_woocommerce_checkout_optin_template', @@ -94,13 +94,13 @@ class SubscriptionTest extends \MailPoetTest { expect($result)->contains(Subscription::CHECKOUT_OPTIN_INPUT_NAME); } - function testItDoesNotTryToSubscribeIfThereIsNoEmailInOrderData() { + public function testItDoesNotTryToSubscribeIfThereIsNoEmailInOrderData() { $data = []; $subscribed = $this->subscription->subscribeOnCheckout($this->order_id, $data); expect($subscribed)->equals(null); } - function testItDoesNotTryToSubscribeIfSubscriberWithTheEmailWasNotSynced() { + public function testItDoesNotTryToSubscribeIfSubscriberWithTheEmailWasNotSynced() { // non-existent $data['billing_email'] = 'non-existent-subscriber@example.com'; $subscribed = $this->subscription->subscribeOnCheckout($this->order_id, $data); @@ -113,7 +113,7 @@ class SubscriptionTest extends \MailPoetTest { expect($subscribed)->equals(null); } - function testItUnsubscribesIfCheckoutOptinIsDisabled() { + public function testItUnsubscribesIfCheckoutOptinIsDisabled() { SubscriberSegment::subscribeToSegments( $this->subscriber, [$this->wc_segment->id] @@ -130,7 +130,7 @@ class SubscriptionTest extends \MailPoetTest { expect($subscribed_segments)->count(0); } - function testItUnsubscribesIfCheckboxIsNotChecked() { + public function testItUnsubscribesIfCheckboxIsNotChecked() { SubscriberSegment::subscribeToSegments( $this->subscriber, [$this->wc_segment->id] @@ -150,7 +150,7 @@ class SubscriptionTest extends \MailPoetTest { expect($subscriber->status)->equals(Subscriber::STATUS_UNSUBSCRIBED); } - function testItSubscribesIfCheckboxIsChecked() { + public function testItSubscribesIfCheckboxIsChecked() { $this->subscriber->status = Subscriber::STATUS_UNSUBSCRIBED; $this->subscriber->save(); @@ -182,7 +182,7 @@ class SubscriptionTest extends \MailPoetTest { return $result; } - function _after() { + public function _after() { ORM::raw_execute('TRUNCATE ' . Subscriber::$_table); ORM::raw_execute('TRUNCATE ' . SubscriberSegment::$_table); // restore settings diff --git a/tests/integration/WooCommerce/TransactionalEmails/RendererTest.php b/tests/integration/WooCommerce/TransactionalEmails/RendererTest.php index 248faa14d3..5983d72342 100644 --- a/tests/integration/WooCommerce/TransactionalEmails/RendererTest.php +++ b/tests/integration/WooCommerce/TransactionalEmails/RendererTest.php @@ -13,7 +13,7 @@ class RendererTest extends \MailPoetTest { /** @var Newsletter */ private $newsletter; - function _before() { + public function _before() { parent::_before(); $this->newsletter = Stub::make(Newsletter::class, [ 'asArray' => function() { @@ -35,7 +35,7 @@ class RendererTest extends \MailPoetTest { ]); } - function testGetHTMLBeforeContent() { + public function testGetHTMLBeforeContent() { $renderer = new Renderer(new csstidy); $newsletter_renderer = new NewsletterRenderer($this->newsletter, true); $newsletter_renderer->preprocessor = new Preprocessor( @@ -58,7 +58,7 @@ class RendererTest extends \MailPoetTest { expect($html)->notContains('Some text after content'); } - function testGetHTMLAfterContent() { + public function testGetHTMLAfterContent() { $renderer = new Renderer(new csstidy); $newsletter_renderer = new NewsletterRenderer($this->newsletter, true); $newsletter_renderer->preprocessor = new Preprocessor( @@ -81,7 +81,7 @@ class RendererTest extends \MailPoetTest { expect($html)->contains('Some text after content'); } - function testPrefixCss() { + public function testPrefixCss() { $renderer = new Renderer(new csstidy); $css = $renderer->prefixCss(' #some_id {color: black} diff --git a/tests/integration/WooCommerce/TransactionalEmailsTest.php b/tests/integration/WooCommerce/TransactionalEmailsTest.php index bc60077235..a44f854cb0 100644 --- a/tests/integration/WooCommerce/TransactionalEmailsTest.php +++ b/tests/integration/WooCommerce/TransactionalEmailsTest.php @@ -31,7 +31,7 @@ class TransactionalEmailsTest extends \MailPoetTest { /** @var NewslettersRepository */ private $newsletters_repository; - function _before() { + public function _before() { $this->wp = new WPFunctions(); $this->settings = SettingsController::getInstance(); $this->original_wc_settings = $this->settings->get('woocommerce'); @@ -46,7 +46,7 @@ class TransactionalEmailsTest extends \MailPoetTest { ); } - function testInitCreatesTransactionalEmailAndSavesItsId() { + public function testInitCreatesTransactionalEmailAndSavesItsId() { $this->transactional_emails->init(); $email = $this->newsletters_repository->findOneBy(['type' => Newsletter::TYPE_WC_TRANSACTIONAL_EMAIL]); $id = $this->settings->get(TransactionalEmails::SETTING_EMAIL_ID, null); @@ -55,14 +55,14 @@ class TransactionalEmailsTest extends \MailPoetTest { expect($email->getId())->equals($id); } - function testInitDoesntCreateTransactionalEmailIfSettingAlreadySet() { + public function testInitDoesntCreateTransactionalEmailIfSettingAlreadySet() { $this->settings->set(TransactionalEmails::SETTING_EMAIL_ID, 1); $this->transactional_emails->init(); $email = $this->newsletters_repository->findOneBy(['type' => Newsletter::TYPE_WC_TRANSACTIONAL_EMAIL]); expect($email)->equals(null); } - function testInitUsesImageFromWCSettings() { + public function testInitUsesImageFromWCSettings() { $wp = Stub::make(new WPFunctions, ['getOption' => function($name) { if ($name == 'woocommerce_email_header_image') { return 'my-awesome-image-url'; @@ -84,7 +84,7 @@ class TransactionalEmailsTest extends \MailPoetTest { expect(json_encode($email->getBody()))->contains('my-awesome-image-url'); } - function testItSynchronizesEmailSettingsToWooCommerce() { + public function testItSynchronizesEmailSettingsToWooCommerce() { $newsletter = new NewsletterEntity; $newsletter->setType(Newsletter::TYPE_WC_TRANSACTIONAL_EMAIL); $newsletter->setSubject('WooCommerce Transactional Email'); @@ -170,7 +170,7 @@ class TransactionalEmailsTest extends \MailPoetTest { expect($wp->getOption('woocommerce_email_text_color'))->equals('#111111'); } - function testUseTemplateForWCEmails() { + public function testUseTemplateForWCEmails() { $added_actions = []; $removed_actions = []; $newsletter = new NewsletterEntity; @@ -240,7 +240,7 @@ class TransactionalEmailsTest extends \MailPoetTest { expect($added_actions['woocommerce_email_styles']('some css'))->equals('prefixed some css'); } - function _after() { + public function _after() { $this->entity_manager ->createQueryBuilder() ->delete() diff --git a/tests/integration/_bootstrap.php b/tests/integration/_bootstrap.php index 0f91f8b46d..fa4e54eb1f 100644 --- a/tests/integration/_bootstrap.php +++ b/tests/integration/_bootstrap.php @@ -158,7 +158,7 @@ abstract class MailPoetTest extends \Codeception\TestCase\Test { /** @var EntityManager */ protected $entity_manager; - function setUp() { + public function setUp() { $this->di_container = ContainerWrapper::getInstance(WP_DEBUG); $this->connection = $this->di_container->get(Connection::class); $this->entity_manager = $this->di_container->get(EntityManager::class); @@ -167,7 +167,7 @@ abstract class MailPoetTest extends \Codeception\TestCase\Test { parent::setUp(); } - function tearDown() { + public function tearDown() { $this->entity_manager->clear(); parent::tearDown(); } @@ -211,20 +211,20 @@ function asCallable($fn) { if (!class_exists(WC_Session::class)) { // phpcs:ignore class WC_Session { - function __unset($name) { + public function __unset($name) { } } } if (!function_exists('WC')) { class WC_Mailer { // phpcs:ignore - function email_header() { // phpcs:ignore + public function email_header() { // phpcs:ignore } - function email_footer() { // phpcs:ignore + public function email_footer() { // phpcs:ignore } } class WooCommerce { // phpcs:ignore - function mailer() { + public function mailer() { return new WC_Mailer; } } @@ -232,7 +232,7 @@ if (!function_exists('WC')) { return new WooCommerce; } class WC_Order_Item_Product { // phpcs:ignore - function get_product_id() { // phpcs:ignore + public function get_product_id() { // phpcs:ignore } } } diff --git a/tests/integration/_fixtures.php b/tests/integration/_fixtures.php index 030122102e..163ae6176f 100644 --- a/tests/integration/_fixtures.php +++ b/tests/integration/_fixtures.php @@ -173,7 +173,7 @@ Fixtures::add( class DynamicSegmentFilter { // phpcs:ignore PSR1.Classes.ClassDeclaration, Squiz.Classes.ClassFileName protected $ids; - function __construct($ids) { + public function __construct($ids) { $this->ids = $ids; } diff --git a/tests/unit/API/JSON/ErrorResponseTest.php b/tests/unit/API/JSON/ErrorResponseTest.php index 90f12e3db5..c29f5cdab5 100644 --- a/tests/unit/API/JSON/ErrorResponseTest.php +++ b/tests/unit/API/JSON/ErrorResponseTest.php @@ -7,7 +7,7 @@ use MailPoet\API\JSON\ErrorResponse; use MailPoet\WP\Functions as WPFunctions; class ErrorResponseTest extends \MailPoetUnitTest { - function testItSanitizesSqlErrorsWhenReturningResponse() { + public function testItSanitizesSqlErrorsWhenReturningResponse() { WPFunctions::set(Stub::make(new WPFunctions, [ '__' => function ($value) { return $value; @@ -39,7 +39,7 @@ class ErrorResponseTest extends \MailPoetUnitTest { ); } - function _after() { + public function _after() { WPFunctions::set(new WPFunctions); } } \ No newline at end of file diff --git a/tests/unit/Cron/CronTriggerTest.php b/tests/unit/Cron/CronTriggerTest.php index eefdb10cce..caee3cf2aa 100644 --- a/tests/unit/Cron/CronTriggerTest.php +++ b/tests/unit/Cron/CronTriggerTest.php @@ -9,7 +9,7 @@ use MailPoet\Cron\Triggers\WordPress; use MailPoet\Settings\SettingsController; class CronTriggerTest extends \MailPoetUnitTest { - function testItDefinesConstants() { + public function testItDefinesConstants() { expect(CronTrigger::METHOD_LINUX_CRON)->same('Linux Cron'); expect(CronTrigger::METHOD_MAILPOET)->same('MailPoet'); expect(CronTrigger::METHOD_WORDPRESS)->same('WordPress'); @@ -23,7 +23,7 @@ class CronTriggerTest extends \MailPoetUnitTest { expect(CronTrigger::SETTING_NAME)->equals('cron_trigger'); } - function testItCanInitializeCronTriggerMethod() { + public function testItCanInitializeCronTriggerMethod() { $settings_mock = Stub::makeEmpty(SettingsController::class, [ 'get' => CronTrigger::METHOD_WORDPRESS, ]); @@ -31,7 +31,7 @@ class CronTriggerTest extends \MailPoetUnitTest { expect($cron_trigger->init())->true(); } - function testItReturnsFalseWhenItCantInitializeCronTriggerMethod() { + public function testItReturnsFalseWhenItCantInitializeCronTriggerMethod() { $settings_mock = Stub::makeEmpty(SettingsController::class, [ 'get' => 'unknown-method', ]); @@ -39,7 +39,7 @@ class CronTriggerTest extends \MailPoetUnitTest { expect($cron_trigger->init())->false(); } - function testItIgnoresExceptionsThrownFromCronTriggerMethods() { + public function testItIgnoresExceptionsThrownFromCronTriggerMethods() { $settings_mock = Stub::makeEmpty(SettingsController::class, [ 'get' => CronTrigger::METHOD_MAILPOET, ]); diff --git a/tests/unit/Cron/Workers/StatsNotifications/SchedulerTest.php b/tests/unit/Cron/Workers/StatsNotifications/SchedulerTest.php index 8ed514cfed..2cf5bc4044 100644 --- a/tests/unit/Cron/Workers/StatsNotifications/SchedulerTest.php +++ b/tests/unit/Cron/Workers/StatsNotifications/SchedulerTest.php @@ -22,7 +22,7 @@ class SchedulerTest extends \MailPoetUnitTest { /** @var StatsNotificationsRepository|\PHPUnit_Framework_MockObject_MockObject */ private $repository; - function _before() { + public function _before() { parent::_before(); $this->settings = $this->createMock(SettingsController::class); $this->entityManager = $this->createMock(EntityManager::class); @@ -35,7 +35,7 @@ class SchedulerTest extends \MailPoetUnitTest { ); } - function testShouldSchedule() { + public function testShouldSchedule() { $this->settings ->method('get') ->will($this->returnValueMap([ @@ -75,7 +75,7 @@ class SchedulerTest extends \MailPoetUnitTest { $this->stats_notifications->schedule($newsletter); } - function testShouldScheduleForNotificationHistory() { + public function testShouldScheduleForNotificationHistory() { $this->settings ->method('get') ->will($this->returnValueMap([ @@ -115,7 +115,7 @@ class SchedulerTest extends \MailPoetUnitTest { $this->stats_notifications->schedule($newsletter); } - function testShouldNotScheduleIfTrackingIsDisabled() { + public function testShouldNotScheduleIfTrackingIsDisabled() { $this->settings ->method('get') ->will($this->returnValueMap([ @@ -135,7 +135,7 @@ class SchedulerTest extends \MailPoetUnitTest { $this->stats_notifications->schedule($newsletter); } - function testShouldNotScheduleIfDisabled() { + public function testShouldNotScheduleIfDisabled() { $this->settings ->method('get') ->will($this->returnValueMap([ @@ -155,7 +155,7 @@ class SchedulerTest extends \MailPoetUnitTest { $this->stats_notifications->schedule($newsletter); } - function testShouldNotScheduleIfSettingsMissing() { + public function testShouldNotScheduleIfSettingsMissing() { $this->settings ->method('get') ->will($this->returnValueMap([ @@ -176,7 +176,7 @@ class SchedulerTest extends \MailPoetUnitTest { $this->stats_notifications->schedule($newsletter); } - function testShouldNotScheduleIfEmailIsMissing() { + public function testShouldNotScheduleIfEmailIsMissing() { $this->settings ->method('get') ->will($this->returnValueMap([ @@ -196,7 +196,7 @@ class SchedulerTest extends \MailPoetUnitTest { $this->stats_notifications->schedule($newsletter); } - function testShouldNotScheduleIfEmailIsEmpty() { + public function testShouldNotScheduleIfEmailIsEmpty() { $this->settings ->method('get') ->will($this->returnValueMap([ @@ -215,7 +215,7 @@ class SchedulerTest extends \MailPoetUnitTest { $this->stats_notifications->schedule($newsletter); } - function testShouldNotScheduleIfAlreadyScheduled() { + public function testShouldNotScheduleIfAlreadyScheduled() { $this->settings ->method('get') ->will($this->returnValueMap([ @@ -240,7 +240,7 @@ class SchedulerTest extends \MailPoetUnitTest { $this->stats_notifications->schedule($newsletter); } - function testShouldNotScheduleIfInvalidType() { + public function testShouldNotScheduleIfInvalidType() { $this->settings ->method('get') ->will($this->returnValueMap([ diff --git a/tests/unit/CustomFields/ApiDataSanitizerTest.php b/tests/unit/CustomFields/ApiDataSanitizerTest.php index f0eb35bbc8..ef41c14d81 100644 --- a/tests/unit/CustomFields/ApiDataSanitizerTest.php +++ b/tests/unit/CustomFields/ApiDataSanitizerTest.php @@ -9,107 +9,107 @@ class ApiDataSanitizerTest extends \MailPoetUnitTest { /** @var ApiDataSanitizer */ private $sanitizer; - function _before() { + public function _before() { $this->sanitizer = new ApiDataSanitizer(); } - function testItThrowsIfNameIsMissing() { + public function testItThrowsIfNameIsMissing() { $this->expectException(InvalidArgumentException::class); $this->sanitizer->sanitize(['type' => 'text']); } - function testItThrowsIfNameIsEmpty() { + public function testItThrowsIfNameIsEmpty() { $this->expectException(InvalidArgumentException::class); $this->sanitizer->sanitize(['name' => '', 'type' => 'text']); } - function testItThrowsIfNameIsWrongType() { + public function testItThrowsIfNameIsWrongType() { $this->expectException(InvalidArgumentException::class); $this->sanitizer->sanitize(['name' => ['x'], 'type' => 'text']); } - function testItThrowsIfTypeIsMissing() { + public function testItThrowsIfTypeIsMissing() { $this->expectException(InvalidArgumentException::class); $this->sanitizer->sanitize(['name' => 'Name']); } - function testItThrowsIfTypeIsEmpty() { + public function testItThrowsIfTypeIsEmpty() { $this->expectException(InvalidArgumentException::class); $this->sanitizer->sanitize(['name' => 'Name', 'type' => '']); } - function testItThrowsIfTypeIsWrongType() { + public function testItThrowsIfTypeIsWrongType() { $this->expectException(InvalidArgumentException::class); $this->sanitizer->sanitize(['name' => 'Name', 'type' => ['y']]); } - function testItThrowsIfTypeIsInvalid() { + public function testItThrowsIfTypeIsInvalid() { $this->expectException(InvalidArgumentException::class); $this->sanitizer->sanitize(['name' => 'Name', 'type' => 'Invalid Type']); } - function testItThrowsIfParamsIsInvalidType() { + public function testItThrowsIfParamsIsInvalidType() { $this->expectException(InvalidArgumentException::class); $this->sanitizer->sanitize(['name' => 'Name', 'type' => 'text', 'params' => 'xyz']); } - function testItReturnsArray() { + public function testItReturnsArray() { $result = $this->sanitizer->sanitize(['name' => 'Name', 'type' => 'text']); expect($result)->internalType('array'); } - function testItReturnsName() { + public function testItReturnsName() { $result = $this->sanitizer->sanitize(['name' => 'Name', 'type' => 'text']); expect($result)->hasKey('name'); expect($result['name'])->same('Name'); } - function testItReturnsType() { + public function testItReturnsType() { $result = $this->sanitizer->sanitize(['name' => 'Name', 'type' => 'Text']); expect($result)->hasKey('type'); expect($result['type'])->same('text'); } - function testItIgnoresUnknownProperties() { + public function testItIgnoresUnknownProperties() { $result = $this->sanitizer->sanitize(['name' => 'Name', 'type' => 'text', 'unknown' => 'Unknown property']); expect($result)->hasntKey('unknown'); } - function testItReturnsParamsIfPassed() { + public function testItReturnsParamsIfPassed() { $result = $this->sanitizer->sanitize(['name' => 'Name', 'type' => 'text', 'params' => ['required' => '1']]); expect($result)->hasKey('params'); } - function testItReturnsCorrectRequiredForm() { + public function testItReturnsCorrectRequiredForm() { $result = $this->sanitizer->sanitize(['name' => 'Name', 'type' => 'text', 'params' => ['required' => true]]); expect($result['params']['required'])->same('1'); $result = $this->sanitizer->sanitize(['name' => 'Name', 'type' => 'text', 'params' => ['required' => false]]); expect($result['params']['required'])->same(''); } - function testItIgnoresUnknownParams() { + public function testItIgnoresUnknownParams() { $result = $this->sanitizer->sanitize(['name' => 'Name', 'type' => 'text', 'params' => ['unknown' => 'Unknown property']]); expect($result)->hasKey('params'); expect($result['params'])->hasntKey('unknown'); } - function testItFillsLabel() { + public function testItFillsLabel() { $result = $this->sanitizer->sanitize(['name' => 'Name', 'type' => 'text']); expect($result['params'])->hasKey('label'); expect($result['params']['label'])->same('Name'); } - function testItThrowsForInvalidValidate() { + public function testItThrowsForInvalidValidate() { $this->expectException(InvalidArgumentException::class); $this->sanitizer->sanitize(['name' => 'Name', 'type' => 'text', 'params' => ['validate' => 'unknown']]); } - function testItReturnsSanitizedValidate() { + public function testItReturnsSanitizedValidate() { $result = $this->sanitizer->sanitize(['name' => 'Name', 'type' => 'text', 'params' => ['validate' => 'alphanuM']]); expect($result['params']['validate'])->same('alphanum'); } - function testItThrowsIfNoValuesInRadio() { + public function testItThrowsIfNoValuesInRadio() { $this->expectException(InvalidArgumentException::class); $this->sanitizer->sanitize([ 'name' => 'Name', @@ -117,7 +117,7 @@ class ApiDataSanitizerTest extends \MailPoetUnitTest { ]); } - function testItReturnsSanitizedValuesForRadio() { + public function testItReturnsSanitizedValuesForRadio() { $result = $this->sanitizer->sanitize([ 'name' => 'Name', 'type' => 'radio', @@ -141,7 +141,7 @@ class ApiDataSanitizerTest extends \MailPoetUnitTest { expect($values[1])->same(['value' => 'value 2', 'is_checked' => '1']); } - function testItThrowsIfNoValuesInCheckbox() { + public function testItThrowsIfNoValuesInCheckbox() { $this->expectException(InvalidArgumentException::class); $this->sanitizer->sanitize([ 'name' => 'Name', @@ -149,7 +149,7 @@ class ApiDataSanitizerTest extends \MailPoetUnitTest { ]); } - function testItThrowsIfMoreValuesInCheckbox() { + public function testItThrowsIfMoreValuesInCheckbox() { $this->expectException(InvalidArgumentException::class); $this->sanitizer->sanitize([ 'name' => 'Name', @@ -167,7 +167,7 @@ class ApiDataSanitizerTest extends \MailPoetUnitTest { ]); } - function testItThrowsIfNameValueMissingInCheckbox() { + public function testItThrowsIfNameValueMissingInCheckbox() { $this->expectException(InvalidArgumentException::class); $this->sanitizer->sanitize([ 'name' => 'Name', @@ -182,7 +182,7 @@ class ApiDataSanitizerTest extends \MailPoetUnitTest { ]); } - function testItSanitizeCheckbox() { + public function testItSanitizeCheckbox() { $result = $this->sanitizer->sanitize([ 'name' => 'Name', 'type' => 'checkbox', @@ -201,7 +201,7 @@ class ApiDataSanitizerTest extends \MailPoetUnitTest { expect($values[0])->same(['value' => 'value 1', 'is_checked' => '1']); } - function testDateThrowsIfNoDateFormat() { + public function testDateThrowsIfNoDateFormat() { $this->expectException(InvalidArgumentException::class); $this->sanitizer->sanitize([ 'name' => 'Name', @@ -210,7 +210,7 @@ class ApiDataSanitizerTest extends \MailPoetUnitTest { ]); } - function testDateThrowsIfInvalidDateFormat() { + public function testDateThrowsIfInvalidDateFormat() { $this->expectException(InvalidArgumentException::class); $this->sanitizer->sanitize([ 'name' => 'Name', @@ -219,7 +219,7 @@ class ApiDataSanitizerTest extends \MailPoetUnitTest { ]); } - function testDateThrowsIfInvalidDateType() { + public function testDateThrowsIfInvalidDateType() { $this->expectException(InvalidArgumentException::class); $this->sanitizer->sanitize([ 'name' => 'Name', @@ -228,7 +228,7 @@ class ApiDataSanitizerTest extends \MailPoetUnitTest { ]); } - function testSanitizeDate() { + public function testSanitizeDate() { $result = $this->sanitizer->sanitize([ 'name' => 'Name', 'type' => 'date', diff --git a/tests/unit/DI/ContainerWrapperTest.php b/tests/unit/DI/ContainerWrapperTest.php index f18ae2fa95..d836294ae9 100644 --- a/tests/unit/DI/ContainerWrapperTest.php +++ b/tests/unit/DI/ContainerWrapperTest.php @@ -10,7 +10,7 @@ use MailPoetVendor\Symfony\Component\DependencyInjection\ContainerBuilder; use MailPoetVendor\Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException; class ContainerWrapperTest extends \MailPoetUnitTest { - function testItCanConstruct() { + public function testItCanConstruct() { $instance = new ContainerWrapper(new ContainerBuilder()); expect($instance)->isInstanceOf(ContainerWrapper::class); expect($instance)->isInstanceOf(ContainerInterface::class); @@ -20,7 +20,7 @@ class ContainerWrapperTest extends \MailPoetUnitTest { expect($instance)->isInstanceOf(ContainerInterface::class); } - function testItProvidesPremiumContainerIfAvailable() { + public function testItProvidesPremiumContainerIfAvailable() { $instance = new ContainerWrapper(new ContainerBuilder()); expect($instance->getPremiumContainer())->null(); @@ -28,7 +28,7 @@ class ContainerWrapperTest extends \MailPoetUnitTest { expect($instance->getPremiumContainer())->isInstanceOf(ContainerBuilder::class); } - function testItProvidesFreePluginServices() { + public function testItProvidesFreePluginServices() { $free_container_stub = Stub::make(Container::class, [ 'get' => function () { return 'service'; @@ -39,7 +39,7 @@ class ContainerWrapperTest extends \MailPoetUnitTest { expect($service)->equals('service'); } - function testItThrowsFreePluginServices() { + public function testItThrowsFreePluginServices() { $free_container_stub = Stub::make(Container::class, [ 'get' => function ($id) { throw new ServiceNotFoundException($id); @@ -55,7 +55,7 @@ class ContainerWrapperTest extends \MailPoetUnitTest { expect($exception)->isInstanceOf(ServiceNotFoundException::class); } - function testItReturnServiceFromPremium() { + public function testItReturnServiceFromPremium() { $free_container_stub = Stub::make(Container::class, [ 'get' => function ($id) { throw new ServiceNotFoundException($id); @@ -70,7 +70,7 @@ class ContainerWrapperTest extends \MailPoetUnitTest { expect($instance->get('service'))->equals('service_1'); } - function testItThrowsIfServiceNotFoundInBothContainers() { + public function testItThrowsIfServiceNotFoundInBothContainers() { $container_stub = Stub::make(Container::class, [ 'get' => function ($id) { throw new ServiceNotFoundException($id); diff --git a/tests/unit/DynamicSegments/RequirementsCheckerTest.php b/tests/unit/DynamicSegments/RequirementsCheckerTest.php index b575504b5c..4495ceac87 100644 --- a/tests/unit/DynamicSegments/RequirementsCheckerTest.php +++ b/tests/unit/DynamicSegments/RequirementsCheckerTest.php @@ -15,7 +15,7 @@ class RequirementsCheckerTest extends \MailPoetUnitTest { /** @var RequirementsChecker */ private $requirements_checker; - function _before() { + public function _before() { parent::_before(); if (!defined('MP_SEGMENTS_TABLE')) define('MP_SEGMENTS_TABLE', ''); $this->woocommerce_helper = $this @@ -25,21 +25,21 @@ class RequirementsCheckerTest extends \MailPoetUnitTest { $this->requirements_checker = new RequirementsChecker($this->woocommerce_helper); } - function testShouldntBlockSegmentIfWooCommerceIsActive() { + public function testShouldntBlockSegmentIfWooCommerceIsActive() { $this->woocommerce_helper->method('isWooCommerceActive')->willReturn(true); $segment = DynamicSegment::create(); $segment->setFilters([new WooCommerceCategory(1)]); expect($this->requirements_checker->shouldSkipSegment($segment))->false(); } - function testShouldBlockWooCommerceSegmentIfWooCommerceIsInactive() { + public function testShouldBlockWooCommerceSegmentIfWooCommerceIsInactive() { $this->woocommerce_helper->method('isWooCommerceActive')->willReturn(false); $segment = DynamicSegment::create(); $segment->setFilters([new WooCommerceCategory(1)]); expect($this->requirements_checker->shouldSkipSegment($segment))->true(); } - function testShouldntBlockNonWooCommerceSegmentIfWooCommerceIsInactive() { + public function testShouldntBlockNonWooCommerceSegmentIfWooCommerceIsInactive() { $this->woocommerce_helper->method('isWooCommerceActive')->willReturn(false); $segment = DynamicSegment::create(); $segment->setFilters([new EmailAction(EmailAction::ACTION_OPENED, 2)]); diff --git a/tests/unit/Features/FeaturesControllerTest.php b/tests/unit/Features/FeaturesControllerTest.php index a83a0f3500..3264142949 100644 --- a/tests/unit/Features/FeaturesControllerTest.php +++ b/tests/unit/Features/FeaturesControllerTest.php @@ -8,7 +8,7 @@ use MailPoet\Features\FeaturesController; class FeaturesControllerTest extends \MailPoetUnitTest { - function testItWorksWithDefaults() { + public function testItWorksWithDefaults() { $repository = $this->makeEmpty( FeatureFlagsRepository::class, [ @@ -34,7 +34,7 @@ class FeaturesControllerTest extends \MailPoetUnitTest { ]); } - function testItWorksWithDatabaseValues() { + public function testItWorksWithDatabaseValues() { $repository = $this->makeEmpty( FeatureFlagsRepository::class, [ @@ -54,7 +54,7 @@ class FeaturesControllerTest extends \MailPoetUnitTest { ]); } - function testItDoesNotReturnUnknownFlag() { + public function testItDoesNotReturnUnknownFlag() { $repository = $this->makeEmpty( FeatureFlagsRepository::class, [ diff --git a/tests/unit/Form/Block/DateTest.php b/tests/unit/Form/Block/DateTest.php index 7c5b7aa637..b926c50733 100644 --- a/tests/unit/Form/Block/DateTest.php +++ b/tests/unit/Form/Block/DateTest.php @@ -5,7 +5,7 @@ namespace MailPoet\Test\Form\Block; use MailPoet\Form\Block\Date; class DateTest extends \MailPoetUnitTest { - function testItCanConvertDateMonthYearFormatToDatetime() { + public function testItCanConvertDateMonthYearFormatToDatetime() { $date = [ 'MM/DD/YYYY' => '05/10/2016', 'DD/MM/YYYY' => '10/05/2016', @@ -18,7 +18,7 @@ class DateTest extends \MailPoetUnitTest { } } - function testItCanConvertMonthYearFormatToDatetime() { + public function testItCanConvertMonthYearFormatToDatetime() { $date = [ 'MM/YYYY' => '05/2016', 'YYYY/MM' => '2016/05', @@ -29,23 +29,23 @@ class DateTest extends \MailPoetUnitTest { } } - function testItCanConvertMonthToDatetime() { + public function testItCanConvertMonthToDatetime() { $current_year = date('Y'); expect(Date::convertDateToDatetime('05', 'MM')) ->equals(sprintf('%s-05-01 00:00:00', $current_year)); } - function testItCanConvertYearToDatetime() { + public function testItCanConvertYearToDatetime() { expect(Date::convertDateToDatetime('2016', 'YYYY')) ->equals('2016-01-01 00:00:00'); } - function testItCanConvertDatetimeToDatetime() { + public function testItCanConvertDatetimeToDatetime() { expect(Date::convertDateToDatetime('2016-05-10 00:00:00', 'datetime')) ->equals('2016-05-10 00:00:00'); } - function testItCanClearDate() { + public function testItCanClearDate() { expect(Date::convertDateToDatetime('0/10/5', 'YYYY/MM/DD')) ->equals(date('Y') . '-10-05 00:00:00'); expect(Date::convertDateToDatetime('0/0/5', 'YYYY/MM/DD')) diff --git a/tests/unit/Form/Util/FieldNameObfuscatorTest.php b/tests/unit/Form/Util/FieldNameObfuscatorTest.php index edf4748070..4f79d500b7 100644 --- a/tests/unit/Form/Util/FieldNameObfuscatorTest.php +++ b/tests/unit/Form/Util/FieldNameObfuscatorTest.php @@ -6,7 +6,7 @@ use Codeception\Stub; use MailPoet\WP\Functions as WPFunctions; class FieldNameObfuscatorTest extends \MailPoetUnitTest { - function _before() { + public function _before() { parent::_before(); WPFunctions::set( Stub::make(WPFunctions::class, [ @@ -40,7 +40,7 @@ class FieldNameObfuscatorTest extends \MailPoetUnitTest { ]); } - function _after() { + public function _after() { parent::_after(); WPFunctions::set(new WPFunctions()); } diff --git a/tests/unit/Form/Util/StylesTest.php b/tests/unit/Form/Util/StylesTest.php index 936adcd481..ad823a8740 100644 --- a/tests/unit/Form/Util/StylesTest.php +++ b/tests/unit/Form/Util/StylesTest.php @@ -10,7 +10,7 @@ class StylesTest extends \MailPoetUnitTest { /** @var FeaturesController&\PHPUnit_Framework_MockObject_MockObject */ private $features_controller; - function _before() { + public function _before() { parent::_before(); $this->features_controller = $this->createMock(FeaturesController::class); $this->features_controller @@ -19,12 +19,12 @@ class StylesTest extends \MailPoetUnitTest { ->willReturn(false); } - function testItSetsDefaultCSSStyles() { + public function testItSetsDefaultCSSStyles() { $styles = new Styles($this->features_controller); expect($styles->getDefaultStyles())->notEmpty(); } - function testItProcessesAndRendersStyles() { + public function testItProcessesAndRendersStyles() { $stylesheet = ' /* some comment */ input[name=first_name] , input.some_class, .some_class { color: red ; background: blue; } .another_style { fonT-siZe: 20px } diff --git a/tests/unit/Logging/LoggerFactoryTest.php b/tests/unit/Logging/LoggerFactoryTest.php index b2a92d4ad6..814cc5df5f 100644 --- a/tests/unit/Logging/LoggerFactoryTest.php +++ b/tests/unit/Logging/LoggerFactoryTest.php @@ -14,7 +14,7 @@ class LoggerFactoryTest extends \MailPoetUnitTest { /** @var LoggerFactory */ private $logger_factory; - function _before() { + public function _before() { parent::_before(); $this->settings = $this->createMock(SettingsController::class); $this->logger_factory = new LoggerFactory($this->settings); diff --git a/tests/unit/Mailer/MailerErrorTest.php b/tests/unit/Mailer/MailerErrorTest.php index 794a0a138d..896d0d83f1 100644 --- a/tests/unit/Mailer/MailerErrorTest.php +++ b/tests/unit/Mailer/MailerErrorTest.php @@ -9,7 +9,7 @@ use MailPoet\WP\Functions as WPFunctions; class MailerErrorTest extends \MailPoetUnitTest { - function _before() { + public function _before() { WPFunctions::set(Stub::make(new WPFunctions, [ '__' => function ($value) { return $value; @@ -17,12 +17,12 @@ class MailerErrorTest extends \MailPoetUnitTest { ])); } - function testItCanComposeErrorMessageWithoutSubscribers() { + public function testItCanComposeErrorMessageWithoutSubscribers() { $error = new MailerError(MailerError::OPERATION_SEND, MailerError::LEVEL_HARD, 'Some Message'); expect($error->getMessageWithFailedSubscribers())->equals('Some Message'); } - function testItCanComposeErrorMessageWithOneSubscriber() { + public function testItCanComposeErrorMessageWithOneSubscriber() { $subscriber_error = new SubscriberError('email@example.com', 'Subscriber message'); $error = new MailerError( MailerError::OPERATION_SEND, @@ -34,7 +34,7 @@ class MailerErrorTest extends \MailPoetUnitTest { expect($error->getMessageWithFailedSubscribers())->equals('Some Message Unprocessed subscriber: (email@example.com: Subscriber message)'); } - function testItCanComposeErrorMessageWithMultipleSubscriberErrors() { + public function testItCanComposeErrorMessageWithMultipleSubscriberErrors() { $subscriber_error_1 = new SubscriberError('email1@example.com', 'Subscriber 1 message'); $subscriber_error_2 = new SubscriberError('email2@example.com', null); $error = new MailerError( @@ -49,7 +49,7 @@ class MailerErrorTest extends \MailPoetUnitTest { ); } - function _after() { + public function _after() { WPFunctions::set(new WPFunctions); } } diff --git a/tests/unit/Mailer/Methods/ErrorMappers/AmazonSESMapperTest.php b/tests/unit/Mailer/Methods/ErrorMappers/AmazonSESMapperTest.php index 57ff596b39..fbab88664a 100644 --- a/tests/unit/Mailer/Methods/ErrorMappers/AmazonSESMapperTest.php +++ b/tests/unit/Mailer/Methods/ErrorMappers/AmazonSESMapperTest.php @@ -14,7 +14,7 @@ class AmazonSESMapperTest extends \MailPoetUnitTest { /** @var array */ private $response_data = []; - function _before() { + public function _before() { parent::_before(); $this->mapper = new AmazonSESMapper(); $this->response_data = [ @@ -27,7 +27,7 @@ class AmazonSESMapperTest extends \MailPoetUnitTest { ]; } - function testGetProperError() { + public function testGetProperError() { $response = $this->buildXmlResponseFromArray($this->response_data, new SimpleXMLElement('')); $error = $this->mapper->getErrorFromResponse($response, 'john@rambo.com'); expect($error->getLevel())->equals(MailerError::LEVEL_HARD); @@ -35,7 +35,7 @@ class AmazonSESMapperTest extends \MailPoetUnitTest { expect($error->getSubscriberErrors()[0]->getEmail())->equals('john@rambo.com'); } - function testGetSoftErrorForRejectedMessage() { + public function testGetSoftErrorForRejectedMessage() { $this->response_data['Error']['Code'] = 'MessageRejected'; $response = $this->buildXmlResponseFromArray($this->response_data, new SimpleXMLElement('')); $error = $this->mapper->getErrorFromResponse($response, 'john@rambo.com'); diff --git a/tests/unit/Mailer/Methods/ErrorMappers/MailPoetMapperTest.php b/tests/unit/Mailer/Methods/ErrorMappers/MailPoetMapperTest.php index 16e88262e0..58f526aada 100644 --- a/tests/unit/Mailer/Methods/ErrorMappers/MailPoetMapperTest.php +++ b/tests/unit/Mailer/Methods/ErrorMappers/MailPoetMapperTest.php @@ -13,13 +13,13 @@ class MailPoetMapperTest extends \MailPoetUnitTest { /** @var array */ private $subscribers; - function _before() { + public function _before() { parent::_before(); $this->mapper = new MailPoetMapper(); $this->subscribers = ['a@example.com', 'c d ']; } - function testCreateBlacklistError() { + public function testCreateBlacklistError() { $error = $this->mapper->getBlacklistError($this->subscribers[1]); expect($error)->isInstanceOf(MailerError::class); expect($error->getOperation())->equals(MailerError::OPERATION_SEND); @@ -28,7 +28,7 @@ class MailPoetMapperTest extends \MailPoetUnitTest { expect($error->getMessage())->contains('MailPoet'); } - function testCreateConnectionError() { + public function testCreateConnectionError() { $error = $this->mapper->getConnectionError('connection error'); expect($error)->isInstanceOf(MailerError::class); expect($error->getOperation())->equals(MailerError::OPERATION_CONNECT); @@ -36,7 +36,7 @@ class MailPoetMapperTest extends \MailPoetUnitTest { expect($error->getMessage())->equals('connection error'); } - function testGetErrorNotArray() { + public function testGetErrorNotArray() { $api_result = [ 'code' => API::RESPONSE_CODE_NOT_ARRAY, 'status' => API::SENDING_STATUS_SEND_ERROR, @@ -50,7 +50,7 @@ class MailPoetMapperTest extends \MailPoetUnitTest { expect($error->getMessage())->equals('JSON input is not an array'); } - function testGetErrorBannedAccount() { + public function testGetErrorBannedAccount() { $api_result = [ 'code' => API::RESPONSE_CODE_CAN_NOT_SEND, 'status' => API::SENDING_STATUS_SEND_ERROR, @@ -64,7 +64,7 @@ class MailPoetMapperTest extends \MailPoetUnitTest { expect($error->getMessage())->contains('The MailPoet Sending Service has stopped sending your emails for one of the following reasons'); } - function testGetErrorUnauthorizedEmail() { + public function testGetErrorUnauthorizedEmail() { $api_result = [ 'code' => API::RESPONSE_CODE_CAN_NOT_SEND, 'status' => API::SENDING_STATUS_SEND_ERROR, @@ -78,7 +78,7 @@ class MailPoetMapperTest extends \MailPoetUnitTest { expect($error->getMessage())->contains('The MailPoet Sending Service did not send your latest email because the address'); } - function testGetErrorPayloadTooBig() { + public function testGetErrorPayloadTooBig() { $api_result = [ 'code' => API::RESPONSE_CODE_PAYLOAD_TOO_BIG, 'status' => API::SENDING_STATUS_SEND_ERROR, @@ -91,7 +91,7 @@ class MailPoetMapperTest extends \MailPoetUnitTest { expect($error->getMessage())->equals('error too big'); } - function testGetPayloadError() { + public function testGetPayloadError() { $api_result = [ 'code' => API::RESPONSE_CODE_PAYLOAD_ERROR, 'status' => API::SENDING_STATUS_SEND_ERROR, @@ -104,7 +104,7 @@ class MailPoetMapperTest extends \MailPoetUnitTest { expect($error->getMessage())->equals('Error while sending. Api Error'); } - function testGetPayloadErrorWithErrorMessage() { + public function testGetPayloadErrorWithErrorMessage() { $api_result = [ 'code' => API::RESPONSE_CODE_PAYLOAD_ERROR, 'status' => API::SENDING_STATUS_SEND_ERROR, @@ -122,7 +122,7 @@ class MailPoetMapperTest extends \MailPoetUnitTest { expect($subscriber_errors[1]->getMessage())->equals('subject is missing'); } - function testGetPayloadErrorForMalformedMSSResponse() { + public function testGetPayloadErrorForMalformedMSSResponse() { $api_result = [ 'code' => API::RESPONSE_CODE_PAYLOAD_ERROR, 'status' => API::SENDING_STATUS_SEND_ERROR, diff --git a/tests/unit/Mailer/Methods/ErrorMappers/PHPMailMapperTest.php b/tests/unit/Mailer/Methods/ErrorMappers/PHPMailMapperTest.php index 09f4b2148f..8b543cb558 100644 --- a/tests/unit/Mailer/Methods/ErrorMappers/PHPMailMapperTest.php +++ b/tests/unit/Mailer/Methods/ErrorMappers/PHPMailMapperTest.php @@ -12,7 +12,7 @@ class PHPMailMapperTest extends \MailPoetUnitTest { /** @var PHPMailMapper*/ private $mapper; - function _before() { + public function _before() { parent::_before(); $this->mapper = new PHPMailMapper(); WPFunctions::set(Stub::make(new WPFunctions, [ @@ -22,26 +22,26 @@ class PHPMailMapperTest extends \MailPoetUnitTest { ])); } - function testGetProperErrorForSubscriber() { + public function testGetProperErrorForSubscriber() { $error = $this->mapper->getErrorForSubscriber('john@rambo.com'); expect($error->getLevel())->equals(MailerError::LEVEL_HARD); expect($error->getMessage())->equals('PHPMail has returned an unknown error.'); expect($error->getSubscriberErrors()[0]->getEmail())->equals('john@rambo.com'); } - function testGetProperErrorFromException() { + public function testGetProperErrorFromException() { $error = $this->mapper->getErrorFromException(new \Exception('Some message'), 'john@rambo.com'); expect($error->getLevel())->equals(MailerError::LEVEL_HARD); expect($error->getMessage())->equals('Some message'); expect($error->getSubscriberErrors()[0]->getEmail())->equals('john@rambo.com'); } - function testGetSoftErrorFromExceptionForInvalidEmail() { + public function testGetSoftErrorFromExceptionForInvalidEmail() { $error = $this->mapper->getErrorFromException(new \Exception('Invalid address. (Add ...'), 'john@rambo.com'); expect($error->getLevel())->equals(MailerError::LEVEL_SOFT); } - function _after() { + public function _after() { WPFunctions::set(new WPFunctions); } } diff --git a/tests/unit/Mailer/Methods/ErrorMappers/SMTPMapperTest.php b/tests/unit/Mailer/Methods/ErrorMappers/SMTPMapperTest.php index 89a78ea81f..17a40de603 100644 --- a/tests/unit/Mailer/Methods/ErrorMappers/SMTPMapperTest.php +++ b/tests/unit/Mailer/Methods/ErrorMappers/SMTPMapperTest.php @@ -14,7 +14,7 @@ class SMTPMapperTest extends \MailPoetUnitTest { /** @var SMTPMapper */ private $mapper; - function _before() { + public function _before() { parent::_before(); $this->mapper = new SMTPMapper(); WPFunctions::set(Stub::make(new WPFunctions, [ @@ -24,7 +24,7 @@ class SMTPMapperTest extends \MailPoetUnitTest { ])); } - function testItCanProcessExceptionMessage() { + public function testItCanProcessExceptionMessage() { $message = 'Connection could not be established with host localhost [Connection refused #111]' . PHP_EOL . 'Log data:' . PHP_EOL . '++ Starting Swift_SmtpTransport' . PHP_EOL @@ -36,13 +36,13 @@ class SMTPMapperTest extends \MailPoetUnitTest { expect($error->getSubscriberErrors()[0]->getEmail())->equals('john@rambo.com'); } - function testItCreatesSoftErrorForInvalidEmail() { + public function testItCreatesSoftErrorForInvalidEmail() { $message = 'Invalid email'; $error = $this->mapper->getErrorFromException(new Swift_RfcComplianceException($message), 'john@rambo.com'); expect($error->getLevel())->equals(MailerError::LEVEL_SOFT); } - function testItCanProcessLogMessageWhenOneExists() { + public function testItCanProcessLogMessageWhenOneExists() { $log = '++ Swift_SmtpTransport started' . PHP_EOL . '>> MAIL FROM:' . PHP_EOL . '<< 250 OK' . PHP_EOL @@ -58,14 +58,14 @@ class SMTPMapperTest extends \MailPoetUnitTest { expect($error->getSubscriberErrors()[0]->getEmail('moi@mrcasual.com')); } - function testItReturnsGenericMessageWhenLogMessageDoesNotExist() { + public function testItReturnsGenericMessageWhenLogMessageDoesNotExist() { $error = $this->mapper->getErrorFromLog(null, 'test@example.com'); expect($error->getMessage()) ->equals(Mailer::METHOD_SMTP . ' has returned an unknown error.'); expect($error->getSubscriberErrors()[0]->getEmail('moi@mrcasual.com')); } - function _after() { + public function _after() { WPFunctions::set(new WPFunctions); } } diff --git a/tests/unit/Mailer/Methods/ErrorMappers/SendGridMapperTest.php b/tests/unit/Mailer/Methods/ErrorMappers/SendGridMapperTest.php index 39fec83ce1..40e8ee130d 100644 --- a/tests/unit/Mailer/Methods/ErrorMappers/SendGridMapperTest.php +++ b/tests/unit/Mailer/Methods/ErrorMappers/SendGridMapperTest.php @@ -13,7 +13,7 @@ class SendGridMapperTest extends \MailPoetUnitTest { /** @var array */ private $response = []; - function _before() { + public function _before() { parent::_before(); $this->mapper = new SendGridMapper(); $this->response = [ @@ -23,14 +23,14 @@ class SendGridMapperTest extends \MailPoetUnitTest { ]; } - function testGetProperError() { + public function testGetProperError() { $error = $this->mapper->getErrorFromResponse($this->response, 'john@rambo.com'); expect($error->getLevel())->equals(MailerError::LEVEL_HARD); expect($error->getMessage())->equals('Some message'); expect($error->getSubscriberErrors()[0]->getEmail())->equals('john@rambo.com'); } - function testGetSoftErrorForInvalidEmail() { + public function testGetSoftErrorForInvalidEmail() { $this->response['errors'][0] = 'Invalid email address ,,@'; $error = $this->mapper->getErrorFromResponse($this->response, ',,@'); expect($error->getLevel())->equals(MailerError::LEVEL_SOFT); diff --git a/tests/unit/Newsletter/Editor/StructureTransformerTest.php b/tests/unit/Newsletter/Editor/StructureTransformerTest.php index fb6864b8f2..a078ad398c 100644 --- a/tests/unit/Newsletter/Editor/StructureTransformerTest.php +++ b/tests/unit/Newsletter/Editor/StructureTransformerTest.php @@ -8,12 +8,12 @@ class StructureTransformerTest extends \MailPoetUnitTest { /** @var StructureTransformer */ private $transformer; - function _before() { + public function _before() { parent::_before(); $this->transformer = new StructureTransformer(); } - function testItExtractsImagesAsImageBlocks() { + public function testItExtractsImagesAsImageBlocks() { $html = '

italicprevious textnext textbolded

'; $blocks = $this->transformer->transform($html, false); diff --git a/tests/unit/Newsletter/Renderer/Blocks/ButtonTest.php b/tests/unit/Newsletter/Renderer/Blocks/ButtonTest.php index d5cb9b52cd..0f662f439b 100644 --- a/tests/unit/Newsletter/Renderer/Blocks/ButtonTest.php +++ b/tests/unit/Newsletter/Renderer/Blocks/ButtonTest.php @@ -26,7 +26,7 @@ class ButtonTest extends \MailPoetUnitTest { ], ]; - function testItRendersCorrectly() { + public function testItRendersCorrectly() { $output = Button::render($this->block, 200); $expected_result = ' diff --git a/tests/unit/Newsletter/Renderer/Blocks/DividerTest.php b/tests/unit/Newsletter/Renderer/Blocks/DividerTest.php index c11f4a3ef5..9e18e1c615 100644 --- a/tests/unit/Newsletter/Renderer/Blocks/DividerTest.php +++ b/tests/unit/Newsletter/Renderer/Blocks/DividerTest.php @@ -17,7 +17,7 @@ class DividerTest extends \MailPoetUnitTest { ], ]; - function testItRendersCorrectly() { + public function testItRendersCorrectly() { $output = Divider::render($this->block); $expected_result = ' diff --git a/tests/unit/Newsletter/Renderer/Blocks/FooterTest.php b/tests/unit/Newsletter/Renderer/Blocks/FooterTest.php index 9734275b4c..158a6c4e3a 100644 --- a/tests/unit/Newsletter/Renderer/Blocks/FooterTest.php +++ b/tests/unit/Newsletter/Renderer/Blocks/FooterTest.php @@ -24,7 +24,7 @@ class FooterTest extends \MailPoetUnitTest { ], ]; - function testItRendersCorrectly() { + public function testItRendersCorrectly() { $output = Footer::render($this->block); $expected_result = ' @@ -35,7 +35,7 @@ class FooterTest extends \MailPoetUnitTest { expect($output)->equals($expected_result); } - function testItRendersWithBackgroundColor() { + public function testItRendersWithBackgroundColor() { $this->block['styles']['block']['backgroundColor'] = '#f0f0f0'; $output = Footer::render($this->block); $expected_result = ' @@ -47,7 +47,7 @@ class FooterTest extends \MailPoetUnitTest { expect($output)->equals($expected_result); } - function testItPrefersInlinedCssForLinks() { + public function testItPrefersInlinedCssForLinks() { $this->block['text'] = '

Footer text. link

'; $output = Footer::render($this->block); expect($output)->contains('link'); diff --git a/tests/unit/Newsletter/Renderer/Blocks/HeaderTest.php b/tests/unit/Newsletter/Renderer/Blocks/HeaderTest.php index c13db8de7a..273e61811e 100644 --- a/tests/unit/Newsletter/Renderer/Blocks/HeaderTest.php +++ b/tests/unit/Newsletter/Renderer/Blocks/HeaderTest.php @@ -24,7 +24,7 @@ class HeaderTest extends \MailPoetUnitTest { ], ]; - function testItRendersCorrectly() { + public function testItRendersCorrectly() { $output = Header::render($this->block); $expected_result = ' @@ -35,7 +35,7 @@ class HeaderTest extends \MailPoetUnitTest { expect($output)->equals($expected_result); } - function testItRendersBackgroundColorCorrectly() { + public function testItRendersBackgroundColorCorrectly() { $this->block['styles']['block']['backgroundColor'] = '#f0f0f0'; $output = Header::render($this->block); $expected_result = ' @@ -47,7 +47,7 @@ class HeaderTest extends \MailPoetUnitTest { expect($output)->equals($expected_result); } - function testItPrefersInlinedCssForLinks() { + public function testItPrefersInlinedCssForLinks() { $this->block['text'] = '

Header text. link

'; $output = Footer::render($this->block); expect($output)->contains('link'); diff --git a/tests/unit/Newsletter/Renderer/Blocks/ImageTest.php b/tests/unit/Newsletter/Renderer/Blocks/ImageTest.php index 7d5de08f5b..43318042d7 100644 --- a/tests/unit/Newsletter/Renderer/Blocks/ImageTest.php +++ b/tests/unit/Newsletter/Renderer/Blocks/ImageTest.php @@ -19,7 +19,7 @@ class ImageTest extends \MailPoetUnitTest { ], ]; - function testItRendersCorrectly() { + public function testItRendersCorrectly() { $output = Image::render($this->block, 200); $expected_result = ' @@ -30,7 +30,7 @@ class ImageTest extends \MailPoetUnitTest { expect($output)->equals($expected_result); } - function testItRendersWithoutLink() { + public function testItRendersWithoutLink() { $this->block['link'] = null; $output = Image::render($this->block, 200); $expected_result = ' diff --git a/tests/unit/Newsletter/Renderer/Blocks/SocialTest.php b/tests/unit/Newsletter/Renderer/Blocks/SocialTest.php index bf3f4b80d6..bd738aef54 100644 --- a/tests/unit/Newsletter/Renderer/Blocks/SocialTest.php +++ b/tests/unit/Newsletter/Renderer/Blocks/SocialTest.php @@ -34,23 +34,23 @@ class SocialTest extends \MailPoetUnitTest { ], ]; - function testItRendersCorrectly() { + public function testItRendersCorrectly() { $output = Social::render($this->block); $expected_result = ' facebook twitter  diff --git a/tests/unit/Newsletter/Renderer/Blocks/SpacerTest.php b/tests/unit/Newsletter/Renderer/Blocks/SpacerTest.php index b8d1c539fd..9085a0028f 100644 --- a/tests/unit/Newsletter/Renderer/Blocks/SpacerTest.php +++ b/tests/unit/Newsletter/Renderer/Blocks/SpacerTest.php @@ -14,7 +14,7 @@ class SpacerTest extends \MailPoetUnitTest { ], ]; - function testItRendersCorrectly() { + public function testItRendersCorrectly() { $output = Spacer::render($this->block); $expected_result = ' @@ -23,7 +23,7 @@ class SpacerTest extends \MailPoetUnitTest { expect($output)->equals($expected_result); } - function testsItRendersWithBackground() { + public function testsItRendersWithBackground() { $this->block['styles']['block']['backgroundColor'] = "#ffffff"; $output = Spacer::render($this->block); $expected_result = ' diff --git a/tests/unit/Newsletter/Renderer/Blocks/TextTest.php b/tests/unit/Newsletter/Renderer/Blocks/TextTest.php index 11a408d98a..9619c797d2 100644 --- a/tests/unit/Newsletter/Renderer/Blocks/TextTest.php +++ b/tests/unit/Newsletter/Renderer/Blocks/TextTest.php @@ -14,12 +14,12 @@ class TextTest extends \MailPoetUnitTest { /** @var pQuery */ private $parser; - function _before() { + public function _before() { parent::_before(); $this->parser = new pQuery; } - function testItRendersPlainText() { + public function testItRendersPlainText() { $output = Text::render($this->block); $expected_result = ' @@ -30,7 +30,7 @@ class TextTest extends \MailPoetUnitTest { expect($output)->equals($expected_result); } - function testItRendersParagraph() { + public function testItRendersParagraph() { $this->block['text'] = '

Text

'; $output = Text::render($this->block); $table = $this->parser->parseStr($output)->query('table'); @@ -45,7 +45,7 @@ class TextTest extends \MailPoetUnitTest { expect($paragraph_table)->equals($expected_result); } - function testItRendersList() { + public function testItRendersList() { $this->block['text'] = '
  • Item 1
  • Item 2
'; $output = Text::render($this->block); $ul = $this->parser->parseStr($output)->query('ul'); @@ -55,7 +55,7 @@ class TextTest extends \MailPoetUnitTest { expect($list)->equals($expected_result); } - function testItRendersBlockquotes() { + public function testItRendersBlockquotes() { $this->block['text'] = '

Quote

'; $output = Text::render($this->block); $table = $this->parser->parseStr($output)->query('table'); @@ -80,14 +80,14 @@ class TextTest extends \MailPoetUnitTest { expect($blockquote_table)->equals($expected_result); } - function testItStylesHeadings() { + public function testItStylesHeadings() { $this->block['text'] = '

Heading

Heading 2

'; $output = Text::render($this->block); expect($output)->contains('

Heading

'); expect($output)->contains('

Heading 2

'); } - function testItRemovesLastLineBreak() { + public function testItRemovesLastLineBreak() { $this->block['text'] = 'hello
'; $output = Text::render($this->block); expect($output)->notContains('
'); diff --git a/tests/unit/Newsletter/Renderer/EscapeHelperTest.php b/tests/unit/Newsletter/Renderer/EscapeHelperTest.php index 4c5db73823..02e6afac12 100644 --- a/tests/unit/Newsletter/Renderer/EscapeHelperTest.php +++ b/tests/unit/Newsletter/Renderer/EscapeHelperTest.php @@ -6,17 +6,17 @@ use MailPoet\Newsletter\Renderer\EscapeHelper as EHelper; class EscapeHelperTest extends \MailPoetUnitTest { - function testItEscapesHtmlText() { + public function testItEscapesHtmlText() { expect(EHelper::escapeHtmlText('Text\'"Hello')) ->equals("Text<tag>'\"Hello</tag>"); } - function testItEscapesHtmlAttr() { + public function testItEscapesHtmlAttr() { expect(EHelper::escapeHtmlAttr('Text\'"Hello')) ->equals("Text<tag>'"Hello</tag>"); } - function testItEscapesLinkAttr() { + public function testItEscapesLinkAttr() { expect(EHelper::escapeHtmlLinkAttr('Text\'"Hello')) ->equals("Text<tag>'"Hello</tag>"); expect(EHelper::escapeHtmlLinkAttr('javaScRipt:Text\'"Hello')) diff --git a/tests/unit/Newsletter/Renderer/PreprocessorTest.php b/tests/unit/Newsletter/Renderer/PreprocessorTest.php index c123c85e55..8df5e99846 100644 --- a/tests/unit/Newsletter/Renderer/PreprocessorTest.php +++ b/tests/unit/Newsletter/Renderer/PreprocessorTest.php @@ -9,7 +9,7 @@ use MailPoet\WooCommerce\TransactionalEmails; class PreprocessorTest extends \MailPoetUnitTest { - function testProcessWooCommerceHeadingBlock() { + public function testProcessWooCommerceHeadingBlock() { $renderer = Stub::make(Renderer::class); $transactional_emails = Stub::make(TransactionalEmails::class, [ 'getWCEmailSettings' => [ @@ -40,7 +40,7 @@ class PreprocessorTest extends \MailPoetUnitTest { ]]); } - function testProcessWooCommerceContentBlock() { + public function testProcessWooCommerceContentBlock() { $renderer = Stub::make(Renderer::class); $preprocessor = new Preprocessor($renderer, Stub::make(TransactionalEmails::class)); expect($preprocessor->processBlock(['type' => 'woocommerceContent']))->equals([[ diff --git a/tests/unit/Newsletter/Renderer/StylesHelperTest.php b/tests/unit/Newsletter/Renderer/StylesHelperTest.php index 869177e825..b816cd68ae 100644 --- a/tests/unit/Newsletter/Renderer/StylesHelperTest.php +++ b/tests/unit/Newsletter/Renderer/StylesHelperTest.php @@ -6,7 +6,7 @@ use MailPoet\Newsletter\Renderer\StylesHelper; class StylesHelperTest extends \MailPoetUnitTest { - function testItGetsCustomFontsLinks() { + public function testItGetsCustomFontsLinks() { $styles_with_custom_fonts = [ "text" => [ "fontColor" => "#565656", diff --git a/tests/unit/Referrals/ReferralDetectorTest.php b/tests/unit/Referrals/ReferralDetectorTest.php index e72279b00a..f047851b67 100644 --- a/tests/unit/Referrals/ReferralDetectorTest.php +++ b/tests/unit/Referrals/ReferralDetectorTest.php @@ -14,7 +14,7 @@ class ReferralDetectorTest extends \MailPoetUnitTest { /** @var WPFunctions&MockObject */ private $wp_mock; - function _before() { + public function _before() { $this->settings_mock = $this->createMock(SettingsController::class); $this->wp_mock = $this->createMock(WPFunctions::class); if (!defined(ReferralDetector::REFERRAL_CONSTANT_NAME)) { @@ -22,7 +22,7 @@ class ReferralDetectorTest extends \MailPoetUnitTest { } } - function testItPrefersSettingsValue() { + public function testItPrefersSettingsValue() { $this->settings_mock ->expects($this->once()) ->method('get') @@ -34,7 +34,7 @@ class ReferralDetectorTest extends \MailPoetUnitTest { expect($referral_detector->detect())->equals('settings_referral_id'); } - function testItPrefersOptionValueToConstantAndStoresValueToSettings() { + public function testItPrefersOptionValueToConstantAndStoresValueToSettings() { $this->settings_mock ->expects($this->once()) ->method('get') @@ -51,7 +51,7 @@ class ReferralDetectorTest extends \MailPoetUnitTest { expect($referral_detector->detect())->equals('option_referral_id'); } - function testItCanReadConstantAndStoreValueToSettings() { + public function testItCanReadConstantAndStoreValueToSettings() { $this->settings_mock ->expects($this->once()) ->method('get') diff --git a/tests/unit/Services/SPFCheckTest.php b/tests/unit/Services/SPFCheckTest.php index af7fd273a7..3149ae1a75 100644 --- a/tests/unit/Services/SPFCheckTest.php +++ b/tests/unit/Services/SPFCheckTest.php @@ -3,7 +3,7 @@ namespace MailPoet\Services; class SPFCheckTest extends \MailPoetUnitTest { - function testItChecksSPFRecord() { + public function testItChecksSPFRecord() { $domain = 'example.com'; // Failed to get DNS records $response = false; diff --git a/tests/unit/Settings/CharsetsTest.php b/tests/unit/Settings/CharsetsTest.php index 75f35a6343..b1da6323dd 100644 --- a/tests/unit/Settings/CharsetsTest.php +++ b/tests/unit/Settings/CharsetsTest.php @@ -5,7 +5,7 @@ namespace MailPoet\Test\Settings; use MailPoet\Settings\Charsets; class CharsetsTest extends \MailPoetUnitTest { - function testItReturnsAListOfCharsets() { + public function testItReturnsAListOfCharsets() { $charsets = Charsets::getAll(); expect($charsets)->notEmpty(); expect($charsets[0])->equals('UTF-8'); diff --git a/tests/unit/Settings/HostsTest.php b/tests/unit/Settings/HostsTest.php index 4baf7caba5..714d844913 100644 --- a/tests/unit/Settings/HostsTest.php +++ b/tests/unit/Settings/HostsTest.php @@ -5,7 +5,7 @@ namespace MailPoet\Test\Settings; use MailPoet\Settings\Hosts; class HostsTest extends \MailPoetUnitTest { - function testItReturnsAListOfWebHosts() { + public function testItReturnsAListOfWebHosts() { $web_hosts = Hosts::getWebHosts(); expect($web_hosts)->notEmpty(); @@ -15,7 +15,7 @@ class HostsTest extends \MailPoetUnitTest { } } - function testItReturnsAListOfSMTPHosts() { + public function testItReturnsAListOfSMTPHosts() { $smtp_hosts = Hosts::getSMTPHosts(); expect($smtp_hosts)->notEmpty(); diff --git a/tests/unit/Subscribers/ImportExport/Import/MailChimpTest.php b/tests/unit/Subscribers/ImportExport/Import/MailChimpTest.php index 92309d4a75..c4efd452aa 100644 --- a/tests/unit/Subscribers/ImportExport/Import/MailChimpTest.php +++ b/tests/unit/Subscribers/ImportExport/Import/MailChimpTest.php @@ -16,14 +16,14 @@ class MailChimpTest extends \MailPoetUnitTest { /** @var array */ private $lists; - function __construct() { + public function __construct() { parent::__construct(); $this->api_key = getenv('WP_TEST_IMPORT_MAILCHIMP_API'); $this->mailchimp = new MailChimp($this->api_key); $this->lists = explode(",", getenv('WP_TEST_IMPORT_MAILCHIMP_LISTS')); } - function _before() { + public function _before() { WPFunctions::set(Stub::make(new WPFunctions, [ '__' => function ($value) { return $value; @@ -31,7 +31,7 @@ class MailChimpTest extends \MailPoetUnitTest { ])); } - function testItCanGetAPIKey() { + public function testItCanGetAPIKey() { $valid_api_key_format = '12345678901234567890123456789012-ab1'; // key must consist of two parts separated by hyphen expect($this->mailchimp->getAPIKey('invalid_api_key_format'))->false(); @@ -49,14 +49,14 @@ class MailChimpTest extends \MailPoetUnitTest { ->equals($valid_api_key_format); } - function testItCanGetDatacenter() { + public function testItCanGetDatacenter() { $valid_api_key_format = '12345678901234567890123456789012-ab1'; $data_center = 'ab1'; expect($this->mailchimp->getDataCenter($valid_api_key_format)) ->equals($data_center); } - function testItFailsWithIncorrectAPIKey() { + public function testItFailsWithIncorrectAPIKey() { if (getenv('WP_TEST_ENABLE_NETWORK_TESTS') !== 'true') $this->markTestSkipped(); try { @@ -69,7 +69,7 @@ class MailChimpTest extends \MailPoetUnitTest { } } - function testItCanGetLists() { + public function testItCanGetLists() { if (getenv('WP_TEST_ENABLE_NETWORK_TESTS') !== 'true') $this->markTestSkipped(); try { $lists = $this->mailchimp->getLists(); @@ -81,7 +81,7 @@ class MailChimpTest extends \MailPoetUnitTest { expect($lists[0]['name'])->notEmpty(); } - function testItFailsWithIncorrectLists() { + public function testItFailsWithIncorrectLists() { if (getenv('WP_TEST_ENABLE_NETWORK_TESTS') !== 'true') $this->markTestSkipped(); try { @@ -99,7 +99,7 @@ class MailChimpTest extends \MailPoetUnitTest { } } - function testItCanGetSubscribers() { + public function testItCanGetSubscribers() { if (getenv('WP_TEST_ENABLE_NETWORK_TESTS') !== 'true') $this->markTestSkipped(); try { @@ -115,7 +115,7 @@ class MailChimpTest extends \MailPoetUnitTest { expect($subscribers['subscribersCount'])->equals(1); } - function testItFailsWhenSubscribersDataTooLarge() { + public function testItFailsWhenSubscribersDataTooLarge() { if (getenv('WP_TEST_ENABLE_NETWORK_TESTS') !== 'true') $this->markTestSkipped(); $mailchimp = clone($this->mailchimp); $mailchimp->max_post_size = 10; @@ -129,7 +129,7 @@ class MailChimpTest extends \MailPoetUnitTest { } } - function _after() { + public function _after() { WPFunctions::set(new WPFunctions); } } diff --git a/tests/unit/Subscription/BlacklistTest.php b/tests/unit/Subscription/BlacklistTest.php index 1b687bc991..a7889e9b4e 100644 --- a/tests/unit/Subscription/BlacklistTest.php +++ b/tests/unit/Subscription/BlacklistTest.php @@ -3,7 +3,7 @@ namespace MailPoet\Subscription; class BlacklistTest extends \MailPoetUnitTest { - function testItChecksBlacklistedEmails() { + public function testItChecksBlacklistedEmails() { $email = 'test@example.com'; $domain = 'example.com'; $blacklist = new Blacklist(); diff --git a/tests/unit/Util/DOMTest.php b/tests/unit/Util/DOMTest.php index ef9f67e237..394ac0942c 100644 --- a/tests/unit/Util/DOMTest.php +++ b/tests/unit/Util/DOMTest.php @@ -9,11 +9,11 @@ class DOMTest extends \MailPoetUnitTest { /** @var pQuery\DomNode */ private $root; - function _before() { + public function _before() { $this->root = pQuery::parseStr('

italicprevious textnext textbolded

'); } - function testItDeepSplitsDOMTreeByElement() { + public function testItDeepSplitsDOMTreeByElement() { $a = $this->root->query('a'); assert($a instanceof pQuery); DOMUtil::splitOn($this->root, $a->offsetGet(0)); @@ -25,7 +25,7 @@ class DOMTest extends \MailPoetUnitTest { ); } - function testItFindsTopAncestor() { + public function testItFindsTopAncestor() { $img = $this->root->query('img'); assert($img instanceof pQuery); $image = $img->offsetGet(0); diff --git a/tests/unit/Util/HelpersTest.php b/tests/unit/Util/HelpersTest.php index de83953527..87dfe2c60e 100644 --- a/tests/unit/Util/HelpersTest.php +++ b/tests/unit/Util/HelpersTest.php @@ -5,14 +5,14 @@ namespace MailPoet\Test\Util; use MailPoet\Util\Helpers; class HelpersTest extends \MailPoetUnitTest { - function testItReplacesLinkTags() { + public function testItReplacesLinkTags() { $source = '[link]example link[/link]'; $link = 'http://example.com'; expect(Helpers::replaceLinkTags($source, $link)) ->equals('example link'); } - function testItReplacesLinkTagsAndAddsAttributes() { + public function testItReplacesLinkTagsAndAddsAttributes() { $source = '[link]example link[/link]'; $link = 'http://example.com'; $attributes = [ @@ -23,20 +23,20 @@ class HelpersTest extends \MailPoetUnitTest { ->equals('example link'); } - function testItAcceptsCustomLinkTag() { + public function testItAcceptsCustomLinkTag() { $source = '[custom_link_tag]example link[/custom_link_tag]'; $link = 'http://example.com'; expect(Helpers::replaceLinkTags($source, $link, [], 'custom_link_tag')) ->equals('example link'); } - function testItChecksForValidJsonString() { + public function testItChecksForValidJsonString() { expect(Helpers::isJson(123))->false(); $json = json_encode(['one' => 1, 'two' => 2]); expect(Helpers::isJson($json))->true(); } - function testItTrimStringsRecursively() { + public function testItTrimStringsRecursively() { expect(Helpers::recursiveTrim(' foo'))->equals('foo'); expect(Helpers::recursiveTrim('foo '))->equals('foo'); expect(Helpers::recursiveTrim(123))->equals(123); diff --git a/tests/unit/Util/License/Features/SubscribersTest.php b/tests/unit/Util/License/Features/SubscribersTest.php index b34e81f22b..738f7a72b8 100644 --- a/tests/unit/Util/License/Features/SubscribersTest.php +++ b/tests/unit/Util/License/Features/SubscribersTest.php @@ -10,7 +10,7 @@ use MailPoet\Util\License\Features\Subscribers as SubscribersFeature; class SubscribersTest extends \MailPoetUnitTest { - function testCheckReturnsTrueIfOldUserReachedLimit() { + public function testCheckReturnsTrueIfOldUserReachedLimit() { $subscribers_feature = $this->constructWith([ 'has_mss_key' => false, 'has_premium_key' => false, @@ -20,7 +20,7 @@ class SubscribersTest extends \MailPoetUnitTest { expect($subscribers_feature->check())->true(); } - function testCheckReturnsFalseIfOldUserDidntReachLimit() { + public function testCheckReturnsFalseIfOldUserDidntReachLimit() { $subscribers_feature = $this->constructWith([ 'has_mss_key' => false, 'has_premium_key' => false, @@ -30,7 +30,7 @@ class SubscribersTest extends \MailPoetUnitTest { expect($subscribers_feature->check())->false(); } - function testCheckReturnsTrueIfNewUserReachedLimit() { + public function testCheckReturnsTrueIfNewUserReachedLimit() { $subscribers_feature = $this->constructWith([ 'has_mss_key' => false, 'has_premium_key' => false, @@ -40,7 +40,7 @@ class SubscribersTest extends \MailPoetUnitTest { expect($subscribers_feature->check())->true(); } - function testCheckReturnsFalseIfNewUserDidntReachLimit() { + public function testCheckReturnsFalseIfNewUserDidntReachLimit() { $subscribers_feature = $this->constructWith([ 'has_mss_key' => false, 'has_premium_key' => false, @@ -50,7 +50,7 @@ class SubscribersTest extends \MailPoetUnitTest { expect($subscribers_feature->check())->false(); } - function testCheckReturnsFalseIfMSSKeyExists() { + public function testCheckReturnsFalseIfMSSKeyExists() { $subscribers_feature = $this->constructWith([ 'has_mss_key' => true, 'has_premium_key' => false, @@ -60,7 +60,7 @@ class SubscribersTest extends \MailPoetUnitTest { expect($subscribers_feature->check())->false(); } - function testCheckReturnsFalseIfPremiumKeyExists() { + public function testCheckReturnsFalseIfPremiumKeyExists() { $subscribers_feature = $this->constructWith([ 'has_mss_key' => false, 'has_premium_key' => true, diff --git a/tests/unit/Util/License/LicenseTest.php b/tests/unit/Util/License/LicenseTest.php index b6dc5f03fb..1815bfbc38 100644 --- a/tests/unit/Util/License/LicenseTest.php +++ b/tests/unit/Util/License/LicenseTest.php @@ -5,7 +5,7 @@ namespace MailPoet\Test\Util\License; use MailPoet\Util\License\License; class LicenseTest extends \MailPoetUnitTest { - function testItGetsLicense() { + public function testItGetsLicense() { if (defined('MAILPOET_PREMIUM_LICENSE')) return; expect(License::getLicense())->false(); expect(License::getLicense('valid'))->equals('valid'); diff --git a/tests/unit/Util/PQueryTest.php b/tests/unit/Util/PQueryTest.php index 6e093e1a22..26448a1f1f 100644 --- a/tests/unit/Util/PQueryTest.php +++ b/tests/unit/Util/PQueryTest.php @@ -5,14 +5,14 @@ namespace MailPoet\Test\Util; use MailPoet\Util\pQuery\pQuery; class PQueryTest extends \MailPoetUnitTest { - function testBreakingQuoteAreNotRendered() { + public function testBreakingQuoteAreNotRendered() { $html = ''; $domnode = pQuery::parseStr($html); $inner_text = $domnode->getInnerText(); expect($inner_text)->equals(""); } - function testQuotesAreCorrectlyEscaped() { + public function testQuotesAreCorrectlyEscaped() { $html_characters = ['"', '"', ''']; foreach ($html_characters as $char) { @@ -20,7 +20,7 @@ class PQueryTest extends \MailPoetUnitTest { } } - function testEncodedHtmlNamesAreDecoded() { + public function testEncodedHtmlNamesAreDecoded() { $html_names = ['&', '<', '>', ' ', '¡', '¢', '£', '¤', '¥', '¦', '§', '¨', '©', 'ª', '«', '¬', '­', '®', '¯', '°', '±', '²', '³', '´', 'µ', '¶', '·', '¸', '¹', 'º', '»', '¼', '½', '¾', '¿', 'À', 'Á', 'Â', 'Ã', 'Ä', 'Å', 'Æ', 'Ç', 'È', 'É', 'Ê', 'Ë', 'Ì', 'Í', 'Î', 'Ï', 'Ð', 'Ñ', 'Ò', 'Ó', 'Ô', 'Õ', 'Ö', '×', 'Ø', 'Ù', 'Ú', 'Û', 'Ü', 'Ý', 'Þ', 'ß', 'à', 'á', 'â', 'ã', 'ä', 'å', 'æ', 'ç', 'è', 'é', 'ê', 'ë', 'ì', 'í', 'î', 'ï', 'ð', 'ñ', 'ò', 'ó', 'ô', 'õ', 'ö', '÷', 'ø', 'ù', 'ú', 'û', 'ü', 'ý', 'þ', 'ÿ']; foreach ($html_names as $char) { @@ -28,7 +28,7 @@ class PQueryTest extends \MailPoetUnitTest { } } - function testEncodedHtmlNumbersAreDecoded() { + public function testEncodedHtmlNumbersAreDecoded() { // Tested numbers are from https://www.ascii.cl/htmlcodes.htm $html_numbers = array_merge(range(40, 126), range(160, 255), [32, 33, 35, 36, 37, 38, 338, 339, 352, 353, 376, 402, 8211, 8212, 8216, 8217, 8218, 8220, 8221, 8222, 8224, 8225, 8226, 8230, 8240, 8364, 8482]); @@ -37,7 +37,7 @@ class PQueryTest extends \MailPoetUnitTest { } } - function testItCanParseRealHtmlSnippets() { + public function testItCanParseRealHtmlSnippets() { $snippets = [ '
', '', @@ -55,7 +55,7 @@ class PQueryTest extends \MailPoetUnitTest { } } - function parseTest($html, $equals = true) { + public function parseTest($html, $equals = true) { $parsed_html = pQuery::parseStr($html)->getInnerText(); if ($equals) { expect($parsed_html)->equals($html); diff --git a/tests/unit/Util/SecondLevelDomainNamesTest.php b/tests/unit/Util/SecondLevelDomainNamesTest.php index f5f4319aeb..ca5560a154 100644 --- a/tests/unit/Util/SecondLevelDomainNamesTest.php +++ b/tests/unit/Util/SecondLevelDomainNamesTest.php @@ -7,28 +7,28 @@ class SecondLevelDomainNamesTest extends \MailPoetUnitTest { /** @var SecondLevelDomainNames */ private $extractor; - function _before() { + public function _before() { parent::_before(); $this->extractor = new SecondLevelDomainNames(); } - function testItGetsSecondLevelDomainName() { + public function testItGetsSecondLevelDomainName() { expect($this->extractor->get('mailpoet.com'))->equals('mailpoet.com'); } - function testItGetsSecondLevelDomainNameFromThirdLevel() { + public function testItGetsSecondLevelDomainNameFromThirdLevel() { expect($this->extractor->get('newsletters.mailpoet.com'))->equals('mailpoet.com'); } - function testItGetsSecondLevelDomainNameWithCoUk() { + public function testItGetsSecondLevelDomainNameWithCoUk() { expect($this->extractor->get('example.co.uk'))->equals('example.co.uk'); } - function testItGetsSecondLevelDomainNameFromThirdLevelWithCoUk() { + public function testItGetsSecondLevelDomainNameFromThirdLevelWithCoUk() { expect($this->extractor->get('test.example.co.uk'))->equals('example.co.uk'); } - function testItGetsSecondLevelDomainNameForLocalhost() { + public function testItGetsSecondLevelDomainNameForLocalhost() { expect($this->extractor->get('localhost'))->equals('localhost'); } } diff --git a/tests/unit/Util/SecurityTest.php b/tests/unit/Util/SecurityTest.php index afc8d6f68f..aa5ae26b94 100644 --- a/tests/unit/Util/SecurityTest.php +++ b/tests/unit/Util/SecurityTest.php @@ -6,7 +6,7 @@ use MailPoet\Util\Security; class SecurityTest extends \MailPoetUnitTest { - function testItCanGenerateARandomString() { + public function testItCanGenerateARandomString() { // it has a default length of 5 $hash = Security::generateRandomString(); expect(strlen($hash))->equals(5); @@ -24,14 +24,14 @@ class SecurityTest extends \MailPoetUnitTest { expect(ctype_alnum($long_hash))->true(); } - function testItGeneratesRandomHash() { + public function testItGeneratesRandomHash() { $hash_1 = Security::generateHash(); $hash_2 = Security::generateHash(); expect($hash_1)->notEquals($hash_2); expect(strlen($hash_1))->equals(Security::HASH_LENGTH); } - function testItGeneratesRandomHashWithCustomLength() { + public function testItGeneratesRandomHashWithCustomLength() { expect(strlen(Security::generateHash(10)))->equals(10); } } \ No newline at end of file diff --git a/tests/unit/Util/UrlTest.php b/tests/unit/Util/UrlTest.php index a726f67c55..1ef6643c2c 100644 --- a/tests/unit/Util/UrlTest.php +++ b/tests/unit/Util/UrlTest.php @@ -7,7 +7,7 @@ use MailPoet\Util\Url; use MailPoet\WP\Functions as WPFunctions; class UrlTest extends \MailPoetUnitTest { - function testCurrentUrlReturnsHomeUrlOnHome() { + public function testCurrentUrlReturnsHomeUrlOnHome() { $home_url = 'http://example.com'; $url_helper = new Url(Stub::make(new WPFunctions(), [ 'homeUrl' => $home_url, diff --git a/tests/unit/WP/DateTimeTest.php b/tests/unit/WP/DateTimeTest.php index e2e3d155d8..065515e6a2 100644 --- a/tests/unit/WP/DateTimeTest.php +++ b/tests/unit/WP/DateTimeTest.php @@ -8,7 +8,7 @@ use MailPoet\WP\Functions as WPFunctions; class DateTimeTest extends \MailPoetUnitTest { - function testGetTimeFormat() { + public function testGetTimeFormat() { $date_time = new WPDateTime(Stub::make(new WPFunctions(), [ 'getOption' => function($key) { return 'H:i'; @@ -24,7 +24,7 @@ class DateTimeTest extends \MailPoetUnitTest { expect($date_time->getTimeFormat())->equals('H:i:s'); } - function testGetDateFormat() { + public function testGetDateFormat() { $date_time = new WPDateTime(Stub::make(new WPFunctions(), [ 'getOption' => function($key) { return 'm-d'; @@ -40,7 +40,7 @@ class DateTimeTest extends \MailPoetUnitTest { expect($date_time->getDateFormat())->equals('Y-m-d'); } - function testGetCurrentDate() { + public function testGetCurrentDate() { $date_time = new WPDateTime(Stub::make(new WPFunctions(), [ 'currentTime' => function($format) { return date($format); @@ -49,7 +49,7 @@ class DateTimeTest extends \MailPoetUnitTest { expect($date_time->getCurrentDate("Y-m"))->equals(date("Y-m")); } - function testGetCurrentTime() { + public function testGetCurrentTime() { $date_time = new WPDateTime(Stub::make(new WPFunctions(), [ 'currentTime' => function($format) { return date($format); @@ -58,7 +58,7 @@ class DateTimeTest extends \MailPoetUnitTest { expect($date_time->getCurrentTime("i:s"))->regExp('/\d\d:\d\d/'); } - function testFormatTime() { + public function testFormatTime() { $date_time = new WPDateTime(Stub::make(new WPFunctions(), [ 'getOption' => function($key) { return 'H:i'; @@ -70,7 +70,7 @@ class DateTimeTest extends \MailPoetUnitTest { expect($date_time->formatTime($timestamp, $format))->equals(date($format, $timestamp)); } - function testFormatDate() { + public function testFormatDate() { $date_time = new WPDateTime(Stub::make(new WPFunctions(), [ 'getOption' => function($key) { return 'm-d'; @@ -82,7 +82,7 @@ class DateTimeTest extends \MailPoetUnitTest { expect($date_time->formatDate($timestamp, $format))->equals(date($format, $timestamp)); } - function testTimeInterval() { + public function testTimeInterval() { $date_time = new WPDateTime(Stub::make(new WPFunctions(), [ 'getOption' => function($key) { return 'H:i'; diff --git a/tests/unit/WP/PostsTest.php b/tests/unit/WP/PostsTest.php index 530a1a7bcf..4666b3b24f 100644 --- a/tests/unit/WP/PostsTest.php +++ b/tests/unit/WP/PostsTest.php @@ -8,7 +8,7 @@ use MailPoet\WP\Posts; class PostsTest extends \MailPoetUnitTest { - function testGetTermsProxiesCallToWordPress() { + public function testGetTermsProxiesCallToWordPress() { $args = [ 'taxonomy' => 'post_tags', 'hide_empty' => true, @@ -31,7 +31,7 @@ class PostsTest extends \MailPoetUnitTest { expect($result['arguments'][0])->equals($args); } - function testGetTermsPassesTaxonomyAsFirstArgumentInOldVersions() { + public function testGetTermsPassesTaxonomyAsFirstArgumentInOldVersions() { $args = [ 'taxonomy' => 'post_tags', 'hide_empty' => true, @@ -55,7 +55,7 @@ class PostsTest extends \MailPoetUnitTest { expect($result['arguments'][1])->equals(array_diff_key($args, ['taxonomy' => ''])); } - function _after() { + public function _after() { WPFunctions::set(new WPFunctions); } } diff --git a/tests/unit/WP/ReadmeTest.php b/tests/unit/WP/ReadmeTest.php index ae469602d8..527e8051d1 100644 --- a/tests/unit/WP/ReadmeTest.php +++ b/tests/unit/WP/ReadmeTest.php @@ -8,24 +8,24 @@ class ReadmeTest extends \MailPoetUnitTest { /** @var string */ private $data; - function _before() { + public function _before() { // Sample taken from https://wordpress.org/plugins/about/readme.txt $this->data = file_get_contents(dirname(__FILE__) . '/ReadmeTestData.txt'); } - function testItParsesChangelog() { + public function testItParsesChangelog() { $result = Readme::parseChangelog($this->data); expect(count($result))->equals(2); expect(count($result[0]['changes']))->equals(2); expect(count($result[1]['changes']))->equals(1); } - function testItRespectsLimitOfParsedItems() { + public function testItRespectsLimitOfParsedItems() { $result = Readme::parseChangelog($this->data, 1); expect(count($result))->equals(1); } - function testItReturnsFalseOnMalformedData() { + public function testItReturnsFalseOnMalformedData() { $result = Readme::parseChangelog(""); expect($result)->false(); $result = Readme::parseChangelog("== Changelog ==\n\n\n=\n=="); diff --git a/tests/unit/WooCommerce/TransactionalEmailsTest.php b/tests/unit/WooCommerce/TransactionalEmailsTest.php index 8c9d62f5ab..c82f69244e 100644 --- a/tests/unit/WooCommerce/TransactionalEmailsTest.php +++ b/tests/unit/WooCommerce/TransactionalEmailsTest.php @@ -12,7 +12,7 @@ use MailPoet\WP\Functions as WPFunctions; class TransactionalEmailsTest extends \MailPoetUnitTest { - function testGetEmailHeadings() { + public function testGetEmailHeadings() { $wp = Stub::make(new WPFunctions, [ 'getOption' => function($name) { if ($name === 'woocommerce_new_order_settings')