Files
piratepoet/tests/integration/Util/Notices/PHPVersionWarningsTest.php
Jan Jakeš b39dac75d6 Autofix number of newlines between methods
[MAILPOET-2715]
2020-02-19 19:12:53 +00:00

65 lines
2.0 KiB
PHP

<?php
namespace MailPoet\Util\Notices;
class PHPVersionWarningsTest extends \MailPoetTest {
/** @var PHPVersionWarnings */
private $phpVersionWarning;
public function _before() {
parent::_before();
$this->phpVersionWarning = new PHPVersionWarnings();
delete_transient('dismissed-php-version-outdated-notice');
}
public function _after() {
delete_transient('dismissed-php-version-outdated-notice');
}
public function testPHP55IsOutdated() {
expect($this->phpVersionWarning->isOutdatedPHPVersion('5.5.3'))->true();
}
public function testPHP56IsOutdated() {
expect($this->phpVersionWarning->isOutdatedPHPVersion('5.6.3'))->true();
}
public function testPHP70IsOutdated() {
expect($this->phpVersionWarning->isOutdatedPHPVersion('7.0.8'))->true();
}
public function testPHP72IsNotOutdated() {
expect($this->phpVersionWarning->isOutdatedPHPVersion('7.2'))->false();
}
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/');
}
public function testItPrintsWarningFor70() {
$warning = $this->phpVersionWarning->init('7.0.0', true);
expect($warning->getMessage())->contains('Your website is running on PHP 7.0.0');
expect($warning->getMessage())->contains('https://www.mailpoet.com/let-us-handle-your-php-upgrade/');
}
public function testItPrintsNoWarningFor71() {
$warning = $this->phpVersionWarning->init('7.1', true);
expect($warning)->null();
}
public function testItPrintsNoWarningWhenDisabled() {
$warning = $this->phpVersionWarning->init('5.5.3', false);
expect($warning)->null();
}
public function testItPrintsNoWarningWhenDismised() {
$this->phpVersionWarning->init('5.5.3', true);
$this->phpVersionWarning->disable();
$warning = $this->phpVersionWarning->init('5.5.3', true);
expect($warning)->null();
}
}