Skip to content

Commit

Permalink
Merge branch '3.0' into 3.0-model
Browse files Browse the repository at this point in the history
  • Loading branch information
markstory committed Jun 12, 2013
2 parents 4860ed3 + a163e32 commit 48bb198
Show file tree
Hide file tree
Showing 16 changed files with 71 additions and 39 deletions.
24 changes: 24 additions & 0 deletions lib/Cake/Database/Exception.php
@@ -0,0 +1,24 @@
<?php
/**
* PHP Version 5.4
*
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
* Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
*
* Licensed under The MIT License
* For full copyright and license information, please see the LICENSE.txt
* Redistributions of files must retain the above copyright notice.
*
* @copyright Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
* @link http://cakephp.org CakePHP(tm) Project
* @since CakePHP(tm) v 3.0.0
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
namespace Cake\Database;

/**
* Exception for the database package.
*/
class Exception extends \Cake\Error\Exception {

}
3 changes: 2 additions & 1 deletion lib/Cake/Database/Schema/Table.php
Expand Up @@ -16,8 +16,8 @@
*/
namespace Cake\Database\Schema;

use Cake\Database\Exception;
use Cake\Database\Connection;
use Cake\Database\Exception;

/**
* Represents a single table in a database schema.
Expand Down Expand Up @@ -331,6 +331,7 @@ public function addConstraint($name, $attrs) {
*
* @param array $attrs Attributes to set.
* @return array
* @throw Cake\Database\Exception When foreign key definition is not valid.
*/
protected function _checkForeignKey($attrs) {
if (count($attrs['references']) < 2) {
Expand Down
3 changes: 2 additions & 1 deletion lib/Cake/Network/Email/Email.php
Expand Up @@ -20,6 +20,7 @@
use Cake\Error;
use Cake\Log\Log;
use Cake\Network\Http\FormData\Part;
use Cake\Utility\File;
use Cake\Utility\Hash;
use Cake\Utility\String;
use Cake\Utility\Validation;
Expand Down Expand Up @@ -1251,7 +1252,7 @@ protected function _wrap($message, $wrapLength = Email::LINE_LENGTH_MUST) {
$message = str_replace(array("\r\n", "\r"), "\n", $message);
$lines = explode("\n", $message);
$formatted = array();
$cut = ($wrapLength == CakeEmail::LINE_LENGTH_MUST) ? true : false;
$cut = ($wrapLength == Email::LINE_LENGTH_MUST) ? true : false;

foreach ($lines as $line) {
if (empty($line)) {
Expand Down
2 changes: 1 addition & 1 deletion lib/Cake/Routing/Route/RedirectRoute.php
Expand Up @@ -16,8 +16,8 @@
namespace Cake\Routing\Route;

use Cake\Network\Response;
use Cake\Routing\Route\Route;
use Cake\Routing\Router;
use Cake\Routing\Route\Route;

/**
* Redirect route will perform an immediate redirect. Redirect routes
Expand Down
15 changes: 15 additions & 0 deletions lib/Cake/Test/TestApp/View/Emails/html/html.ctp
@@ -0,0 +1,15 @@
<?php
use Cake\Network\Email\Email;
?>
<h1>HTML Ipsum Presents</h1><p><strong>Pellentesque habitant morbi tristique</strong> senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. <em>Aenean ultricies mi vitae est.</em> Mauris placerat eleifend leo. Quisque sit amet est et sapien ullamcorper pharetra. Vestibulum erat wisi, condimentum sed, <code>commodo vitae</code>, ornare sit amet, wisi. Aenean fermentum, elit eget tincidunt condimentum, eros ipsum rutrum orci, sagittis tempus lacus enim ac dui. <a href="#">Donec non enim</a> in turpis pulvinar facilisis. Ut felis.</p><h2>Header Level 2</h2><ol><li>Lorem ipsum dolor sit amet, consectetuer adipiscing elit.</li><li>Aliquam tincidunt mauris eu risus.</li></ol><blockquote><p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus magna. Cras in mi at felis aliquet congue. Ut a est eget ligula molestie gravida. Curabitur massa. Donec eleifend, libero at sagittis mollis, tellus est malesuada tellus, at luctus turpis elit sit amet quam. Vivamus pretium ornare est.</p></blockquote><h3>Header Level 3</h3><ul><li>Lorem ipsum dolor sit amet, consectetuer adipiscing elit.</li><li>Aliquam tincidunt mauris eu risus.</li></ul>
<pre><code>
#header h1 a {
display: block;
width: 300px;
height: 80px;
}</code></pre>
<table>
<th align="right" valign="top"
style="font-weight: bold">The tag is across multiple lines - <?php echo str_repeat('x', Email::LINE_LENGTH_MUST); ?></th>
</table>
<p>Some more <?php echo str_repeat('x', Email::LINE_LENGTH_MUST); ?> <b>Bold</b> test.</p>
2 changes: 1 addition & 1 deletion lib/Cake/Test/TestCase/Controller/PagesControllerTest.php
Expand Up @@ -19,7 +19,7 @@
*/
namespace Cake\Test\TestCase\Controller;

use \App\Controller\PagesController;
use App\Controller\PagesController;
use Cake\Core\App;
use Cake\Network\Request;
use Cake\Network\Response;
Expand Down
2 changes: 1 addition & 1 deletion lib/Cake/Test/TestCase/Database/Schema/CollectionTest.php
Expand Up @@ -18,8 +18,8 @@

use Cake\Core\Configure;
use Cake\Database\Connection;
use Cake\Database\Schema\Table;
use Cake\Database\Schema\Collection;
use Cake\Database\Schema\Table;
use Cake\TestSuite\TestCase;

/**
Expand Down
1 change: 0 additions & 1 deletion lib/Cake/Test/TestCase/Database/Schema/MysqlSchemaTest.php
Expand Up @@ -23,7 +23,6 @@
use Cake\Database\Schema\Table;
use Cake\TestSuite\TestCase;


/**
* Test case for Mysql Schema Dialect.
*/
Expand Down
2 changes: 0 additions & 2 deletions lib/Cake/Test/TestCase/Database/Schema/SqliteSchemaTest.php
Expand Up @@ -23,7 +23,6 @@
use Cake\Database\Schema\Table;
use Cake\TestSuite\TestCase;


/**
* Test case for Sqlite Schema Dialect.
*/
Expand Down Expand Up @@ -606,7 +605,6 @@ public function testCreateSql() {
);
}


/**
* test dropSql
*
Expand Down
3 changes: 1 addition & 2 deletions lib/Cake/Test/TestCase/Database/Schema/TableTest.php
Expand Up @@ -250,8 +250,7 @@ public function testAddConstraintForeignKey() {
*
* @return array
*/
public static function badForeignKeyProvider()
{
public static function badForeignKeyProvider() {
return [
'references is bad' => [[
'type' => Table::CONSTRAINT_FOREIGN,
Expand Down
32 changes: 15 additions & 17 deletions lib/Cake/Test/TestCase/Network/Email/EmailTest.php
Expand Up @@ -42,7 +42,7 @@ public function formatAddress($address) {
* Wrap to protected method
*
*/
public function wrap($text, $length = CakeEmail::LINE_LENGTH_MUST) {
public function wrap($text, $length = Email::LINE_LENGTH_MUST) {
return parent::_wrap($text, $length);
}

Expand Down Expand Up @@ -1037,27 +1037,25 @@ public function testSendWithLog() {
* @return void
*/
public function testSendWithLogAndScope() {
CakeLog::config('email', array(
Configure::write('Log.email', array(
'engine' => 'FileLog',
'path' => TMP,
'types' => array('cake_test_emails'),
'file' => 'cake_test_emails',
'scopes' => array('email')
));
CakeLog::drop('default');
Log::reset();
$this->CakeEmail->transport('Debug');
$this->CakeEmail->to('me@cakephp.org');
$this->CakeEmail->from('cake@cakephp.org');
$this->CakeEmail->subject('My title');
$this->CakeEmail->config(array('log' => array('level' => 'cake_test_emails', 'scope' => 'email')));
$this->CakeEmail->config(array('log' => array('scope' => 'email')));
$result = $this->CakeEmail->send("Logging This");

App::uses('File', 'Utility');
$File = new File(TMP . 'cake_test_emails.log');
$log = $File->read();
$this->assertTrue(strpos($log, $result['headers']) !== false);
$this->assertTrue(strpos($log, $result['message']) !== false);
$File->delete();
CakeLog::drop('email');
}

/**
Expand Down Expand Up @@ -1920,7 +1918,7 @@ protected function _getEmailByNewStyleCharset($charset, $headerCharset) {
}

public function testWrapLongLine() {
$message = '<a href="http://cakephp.org">' . str_repeat('x', CakeEmail::LINE_LENGTH_MUST) . "</a>";
$message = '<a href="http://cakephp.org">' . str_repeat('x', Email::LINE_LENGTH_MUST) . "</a>";

$this->CakeEmail->reset();
$this->CakeEmail->transport('Debug');
Expand All @@ -1929,32 +1927,32 @@ public function testWrapLongLine() {
$this->CakeEmail->subject('Wordwrap Test');
$this->CakeEmail->config(array('empty'));
$result = $this->CakeEmail->send($message);
$expected = "<a\r\n" . 'href="http://cakephp.org">' . str_repeat('x', CakeEmail::LINE_LENGTH_MUST - 26) . "\r\n" .
$expected = "<a\r\n" . 'href="http://cakephp.org">' . str_repeat('x', Email::LINE_LENGTH_MUST - 26) . "\r\n" .
str_repeat('x', 26) . "\r\n</a>\r\n\r\n";
$this->assertEquals($expected, $result['message']);
$this->assertLineLengths($result['message']);

$str1 = "a ";
$str2 = " b";
$length = strlen($str1) + strlen($str2);
$message = $str1 . str_repeat('x', CakeEmail::LINE_LENGTH_MUST - $length - 1) . $str2;
$message = $str1 . str_repeat('x', Email::LINE_LENGTH_MUST - $length - 1) . $str2;

$result = $this->CakeEmail->send($message);
$expected = "{$message}\r\n\r\n";
$this->assertEquals($expected, $result['message']);
$this->assertLineLengths($result['message']);

$message = $str1 . str_repeat('x', CakeEmail::LINE_LENGTH_MUST - $length) . $str2;
$message = $str1 . str_repeat('x', Email::LINE_LENGTH_MUST - $length) . $str2;

$result = $this->CakeEmail->send($message);
$expected = "{$message}\r\n\r\n";
$this->assertEquals($expected, $result['message']);
$this->assertLineLengths($result['message']);

$message = $str1 . str_repeat('x', CakeEmail::LINE_LENGTH_MUST - $length + 1) . $str2;
$message = $str1 . str_repeat('x', Email::LINE_LENGTH_MUST - $length + 1) . $str2;

$result = $this->CakeEmail->send($message);
$expected = $str1 . str_repeat('x', CakeEmail::LINE_LENGTH_MUST - $length + 1) . sprintf("\r\n%s\r\n\r\n", trim($str2));
$expected = $str1 . str_repeat('x', Email::LINE_LENGTH_MUST - $length + 1) . sprintf("\r\n%s\r\n\r\n", trim($str2));
$this->assertEquals($expected, $result['message']);
$this->assertLineLengths($result['message']);
}
Expand All @@ -1967,7 +1965,7 @@ public function testWrapWithTagsAcrossLines() {
</table>
HTML;
$length = strlen($str);
$message = $str . str_repeat('x', CakeEmail::LINE_LENGTH_MUST + 1);
$message = $str . str_repeat('x', Email::LINE_LENGTH_MUST + 1);

$this->CakeEmail->reset();
$this->CakeEmail->transport('Debug');
Expand All @@ -1986,7 +1984,7 @@ public function testWrapWithTagsAcrossLines() {
public function testWrapIncludeLessThanSign() {
$str = 'foo<bar';
$length = strlen($str);
$message = $str . str_repeat('x', CakeEmail::LINE_LENGTH_MUST - $length + 1);
$message = $str . str_repeat('x', Email::LINE_LENGTH_MUST - $length + 1);

$this->CakeEmail->reset();
$this->CakeEmail->transport('Debug');
Expand Down Expand Up @@ -2028,8 +2026,8 @@ public function testWrapForJapaneseEncoding() {
public function assertLineLengths($message) {
$lines = explode("\r\n", $message);
foreach ($lines as $line) {
$this->assertTrue(strlen($line) <= CakeEmail::LINE_LENGTH_MUST,
'Line length exceeds the max. limit of CakeEmail::LINE_LENGTH_MUST');
$this->assertTrue(strlen($line) <= Email::LINE_LENGTH_MUST,
'Line length exceeds the max. limit of Email::LINE_LENGTH_MUST');
}
}

Expand Down
6 changes: 3 additions & 3 deletions lib/Cake/Test/TestCase/Network/SocketTest.php
Expand Up @@ -136,7 +136,7 @@ public function testInvalidConnection($data) {
*/
public function testSocketHost() {
try {
$this->Socket = new CakeSocket();
$this->Socket = new Socket();
$this->Socket->connect();
$this->assertEquals('127.0.0.1', $this->Socket->address());
$this->assertEquals(gethostbyaddr('127.0.0.1'), $this->Socket->host());
Expand Down Expand Up @@ -180,7 +180,7 @@ public function testSocketReading() {
$this->assertEquals(null, $this->Socket->read(26));

$config = array('host' => 'google.com', 'port' => 80, 'timeout' => 1);
$this->Socket = new CakeSocket($config);
$this->Socket = new Socket($config);
$this->assertTrue($this->Socket->connect());
$this->assertEquals(null, $this->Socket->read(26));
$this->assertEquals('2: ' . __d('cake_dev', 'Connection timed out'), $this->Socket->lastError());
Expand All @@ -201,7 +201,7 @@ public function testTimeOutConnection() {
$this->assertTrue($this->Socket->connect());

$config = array('host' => '127.0.0.1', 'timeout' => 0.00001);
$this->Socket = new CakeSocket($config);
$this->Socket = new Socket($config);
$this->assertFalse($this->Socket->read(1024 * 1024));
$this->assertEquals('2: ' . __d('cake_dev', 'Connection timed out'), $this->Socket->lastError());
} catch (Error\SocketException $e) {
Expand Down
Expand Up @@ -21,8 +21,8 @@

use Cake\Core\App;
use Cake\Core\Configure;
use Cake\Routing\Route\PluginShortRoute;
use Cake\Routing\Router;
use Cake\Routing\Route\PluginShortRoute;
use Cake\TestSuite\TestCase;

/**
Expand Down
2 changes: 1 addition & 1 deletion lib/Cake/Test/TestCase/Routing/Route/RedirectRouteTest.php
Expand Up @@ -22,8 +22,8 @@
use Cake\Core\App;
use Cake\Core\Configure;
use Cake\Network\Response;
use Cake\Routing\Route\RedirectRoute;
use Cake\Routing\Router;
use Cake\Routing\Route\RedirectRoute;
use Cake\TestSuite\TestCase;

/**
Expand Down
10 changes: 3 additions & 7 deletions lib/Cake/Test/TestCase/Routing/RouterTest.php
Expand Up @@ -27,10 +27,6 @@
use Cake\Routing\Route\Route;
use Cake\TestSuite\TestCase;

if (!defined('FULL_BASE_URL')) {
define('FULL_BASE_URL', 'http://cakephp.org');
}

/**
* RouterTest class
*
Expand All @@ -47,6 +43,8 @@ public function setUp() {
parent::setUp();
Configure::write('Routing', array('admin' => null, 'prefixes' => array()));
Router::reload();
Router::baseURL('');
Configure::write('App.fullBaseURL', 'http://localhost');
}

/**
Expand All @@ -70,7 +68,6 @@ public function testFullBaseURL() {
$this->assertRegExp('/^http(s)?:\/\//', Router::url('/', true));
$this->assertRegExp('/^http(s)?:\/\//', Router::url(null, true));
$this->assertRegExp('/^http(s)?:\/\//', Router::url(array('_full' => true)));
$this->assertSame(FULL_BASE_URL . '/', Router::url(array('_full' => true)));
}

/**
Expand All @@ -79,7 +76,6 @@ public function testFullBaseURL() {
* @return void
*/
public function testBaseURL() {
$this->assertEquals(FULL_BASE_URL, Router::baseUrl());
Router::baseURL('http://example.com');
$this->assertEquals('http://example.com/', Router::url('/', true));
$this->assertEquals('http://example.com', Configure::read('App.fullBaseURL'));
Expand Down Expand Up @@ -2438,7 +2434,7 @@ public function testUrlProtocol() {
$this->assertEquals($url, Router::url($url));
$url = '/posts/index#here';

$expected = FULL_BASE_URL . '/posts/index#here';
$expected = Configure::read('App.fullBaseURL') . '/posts/index#here';
$this->assertEquals($expected, Router::url($url, true));
}

Expand Down
1 change: 1 addition & 0 deletions lib/Cake/TestSuite/Fixture/TestFixture.php
Expand Up @@ -178,6 +178,7 @@ protected function _schemaFromFields() {
* Build fixture schema from a table in another datasource.
*
* @return void
* @throws Cake\Error\Exception when trying to import from an empty table.
*/
protected function _schemaFromImport() {
if (!is_array($this->import)) {
Expand Down

0 comments on commit 48bb198

Please sign in to comment.