Permalink
Browse files

Follow the deprecation note of 2.1 migration guide and switch to fetc…

…h(title)

correct assert order for test
  • Loading branch information...
1 parent 7f2e0a2 commit 29e15386b20b5c6f6573f60b6cb2fd2371190453 @dereuromark dereuromark committed Jan 9, 2014
@@ -10,7 +10,7 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN">
<html>
<head>
- <title><?php echo $title_for_layout; ?></title>
+ <title><?php echo $this->fetch('title'); ?></title>
</head>
<body>
<?php echo $this->fetch('content'); ?>
@@ -15,7 +15,7 @@ $cakeDescription = __d('cake_dev', 'CakePHP: the rapid development php framework
<?php echo $this->Html->charset(); ?>
<title>
<?php echo $cakeDescription ?>:
- <?php echo $title_for_layout; ?>
+ <?php echo $this->fetch('title'); ?>
</title>
<?php
echo $this->Html->meta('icon');
@@ -15,7 +15,7 @@ $cakeDescription = __d('cake_dev', 'CakePHP: the rapid development php framework
<?php echo $this->Html->charset(); ?>
<title>
<?php echo $cakeDescription ?>:
- <?php echo $title_for_layout; ?>
+ <?php echo $this->fetch('title'); ?>
</title>
<?php
echo $this->Html->meta('icon');
@@ -3,7 +3,7 @@ if (!isset($channel)):
$channel = array();
endif;
if (!isset($channel['title'])):
- $channel['title'] = $title_for_layout;
+ $channel['title'] = $this->fetch('title');
endif;
echo $this->Rss->document(
@@ -191,14 +191,14 @@ public function testSendFormats() {
MSGBLOC;
$this->Controller->EmailTest->sendAs = 'text';
- $expect = str_replace('{CONTENTTYPE}', 'text/plain; charset=UTF-8', $message);
+ $expects = str_replace('{CONTENTTYPE}', 'text/plain; charset=UTF-8', $message);
$this->assertTrue($this->Controller->EmailTest->send('This is the body of the message'));
- $this->assertTextEquals(DebugCompTransport::$lastEmail, $expect);
+ $this->assertTextEquals($expects, DebugCompTransport::$lastEmail);
$this->Controller->EmailTest->sendAs = 'html';
- $expect = str_replace('{CONTENTTYPE}', 'text/html; charset=UTF-8', $message);
+ $expects = str_replace('{CONTENTTYPE}', 'text/html; charset=UTF-8', $message);
$this->assertTrue($this->Controller->EmailTest->send('This is the body of the message'));
- $this->assertTextEquals(DebugCompTransport::$lastEmail, $expect);
+ $this->assertTextEquals($expects, DebugCompTransport::$lastEmail);
}
/**
@@ -262,18 +262,18 @@ public function testTemplates() {
HTMLBLOC;
$this->Controller->EmailTest->sendAs = 'text';
- $expect = '<pre>' . str_replace('{CONTENTTYPE}', 'text/plain; charset=UTF-8', $header) . $text . "\n" . '</pre>';
+ $expects = '<pre>' . str_replace('{CONTENTTYPE}', 'text/plain; charset=UTF-8', $header) . $text . "\n" . '</pre>';
$this->assertTrue($this->Controller->EmailTest->send('This is the body of the message'));
- $this->assertTextEquals(DebugCompTransport::$lastEmail, $expect);
+ $this->assertTextEquals($expects, DebugCompTransport::$lastEmail);
$this->Controller->EmailTest->sendAs = 'html';
- $expect = '<pre>' . str_replace('{CONTENTTYPE}', 'text/html; charset=UTF-8', $header) . $html . "\n" . '</pre>';
+ $expects = '<pre>' . str_replace('{CONTENTTYPE}', 'text/html; charset=UTF-8', $header) . $html . "\n" . '</pre>';
$this->assertTrue($this->Controller->EmailTest->send('This is the body of the message'));
- $this->assertTextEquals(DebugCompTransport::$lastEmail, $expect);
+ $this->assertTextEquals($expects, DebugCompTransport::$lastEmail);
$this->Controller->EmailTest->sendAs = 'both';
- $expect = str_replace('{CONTENTTYPE}', 'multipart/mixed; boundary="{boundary}"', $header);
- $expect .= "--{boundary}\n" .
+ $expects = str_replace('{CONTENTTYPE}', 'multipart/mixed; boundary="{boundary}"', $header);
+ $expects .= "--{boundary}\n" .
'Content-Type: multipart/alternative; boundary="alt-{boundary}"' . "\n\n" .
'--alt-{boundary}' . "\n" .
'Content-Type: text/plain; charset=UTF-8' . "\n" .
@@ -288,11 +288,11 @@ public function testTemplates() {
'--alt-{boundary}--' . "\n\n\n" .
'--{boundary}--' . "\n";
- $expect = '<pre>' . $expect . '</pre>';
+ $expects = '<pre>' . $expects . '</pre>';
$this->assertTrue($this->Controller->EmailTest->send('This is the body of the message'));
$this->assertTextEquals(
- $expect,
+ $expects,
preg_replace('/[a-z0-9]{32}/i', '{boundary}', DebugCompTransport::$lastEmail)
);
@@ -313,9 +313,9 @@ public function testTemplates() {
HTMLBLOC;
$this->Controller->EmailTest->sendAs = 'html';
- $expect = '<pre>' . str_replace('{CONTENTTYPE}', 'text/html; charset=UTF-8', $header) . $html . '</pre>';
+ $expects = '<pre>' . str_replace('{CONTENTTYPE}', 'text/html; charset=UTF-8', $header) . $html . '</pre>';
$this->assertTrue($this->Controller->EmailTest->send('This is the body of the message', 'default', 'thin'));
- $this->assertTextEquals(DebugCompTransport::$lastEmail, $expect);
+ $this->assertTextEquals($expects, DebugCompTransport::$lastEmail);
}
/**
@@ -2,7 +2,7 @@
<html>
<head>
- <title><?php echo $title_for_layout; ?></title>
+ <title><?php echo $this->fetch('title'); ?></title>
</head>
<body>
@@ -2,7 +2,7 @@
<html>
<head>
- <title><?php echo $title_for_layout; ?></title>
+ <title><?php echo $this->fetch('title'); ?></title>
</head>
<body>
@@ -2,7 +2,7 @@
<html>
<head>
- <title><?php echo $title_for_layout; ?></title>
+ <title><?php echo $this->fetch('title'); ?></title>
</head>
<body>
@@ -1,7 +1,7 @@
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
- <title><?php echo $title_for_layout; ?></title>
+ <title><?php echo $this->fetch('title'); ?></title>
<!--nocache--><?php $x = 1; ?><!--/nocache-->
</head>
<body>
@@ -10,7 +10,7 @@ $cakeDescription = __d('cake_dev', 'CakePHP: the rapid development php framework
<?php echo $this->Html->charset(); ?>
<title>
<?php echo $cakeDescription ?>:
- <?php echo $title_for_layout; ?>
+ <?php echo $this->fetch('title'); ?>
</title>
<?php
echo $this->Html->meta('icon');
@@ -5,7 +5,7 @@ if (!isset($channel)) {
$channel = array();
}
if (!isset($channel['title'])) {
- $channel['title'] = $title_for_layout;
+ $channel['title'] = $this->fetch('title');
}
echo $this->Rss->document(
View
@@ -452,7 +452,6 @@ public function render($view = null, $layout = null) {
if ($this->hasRendered) {
return true;
}
- $this->Blocks->set('content', '');
if ($view !== false && $viewFileName = $this->_getViewFileName($view)) {
$this->_currentType = self::TYPE_VIEW;
@@ -485,7 +484,8 @@ public function render($view = null, $layout = null) {
* - `$scripts_for_layout` is deprecated and will be removed in CakePHP 3.0.
* Use the block features instead. `meta`, `css` and `script` will be populated
* by the matching methods on HtmlHelper.
- * - `$title_for_layout` is deprecated and will be removed in CakePHP 3.0
+ * - `$title_for_layout` is deprecated and will be removed in CakePHP 3.0.
+ * Use the `title` block instead.
* - `$content_for_layout` is deprecated and will be removed in CakePHP 3.0.
* Use the `content` block instead.
*
@@ -515,9 +515,16 @@ public function renderLayout($content, $layout = null) {
'scripts_for_layout' => $scripts,
));
- if (!isset($this->viewVars['title_for_layout'])) {
- $this->viewVars['title_for_layout'] = Inflector::humanize($this->viewPath);
+ $title = $this->Blocks->get('title');
+ if ($title === '') {
+ if (isset($this->viewVars['title_for_layout'])) {
+ $title = $this->viewVars['title_for_layout'];
+ } else {
+ $title = Inflector::humanize($this->viewPath);
+ }
}
+ $this->viewVars['title_for_layout'] = $title;
+ $this->Blocks->set('title', $title);
$this->_currentType = self::TYPE_LAYOUT;
$this->Blocks->set('content', $this->_render($layoutFileName));

0 comments on commit 29e1538

Please sign in to comment.