Permalink
Browse files

Fix more tests to use assertTextEquals()

Refs #2148
  • Loading branch information...
1 parent 2afece4 commit 14228fa46902801a941f6589817a3cc16292e251 @markstory markstory committed Feb 17, 2012
@@ -1410,11 +1410,9 @@ public function testFullPageCachingDispatch($url) {
$dispatcher->cached($request->here());
$cached = ob_get_clean();
- $result = str_replace(array("\t", "\r\n", "\n"), "", $out);
$cached = preg_replace('/<!--+[^<>]+-->/', '', $cached);
- $expected = str_replace(array("\t", "\r\n", "\n"), "", $cached);
- $this->assertEquals($expected, $result);
+ $this->assertTextEquals($cached, $out);
$filename = $this->__cachePath($request->here());
unlink($filename);
@@ -212,7 +212,7 @@ public function testMissingView() {
$View = new TestTheme2View($this->Controller);
ob_start();
$result = $View->getViewFileName('does_not_exist');
- $expected = str_replace(array("\t", "\r\n", "\n"), "", ob_get_clean());
+ $expected = ob_get_clean();
$this->assertRegExp("/PagesController::/", $expected);
$this->assertRegExp("/views(\/|\\\)themed(\/|\\\)my_theme(\/|\\\)pages(\/|\\\)does_not_exist.ctp/", $expected);
}
@@ -233,7 +233,7 @@ public function testMissingLayout() {
$View = new TestTheme2View($this->Controller);
ob_start();
$result = $View->getLayoutFileName();
- $expected = str_replace(array("\t", "\r\n", "\n"), "", ob_get_clean());
+ $expected = ob_get_clean();
$this->assertRegExp("/Missing Layout/", $expected);
$this->assertRegExp("/views(\/|\\\)themed(\/|\\\)my_theme(\/|\\\)layouts(\/|\\\)whatever.ctp/", $expected);
}
@@ -558,7 +558,7 @@ public function testMissingView() {
$View = new TestThemeView($this->ThemeController);
ob_start();
$result = $View->getViewFileName('does_not_exist');
- $expected = str_replace(array("\t", "\r\n", "\n"), "", ob_get_clean());
+ $expected = ob_get_clean();
$this->assertRegExp("/PagesController::/", $expected);
$this->assertRegExp("/views(\/|\\\)themed(\/|\\\)my_theme(\/|\\\)pages(\/|\\\)does_not_exist.ctp/", $expected);
}
@@ -578,7 +578,7 @@ public function testMissingLayout() {
$View = new TestView($this->Controller);
ob_start();
$result = $View->getLayoutFileName();
- $expected = str_replace(array("\t", "\r\n", "\n"), "", ob_get_clean());
+ $expected = ob_get_clean();
$this->ThemeController->plugin = null;
$this->ThemeController->name = 'Posts';
@@ -589,7 +589,7 @@ public function testMissingLayout() {
$View = new TestThemeView($this->ThemeController);
ob_start();
$result = $View->getLayoutFileName();
- $expected = str_replace(array("\t", "\r\n", "\n"), "", ob_get_clean());
+ $expected = ob_get_clean();
$this->assertRegExp("/Missing Layout/", $expected);
$this->assertRegExp("/views(\/|\\\)themed(\/|\\\)my_theme(\/|\\\)layouts(\/|\\\)whatever.ctp/", $expected);
}
@@ -955,11 +955,11 @@ public function testRenderLoadHelper() {
*/
public function testRender() {
$View = new TestView($this->PostsController);
- $result = str_replace(array("\t", "\r\n", "\n"), "", $View->render('index'));
+ $result = $View->render('index');
- $this->assertRegExp("/<meta http-equiv=\"Content-Type\" content=\"text\/html; charset=utf-8\" \/><title>/", $result);
- $this->assertRegExp("/<div id=\"content\">posts index<\/div>/", $result);
- $this->assertRegExp("/<div id=\"content\">posts index<\/div>/", $result);
+ $this->assertRegExp("/<meta http-equiv=\"Content-Type\" content=\"text\/html; charset=utf-8\" \/>\s*<title>/", $result);
+ $this->assertRegExp("/<div id=\"content\">\s*posts index\s*<\/div>/", $result);
+ $this->assertRegExp("/<div id=\"content\">\s*posts index\s*<\/div>/", $result);
$this->assertTrue(isset($View->viewVars['content_for_layout']), 'content_for_layout should be a view var');
$this->assertTrue(isset($View->viewVars['scripts_for_layout']), 'scripts_for_layout should be a view var');
@@ -970,7 +970,7 @@ public function testRender() {
$this->PostsController->set('page_title', 'yo what up');
$View = new TestView($this->PostsController);
- $result = str_replace(array("\t", "\r\n", "\n"), "", $View->render(false, 'flash'));
+ $result = $View->render(false, 'flash');
$this->assertRegExp("/<title>yo what up<\/title>/", $result);
$this->assertRegExp("/<p><a href=\"flash\">yo what up<\/a><\/p>/", $result);
@@ -984,11 +984,11 @@ public function testRender() {
Configure::write('Cache.check', true);
$View = new TestView($this->PostsController);
- $result = str_replace(array("\t", "\r\n", "\n"), "", $View->render('index'));
+ $result = $View->render('index');
- $this->assertRegExp("/<meta http-equiv=\"Content-Type\" content=\"text\/html; charset=utf-8\" \/><title>/", $result);
- $this->assertRegExp("/<div id=\"content\">posts index<\/div>/", $result);
- $this->assertRegExp("/<div id=\"content\">posts index<\/div>/", $result);
+ $this->assertRegExp("/<meta http-equiv=\"Content-Type\" content=\"text\/html; charset=utf-8\" \/>\s*<title>/", $result);
+ $this->assertRegExp("/<div id=\"content\">\s*posts index\s*<\/div>/", $result);
+ $this->assertRegExp("/<div id=\"content\">\s*posts index\s*<\/div>/", $result);
}
/**
@@ -1198,7 +1198,6 @@ public function testBadExt() {
$View = new TestView($this->PostsController);
$View->render('this_is_missing');
- $result = str_replace(array("\t", "\r\n", "\n"), "", ob_get_clean());
}
/**
@@ -1222,7 +1221,6 @@ public function testAltExt() {
public function testAltBadExt() {
$View = new TestView($this->PostsController);
$View->render('alt_ext');
- $result = str_replace(array("\t", "\r\n", "\n"), "", ob_get_clean());
}
/**
@@ -43,8 +43,8 @@ public function testRenderWithoutView() {
$View = new XmlView($Controller);
$output = $View->render(false);
- $expected = '<?xml version="1.0" encoding="UTF-8"?><users><user>user1</user><user>user2</user></users>';
- $this->assertIdentical($expected, str_replace(array("\r", "\n"), '', $output));
+ $expected = '<?xml version="1.0" encoding="UTF-8"?>' . "\n" . '<users><user>user1</user><user>user2</user></users>';
+ $this->assertTextEquals($expected, trim($output));
$this->assertIdentical('application/xml', $Response->type());
}

0 comments on commit 14228fa

Please sign in to comment.