mirror of
https://github.com/yiisoft/yii2.git
synced 2025-11-03 13:58:55 +08:00
* Fix `\yiiunit\framework\helpers\ConsoleTest::testErrorSummary` * Fix `\yiiunit\framework\console\controllers\PHPMessageControllerTest::testRemoveUnusedBehavior`
This commit is contained in:
committed by
Alexander Makarov
parent
27463c1fcf
commit
c5397f8784
@ -7,10 +7,6 @@ environment:
|
||||
matrix:
|
||||
- php_ver: 7.2.4
|
||||
|
||||
matrix:
|
||||
allow_failures:
|
||||
- php_ver: 7.2.4
|
||||
|
||||
cache:
|
||||
- '%APPDATA%\Composer'
|
||||
- '%LOCALAPPDATA%\Composer'
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -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]);
|
||||
|
||||
Reference in New Issue
Block a user