Closes #16411. Fix windows tests (#17380)

* Fix `\yiiunit\framework\helpers\ConsoleTest::testErrorSummary`
* Fix `\yiiunit\framework\console\controllers\PHPMessageControllerTest::testRemoveUnusedBehavior`
This commit is contained in:
Alexander Kartavenko
2019-06-19 16:48:20 +03:00
committed by Alexander Makarov
parent 27463c1fcf
commit c5397f8784
5 changed files with 18 additions and 6 deletions

View File

@ -7,10 +7,6 @@ environment:
matrix:
- php_ver: 7.2.4
matrix:
allow_failures:
- php_ver: 7.2.4
cache:
- '%APPDATA%\Composer'
- '%LOCALAPPDATA%\Composer'

View File

@ -903,6 +903,7 @@ EOD;
$categoryFileName = str_replace($dirName, '', $messageFile);
$categoryFileName = ltrim($categoryFileName, DIRECTORY_SEPARATOR);
$category = preg_replace('#\.php$#', '', $categoryFileName);
$category = str_replace(DIRECTORY_SEPARATOR, '/', $category);
if (!in_array($category, $existingCategories, true)) {
unlink($messageFile);

View File

@ -122,6 +122,21 @@ abstract class TestCase extends \PHPUnit\Framework\TestCase
$this->assertEquals($expected, $actual, $message);
}
/**
* Asserts that a haystack contains a needle ignoring line endings.
*
* @param mixed $needle
* @param mixed $haystack
* @param string $message
*/
protected function assertContainsWithoutLE($needle, $haystack, $message = '')
{
$needle = str_replace("\r\n", "\n", $needle);
$haystack = str_replace("\r\n", "\n", $haystack);
$this->assertContains($needle, $haystack, $message);
}
/**
* Invokes a inaccessible method.
* @param $object

View File

@ -214,7 +214,7 @@ class ConsoleTest extends TestCase
$model->validate(null, false);
$options = ['showAllErrors' => true];
$expectedHtml = "Error message. Here are some chars: < >\nError message. Here are even more chars: \"\"";
$this->assertEquals($expectedHtml, Console::errorSummary($model, $options));
$this->assertEqualsWithoutLE($expectedHtml, Console::errorSummary($model, $options));
}
}

View File

@ -65,7 +65,7 @@ class ViewTest extends TestCase
$view = new View();
$view->registerJsFile('@web/js/somefile.js', ['position' => View::POS_BEGIN]);
$html = $view->render('@yiiunit/data/views/layout.php', ['content' => 'content']);
$this->assertContains('<body>' . PHP_EOL . '<script src="/baseUrl/js/somefile.js"></script>', $html);
$this->assertContainsWithoutLE('<body>' . PHP_EOL . '<script src="/baseUrl/js/somefile.js"></script>', $html);
$view = new View();
$view->registerJsFile('@web/js/somefile.js', ['position' => View::POS_END]);