Follow the deprecation note of 2.1 migration guide and switch to fetch(title)

correct assert order for test
This commit is contained in:
euromark 2014-01-09 16:45:49 +01:00
parent 7f2e0a29a4
commit 29e15386b2
12 changed files with 35 additions and 28 deletions

View file

@ -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'); ?>

View file

@ -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');

View file

@ -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');

View file

@ -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(

View file

@ -191,14 +191,14 @@ This is the body of the message
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 @@ TEXTBLOC;
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 @@ HTMLBLOC;
'--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 @@ HTMLBLOC;
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);
}
/**

View file

@ -2,7 +2,7 @@
<html>
<head>
<title><?php echo $title_for_layout; ?></title>
<title><?php echo $this->fetch('title'); ?></title>
</head>
<body>

View file

@ -2,7 +2,7 @@
<html>
<head>
<title><?php echo $title_for_layout; ?></title>
<title><?php echo $this->fetch('title'); ?></title>
</head>
<body>

View file

@ -2,7 +2,7 @@
<html>
<head>
<title><?php echo $title_for_layout; ?></title>
<title><?php echo $this->fetch('title'); ?></title>
</head>
<body>

View file

@ -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>

View file

@ -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');

View file

@ -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 file

@ -452,7 +452,6 @@ class View extends Object {
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 @@ class View extends Object {
* - `$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 @@ class View extends Object {
'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));