Skip to content

Commit

Permalink
Moved assertEqualsWithoutLE() to \yiiunit\TestCase, fixed some test f…
Browse files Browse the repository at this point in the history
…ailures on Windows
  • Loading branch information
samdark committed Feb 15, 2015
1 parent 6e67f71 commit a831271
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 18 deletions.
14 changes: 14 additions & 0 deletions tests/unit/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,4 +83,18 @@ protected function destroyApplication()
{
\Yii::$app = null;
}

/**
* Asserting two strings equality ignoring line endings
*
* @param string $expected
* @param string $actual
*/
public function assertEqualsWithoutLE($expected, $actual)
{
$expected = str_replace("\r\n", "\n", $expected);
$actual = str_replace("\r\n", "\n", $actual);

$this->assertEquals($expected, $actual);
}
}
8 changes: 0 additions & 8 deletions tests/unit/framework/helpers/HtmlTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,6 @@ protected function setUp()
]);
}

public function assertEqualsWithoutLE($expected, $actual)
{
$expected = str_replace("\r\n", "\n", $expected);
$actual = str_replace("\r\n", "\n", $actual);

$this->assertEquals($expected, $actual);
}

public function testEncode()
{
$this->assertEquals("a&lt;&gt;&amp;&quot;&#039;�", Html::encode("a<>&\"'\x80"));
Expand Down
4 changes: 2 additions & 2 deletions tests/unit/framework/web/AssetBundleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public function testSimpleDependency()
1<link href="/files/cssFile.css" rel="stylesheet">23<script src="/js/jquery.js"></script>
<script src="/files/jsFile.js"></script>4
EOF;
$this->assertEquals($expected, $view->renderFile('@yiiunit/data/views/rawlayout.php'));
$this->assertEqualsWithoutLE($expected, $view->renderFile('@yiiunit/data/views/rawlayout.php'));
}

public function positionProvider()
Expand Down Expand Up @@ -142,7 +142,7 @@ public function testPositionDependency($pos, $jqAlreadyRegistered)
EOF;
break;
}
$this->assertEquals($expected, $view->renderFile('@yiiunit/data/views/rawlayout.php'));
$this->assertEqualsWithoutLE($expected, $view->renderFile('@yiiunit/data/views/rawlayout.php'));
}

public function positionProvider2()
Expand Down
8 changes: 0 additions & 8 deletions tests/unit/framework/widgets/ActiveFormTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,6 @@ protected function setUp()
$this->mockApplication();
}

public function assertEqualsWithoutLE($expected, $actual)
{
$expected = str_replace("\r\n", "\n", $expected);
$actual = str_replace("\r\n", "\n", $actual);

$this->assertEquals($expected, $actual);
}

public function testBooleanAttributes()
{
$o = ['template' => '{input}'];
Expand Down

0 comments on commit a831271

Please sign in to comment.