mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
Follow the deprecation note of 2.1 migration guide and switch to fetch(title)
correct assert order for test
This commit is contained in:
parent
7f2e0a29a4
commit
29e15386b2
12 changed files with 35 additions and 28 deletions
|
@ -10,7 +10,7 @@
|
||||||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN">
|
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN">
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<title><?php echo $title_for_layout; ?></title>
|
<title><?php echo $this->fetch('title'); ?></title>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<?php echo $this->fetch('content'); ?>
|
<?php echo $this->fetch('content'); ?>
|
||||||
|
|
|
@ -15,7 +15,7 @@ $cakeDescription = __d('cake_dev', 'CakePHP: the rapid development php framework
|
||||||
<?php echo $this->Html->charset(); ?>
|
<?php echo $this->Html->charset(); ?>
|
||||||
<title>
|
<title>
|
||||||
<?php echo $cakeDescription ?>:
|
<?php echo $cakeDescription ?>:
|
||||||
<?php echo $title_for_layout; ?>
|
<?php echo $this->fetch('title'); ?>
|
||||||
</title>
|
</title>
|
||||||
<?php
|
<?php
|
||||||
echo $this->Html->meta('icon');
|
echo $this->Html->meta('icon');
|
||||||
|
|
|
@ -15,7 +15,7 @@ $cakeDescription = __d('cake_dev', 'CakePHP: the rapid development php framework
|
||||||
<?php echo $this->Html->charset(); ?>
|
<?php echo $this->Html->charset(); ?>
|
||||||
<title>
|
<title>
|
||||||
<?php echo $cakeDescription ?>:
|
<?php echo $cakeDescription ?>:
|
||||||
<?php echo $title_for_layout; ?>
|
<?php echo $this->fetch('title'); ?>
|
||||||
</title>
|
</title>
|
||||||
<?php
|
<?php
|
||||||
echo $this->Html->meta('icon');
|
echo $this->Html->meta('icon');
|
||||||
|
|
|
@ -3,7 +3,7 @@ if (!isset($channel)):
|
||||||
$channel = array();
|
$channel = array();
|
||||||
endif;
|
endif;
|
||||||
if (!isset($channel['title'])):
|
if (!isset($channel['title'])):
|
||||||
$channel['title'] = $title_for_layout;
|
$channel['title'] = $this->fetch('title');
|
||||||
endif;
|
endif;
|
||||||
|
|
||||||
echo $this->Rss->document(
|
echo $this->Rss->document(
|
||||||
|
|
|
@ -191,14 +191,14 @@ This is the body of the message
|
||||||
MSGBLOC;
|
MSGBLOC;
|
||||||
|
|
||||||
$this->Controller->EmailTest->sendAs = 'text';
|
$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->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';
|
$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->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;
|
HTMLBLOC;
|
||||||
|
|
||||||
$this->Controller->EmailTest->sendAs = 'text';
|
$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->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';
|
$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->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';
|
$this->Controller->EmailTest->sendAs = 'both';
|
||||||
$expect = str_replace('{CONTENTTYPE}', 'multipart/mixed; boundary="{boundary}"', $header);
|
$expects = str_replace('{CONTENTTYPE}', 'multipart/mixed; boundary="{boundary}"', $header);
|
||||||
$expect .= "--{boundary}\n" .
|
$expects .= "--{boundary}\n" .
|
||||||
'Content-Type: multipart/alternative; boundary="alt-{boundary}"' . "\n\n" .
|
'Content-Type: multipart/alternative; boundary="alt-{boundary}"' . "\n\n" .
|
||||||
'--alt-{boundary}' . "\n" .
|
'--alt-{boundary}' . "\n" .
|
||||||
'Content-Type: text/plain; charset=UTF-8' . "\n" .
|
'Content-Type: text/plain; charset=UTF-8' . "\n" .
|
||||||
|
@ -288,11 +288,11 @@ HTMLBLOC;
|
||||||
'--alt-{boundary}--' . "\n\n\n" .
|
'--alt-{boundary}--' . "\n\n\n" .
|
||||||
'--{boundary}--' . "\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->assertTrue($this->Controller->EmailTest->send('This is the body of the message'));
|
||||||
$this->assertTextEquals(
|
$this->assertTextEquals(
|
||||||
$expect,
|
$expects,
|
||||||
preg_replace('/[a-z0-9]{32}/i', '{boundary}', DebugCompTransport::$lastEmail)
|
preg_replace('/[a-z0-9]{32}/i', '{boundary}', DebugCompTransport::$lastEmail)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -313,9 +313,9 @@ HTMLBLOC;
|
||||||
HTMLBLOC;
|
HTMLBLOC;
|
||||||
|
|
||||||
$this->Controller->EmailTest->sendAs = 'html';
|
$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->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>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<title><?php echo $title_for_layout; ?></title>
|
<title><?php echo $this->fetch('title'); ?></title>
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<title><?php echo $title_for_layout; ?></title>
|
<title><?php echo $this->fetch('title'); ?></title>
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<title><?php echo $title_for_layout; ?></title>
|
<title><?php echo $this->fetch('title'); ?></title>
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||||
<head>
|
<head>
|
||||||
<title><?php echo $title_for_layout; ?></title>
|
<title><?php echo $this->fetch('title'); ?></title>
|
||||||
<!--nocache--><?php $x = 1; ?><!--/nocache-->
|
<!--nocache--><?php $x = 1; ?><!--/nocache-->
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
|
|
@ -10,7 +10,7 @@ $cakeDescription = __d('cake_dev', 'CakePHP: the rapid development php framework
|
||||||
<?php echo $this->Html->charset(); ?>
|
<?php echo $this->Html->charset(); ?>
|
||||||
<title>
|
<title>
|
||||||
<?php echo $cakeDescription ?>:
|
<?php echo $cakeDescription ?>:
|
||||||
<?php echo $title_for_layout; ?>
|
<?php echo $this->fetch('title'); ?>
|
||||||
</title>
|
</title>
|
||||||
<?php
|
<?php
|
||||||
echo $this->Html->meta('icon');
|
echo $this->Html->meta('icon');
|
||||||
|
|
|
@ -5,7 +5,7 @@ if (!isset($channel)) {
|
||||||
$channel = array();
|
$channel = array();
|
||||||
}
|
}
|
||||||
if (!isset($channel['title'])) {
|
if (!isset($channel['title'])) {
|
||||||
$channel['title'] = $title_for_layout;
|
$channel['title'] = $this->fetch('title');
|
||||||
}
|
}
|
||||||
|
|
||||||
echo $this->Rss->document(
|
echo $this->Rss->document(
|
||||||
|
|
|
@ -452,7 +452,6 @@ class View extends Object {
|
||||||
if ($this->hasRendered) {
|
if ($this->hasRendered) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
$this->Blocks->set('content', '');
|
|
||||||
|
|
||||||
if ($view !== false && $viewFileName = $this->_getViewFileName($view)) {
|
if ($view !== false && $viewFileName = $this->_getViewFileName($view)) {
|
||||||
$this->_currentType = self::TYPE_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.
|
* - `$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
|
* Use the block features instead. `meta`, `css` and `script` will be populated
|
||||||
* by the matching methods on HtmlHelper.
|
* 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.
|
* - `$content_for_layout` is deprecated and will be removed in CakePHP 3.0.
|
||||||
* Use the `content` block instead.
|
* Use the `content` block instead.
|
||||||
*
|
*
|
||||||
|
@ -515,9 +515,16 @@ class View extends Object {
|
||||||
'scripts_for_layout' => $scripts,
|
'scripts_for_layout' => $scripts,
|
||||||
));
|
));
|
||||||
|
|
||||||
if (!isset($this->viewVars['title_for_layout'])) {
|
$title = $this->Blocks->get('title');
|
||||||
$this->viewVars['title_for_layout'] = Inflector::humanize($this->viewPath);
|
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->_currentType = self::TYPE_LAYOUT;
|
||||||
$this->Blocks->set('content', $this->_render($layoutFileName));
|
$this->Blocks->set('content', $this->_render($layoutFileName));
|
||||||
|
|
Loading…
Reference in a new issue