From 87f5b6cf26b1a6efaf6be228bb9f70032f9f0212 Mon Sep 17 00:00:00 2001 From: mark_story Date: Sun, 13 Nov 2011 20:47:55 -0500 Subject: [PATCH] Fix more strict errors. Fix strict errors in test files. Remove a test in CakeEmail as array -> string causes a notice in PHP 5.4 --- lib/Cake/Network/Email/CakeEmail.php | 4 ++-- lib/Cake/Network/Email/SmtpTransport.php | 3 ++- lib/Cake/Test/Case/Model/Datasource/DboSourceTest.php | 4 ++-- lib/Cake/Test/Case/Network/Email/CakeEmailTest.php | 4 ---- .../test_app/Model/Datasource/Test2OtherSource.php | 10 +++++----- .../Test/test_app/Model/Datasource/Test2Source.php | 10 +++++----- .../TestPlugin/Model/Datasource/test_other_source.php | 10 +++++----- 7 files changed, 21 insertions(+), 24 deletions(-) diff --git a/lib/Cake/Network/Email/CakeEmail.php b/lib/Cake/Network/Email/CakeEmail.php index 8690624ef..3bcdb3338 100644 --- a/lib/Cake/Network/Email/CakeEmail.php +++ b/lib/Cake/Network/Email/CakeEmail.php @@ -546,9 +546,9 @@ class CakeEmail { } /** - * Set Subject + * Get/Set Subject. * - * @param string $subject + * @param null|string $subject * @return mixed */ public function subject($subject = null) { diff --git a/lib/Cake/Network/Email/SmtpTransport.php b/lib/Cake/Network/Email/SmtpTransport.php index cc58bdd96..e6bb9544f 100644 --- a/lib/Cake/Network/Email/SmtpTransport.php +++ b/lib/Cake/Network/Email/SmtpTransport.php @@ -214,7 +214,8 @@ class SmtpTransport extends AbstractTransport { if (substr($response, -2) !== "\r\n") { throw new SocketException(__d('cake_dev', 'SMTP timeout.')); } - $response = end(explode("\r\n", rtrim($response, "\r\n"))); + $responseLines = explode("\r\n", rtrim($response, "\r\n")); + $response = end($responseLines); if (preg_match('/^(' . $checkCode . ')(.)/', $response, $code)) { if ($code[2] === '-') { diff --git a/lib/Cake/Test/Case/Model/Datasource/DboSourceTest.php b/lib/Cake/Test/Case/Model/Datasource/DboSourceTest.php index 85aaf03e3..02182fe2f 100644 --- a/lib/Cake/Test/Case/Model/Datasource/DboSourceTest.php +++ b/lib/Cake/Test/Case/Model/Datasource/DboSourceTest.php @@ -733,11 +733,11 @@ class DboSourceTest extends CakeTestCase { */ public function testFieldsUsingMethodCache() { $this->testDb->cacheMethods = false; - $this->assertTrue(empty($this->testDb->methodCache['fields']), 'Cache not empty'); + DboTestSource::$methodCache = array(); $Article = ClassRegistry::init('Article'); $this->testDb->fields($Article, null, array('title', 'body', 'published')); - $this->assertTrue(empty($this->testDb->methodCache['fields']), 'Cache not empty'); + $this->assertTrue(empty(DboTestSource::$methodCache['fields']), 'Cache not empty'); } /** diff --git a/lib/Cake/Test/Case/Network/Email/CakeEmailTest.php b/lib/Cake/Test/Case/Network/Email/CakeEmailTest.php index fdd2f9b9c..6711b2823 100644 --- a/lib/Cake/Test/Case/Network/Email/CakeEmailTest.php +++ b/lib/Cake/Test/Case/Network/Email/CakeEmailTest.php @@ -390,10 +390,6 @@ class CakeEmailTest extends CakeTestCase { $this->CakeEmail->subject(1); $this->assertIdentical($this->CakeEmail->subject(), '1'); - $result = $this->CakeEmail->subject(array('something')); - $this->assertIdentical($this->CakeEmail->subject(), 'Array'); - $this->assertIdentical($this->CakeEmail, $result); - $this->CakeEmail->subject('هذه رسالة بعنوان طويل مرسل للمستلم'); $expected = '=?UTF-8?B?2YfYsNmHINix2LPYp9mE2Kkg2KjYudmG2YjYp9mGINi32YjZitmEINmF2LE=?=' . "\r\n" . ' =?UTF-8?B?2LPZhCDZhNmE2YXYs9iq2YTZhQ==?='; $this->assertIdentical($this->CakeEmail->subject(), $expected); diff --git a/lib/Cake/Test/test_app/Model/Datasource/Test2OtherSource.php b/lib/Cake/Test/test_app/Model/Datasource/Test2OtherSource.php index e9d3bfaf0..88168229a 100644 --- a/lib/Cake/Test/test_app/Model/Datasource/Test2OtherSource.php +++ b/lib/Cake/Test/test_app/Model/Datasource/Test2OtherSource.php @@ -5,23 +5,23 @@ class Test2OtherSource extends DataSource { return compact('model'); } - public function listSources() { + public function listSources($data = null) { return array('test_source'); } - public function create($model, $fields = array(), $values = array()) { + public function create(Model $model, $fields = null, $values = null) { return compact('model', 'fields', 'values'); } - public function read($model, $queryData = array()) { + public function read(Model $model, $queryData = array()) { return compact('model', 'queryData'); } - public function update($model, $fields = array(), $values = array()) { + public function update(Model $model, $fields = array(), $values = array()) { return compact('model', 'fields', 'values'); } - public function delete($model, $id) { + public function delete(Model $model, $id = null) { return compact('model', 'id'); } } diff --git a/lib/Cake/Test/test_app/Model/Datasource/Test2Source.php b/lib/Cake/Test/test_app/Model/Datasource/Test2Source.php index bab312502..bb9f1dc80 100644 --- a/lib/Cake/Test/test_app/Model/Datasource/Test2Source.php +++ b/lib/Cake/Test/test_app/Model/Datasource/Test2Source.php @@ -5,23 +5,23 @@ class Test2Source extends DataSource { return compact('model'); } - public function listSources() { + public function listSources($data = null) { return array('test_source'); } - public function create($model, $fields = array(), $values = array()) { + public function create(Model $model, $fields = null, $values = null) { return compact('model', 'fields', 'values'); } - public function read($model, $queryData = array()) { + public function read(Model $model, $queryData = array()) { return compact('model', 'queryData'); } - public function update($model, $fields = array(), $values = array()) { + public function update(Model $model, $fields = array(), $values = array()) { return compact('model', 'fields', 'values'); } - public function delete($model, $id) { + public function delete(Model $model, $id = null) { return compact('model', 'id'); } } diff --git a/lib/Cake/Test/test_app/Plugin/TestPlugin/Model/Datasource/test_other_source.php b/lib/Cake/Test/test_app/Plugin/TestPlugin/Model/Datasource/test_other_source.php index d3b77ce01..7ab6febca 100644 --- a/lib/Cake/Test/test_app/Plugin/TestPlugin/Model/Datasource/test_other_source.php +++ b/lib/Cake/Test/test_app/Plugin/TestPlugin/Model/Datasource/test_other_source.php @@ -5,23 +5,23 @@ class TestOtherSource extends DataSource { return compact('model'); } - public function listSources() { + public function listSources($data = null) { return array('test_source'); } - public function create($model, $fields = array(), $values = array()) { + public function create(Model $model, $fields = null, $values = array()) { return compact('model', 'fields', 'values'); } - public function read($model, $queryData = array()) { + public function read(Model $model, $queryData = array()) { return compact('model', 'queryData'); } - public function update($model, $fields = array(), $values = array()) { + public function update(Model $model, $fields = array(), $values = array()) { return compact('model', 'fields', 'values'); } - public function delete($model, $id) { + public function delete(Model $model, $id = null) { return compact('model', 'id'); } }