diff --git a/app/View/Layouts/Emails/html/default.ctp b/app/View/Layouts/Emails/html/default.ctp index 4d360d908..e574a9ba1 100644 --- a/app/View/Layouts/Emails/html/default.ctp +++ b/app/View/Layouts/Emails/html/default.ctp @@ -22,7 +22,7 @@ <?php echo $title_for_layout;?> - + fetch('content');?>

This email was sent using the CakePHP Framework

diff --git a/app/View/Layouts/Emails/text/default.ctp b/app/View/Layouts/Emails/text/default.ctp index 94ed22249..c2a683a7c 100644 --- a/app/View/Layouts/Emails/text/default.ctp +++ b/app/View/Layouts/Emails/text/default.ctp @@ -16,6 +16,6 @@ * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ ?> - +fetch('content');?> This email was sent using the CakePHP Framework, http://cakephp.org. diff --git a/lib/Cake/Configure/IniReader.php b/lib/Cake/Configure/IniReader.php index debd685c6..f8fe2077f 100644 --- a/lib/Cake/Configure/IniReader.php +++ b/lib/Cake/Configure/IniReader.php @@ -142,6 +142,7 @@ class IniReader implements ConfigReaderInterface { * Dumps the state of Configure data into an ini formatted string. * * @param string $filename The filename on $this->_path to save into. + * Extension ".ini" will be automatically appended if not included in filename. * @param array $data The data to convert to ini file. * @return int Bytes saved. */ @@ -159,6 +160,10 @@ class IniReader implements ConfigReaderInterface { } } $contents = join("\n", $result); + + if (substr($filename, -4) !== '.ini') { + $filename .= '.ini'; + } return file_put_contents($this->_path . $filename, $contents); } diff --git a/lib/Cake/Configure/PhpReader.php b/lib/Cake/Configure/PhpReader.php index f5d961961..32d1f5264 100644 --- a/lib/Cake/Configure/PhpReader.php +++ b/lib/Cake/Configure/PhpReader.php @@ -92,11 +92,16 @@ class PhpReader implements ConfigReaderInterface { * be used saved into a file and loaded later. * * @param string $filename The filename to create on $this->_path. + * Extension ".php" will be automatically appended if not included in filename. * @param array $data Data to dump. * @return int Bytes saved. */ public function dump($filename, $data) { $contents = '_path . $filename, $contents); } diff --git a/lib/Cake/Console/Command/Task/TestTask.php b/lib/Cake/Console/Command/Task/TestTask.php index b49296ee1..edee2d21b 100644 --- a/lib/Cake/Console/Command/Task/TestTask.php +++ b/lib/Cake/Console/Command/Task/TestTask.php @@ -54,6 +54,21 @@ class TestTask extends BakeTask { 'Helper' => 'View/Helper' ); +/** + * Mapping between packages, and their baseclass + package. + * This is used to generate App::uses() call to autoload base + * classes if a developer has forgotten to do so. + * + * @var array + */ + public $baseTypes = array( + 'Model' => array('Model', 'Model'), + 'Behavior' => array('ModelBehavior', 'Model'), + 'Controller' => array('Controller', 'Controller'), + 'Component' => array('Component', 'Controller'), + 'Helper' => array('Helper', 'View') + ); + /** * Internal list of fixtures that have been added so far. * @@ -132,6 +147,8 @@ class TestTask extends BakeTask { } elseif ($this->interactive) { $this->getUserFixtures(); } + list($baseClass, $baseType) = $this->getBaseType($type); + App::uses($baseClass, $baseType); App::uses($fullClassName, $realType); $methods = array(); @@ -311,6 +328,20 @@ class TestTask extends BakeTask { return $real; } +/** + * Get the base class and package name for a given type. + * + * @param string $package The package the class having a test + * generated for is in. + * @return array Array of class, type) + */ + public function getBaseType($type) { + if (empty($this->baseTypes[$type])) { + throw new CakeException(__d('cake_dev', 'Invalid package name')); + } + return $this->baseTypes[$type]; + } + /** * Get methods declared in the class given. * No parent methods will be returned diff --git a/lib/Cake/Controller/Component/RequestHandlerComponent.php b/lib/Cake/Controller/Component/RequestHandlerComponent.php index ee90814b3..89b2ca6cf 100644 --- a/lib/Cake/Controller/Component/RequestHandlerComponent.php +++ b/lib/Cake/Controller/Component/RequestHandlerComponent.php @@ -232,6 +232,7 @@ class RequestHandlerComponent extends Component { /** * Handles (fakes) redirects for Ajax requests using requestAction() + * Modifies the $_POST and $_SERVER['REQUEST_METHOD'] to simulate a new GET request. * * @param Controller $controller A reference to the controller * @param string|array $url A string or array containing the redirect location @@ -243,6 +244,7 @@ class RequestHandlerComponent extends Component { if (!$this->request->is('ajax')) { return; } + $_SERVER['REQUEST_METHOD'] = 'GET'; foreach ($_POST as $key => $val) { unset($_POST[$key]); } diff --git a/lib/Cake/Network/CakeRequest.php b/lib/Cake/Network/CakeRequest.php index cadbbbd0c..1ac08cf8f 100644 --- a/lib/Cake/Network/CakeRequest.php +++ b/lib/Cake/Network/CakeRequest.php @@ -165,7 +165,7 @@ class CakeRequest implements ArrayAccess { $this->data = $_POST; } elseif ($this->is('put') || $this->is('delete')) { $this->data = $this->_readInput(); - if (env('CONTENT_TYPE') === 'application/x-www-form-urlencoded') { + if (strpos(env('CONTENT_TYPE'), 'application/x-www-form-urlencoded') === 0) { parse_str($this->data, $this->data); } } diff --git a/lib/Cake/Test/Case/Configure/IniReaderTest.php b/lib/Cake/Test/Case/Configure/IniReaderTest.php index e4b463450..dd1f087b4 100644 --- a/lib/Cake/Test/Case/Configure/IniReaderTest.php +++ b/lib/Cake/Test/Case/Configure/IniReaderTest.php @@ -166,6 +166,13 @@ INI; unlink($file); $this->assertTextEquals($expected, $result); + + $result = $reader->dump('test', $this->testData); + $this->assertTrue($result > 0); + + $contents = file_get_contents($file); + $this->assertTextEquals($expected, $contents); + unlink($file); } /** diff --git a/lib/Cake/Test/Case/Configure/PhpReaderTest.php b/lib/Cake/Test/Case/Configure/PhpReaderTest.php index 08982cb4e..59d4d5178 100644 --- a/lib/Cake/Test/Case/Configure/PhpReaderTest.php +++ b/lib/Cake/Test/Case/Configure/PhpReaderTest.php @@ -151,6 +151,13 @@ PHP; unlink($file); $this->assertTextEquals($expected, $contents); + + $result = $reader->dump('test', $this->testData); + $this->assertTrue($result > 0); + + $contents = file_get_contents($file); + $this->assertTextEquals($expected, $contents); + unlink($file); } /** diff --git a/lib/Cake/Test/Case/I18n/I18nTest.php b/lib/Cake/Test/Case/I18n/I18nTest.php index e86628bb4..637494012 100644 --- a/lib/Cake/Test/Case/I18n/I18nTest.php +++ b/lib/Cake/Test/Case/I18n/I18nTest.php @@ -31,6 +31,8 @@ class I18nTest extends CakeTestCase { * @return void */ public function setUp() { + parent::setUp(); + Cache::delete('object_map', '_cake_core_'); App::build(array( 'Locale' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'Locale' . DS), @@ -45,6 +47,8 @@ class I18nTest extends CakeTestCase { * @return void */ public function tearDown() { + parent::tearDown(); + Cache::delete('object_map', '_cake_core_'); App::build(); CakePlugin::unload(); diff --git a/lib/Cake/Test/Case/Network/CakeRequestTest.php b/lib/Cake/Test/Case/Network/CakeRequestTest.php index 8ef0e1868..86f6f6039 100644 --- a/lib/Cake/Test/Case/Network/CakeRequestTest.php +++ b/lib/Cake/Test/Case/Network/CakeRequestTest.php @@ -233,7 +233,7 @@ class CakeRequestTest extends CakeTestCase { */ public function testPutParsing() { $_SERVER['REQUEST_METHOD'] = 'PUT'; - $_SERVER['CONTENT_TYPE'] = 'application/x-www-form-urlencoded'; + $_SERVER['CONTENT_TYPE'] = 'application/x-www-form-urlencoded; charset=UTF-8'; $data = array('data' => array( 'Article' => array('title') diff --git a/lib/Cake/Test/Case/View/Helper/JsHelperTest.php b/lib/Cake/Test/Case/View/Helper/JsHelperTest.php index 8589850a8..950e5c221 100644 --- a/lib/Cake/Test/Case/View/Helper/JsHelperTest.php +++ b/lib/Cake/Test/Case/View/Helper/JsHelperTest.php @@ -123,7 +123,8 @@ class JsHelperTest extends CakeTestCase { * @return void */ public function setUp() { - $this->_asset = Configure::read('Asset.timestamp'); + parent::setUp(); + Configure::write('Asset.timestamp', false); $controller = null; @@ -146,7 +147,7 @@ class JsHelperTest extends CakeTestCase { * @return void */ public function tearDown() { - Configure::write('Asset.timestamp', $this->_asset); + parent::tearDown(); unset($this->Js); } @@ -351,6 +352,7 @@ class JsHelperTest extends CakeTestCase { public function testWriteScriptsInFile() { $this->skipIf(!is_writable(JS), 'webroot/js is not Writable, script caching test has been skipped.'); + Configure::write('Cache.disable', false); $this->Js->request->webroot = '/'; $this->Js->JsBaseEngine = new TestJsEngineHelper($this->View); $this->Js->buffer('one = 1;'); @@ -364,8 +366,14 @@ class JsHelperTest extends CakeTestCase { $this->assertTrue(file_exists(WWW_ROOT . $filename[1])); $contents = file_get_contents(WWW_ROOT . $filename[1]); $this->assertRegExp('/one\s=\s1;\ntwo\s=\s2;/', $contents); - @unlink(WWW_ROOT . $filename[1]); + + Configure::write('Cache.disable', true); + $this->Js->buffer('one = 1;'); + $this->Js->buffer('two = 2;'); + $result = $this->Js->writeBuffer(array('onDomReady' => false, 'cache' => true)); + $this->assertRegExp('/one\s=\s1;\ntwo\s=\s2;/', $result); + $this->assertFalse(file_exists(WWW_ROOT . $filename[1])); } /** diff --git a/lib/Cake/View/Helper/JsHelper.php b/lib/Cake/View/Helper/JsHelper.php index 5490fbb36..93343dde1 100644 --- a/lib/Cake/View/Helper/JsHelper.php +++ b/lib/Cake/View/Helper/JsHelper.php @@ -208,18 +208,19 @@ class JsHelper extends AppHelper { $opts = $options; unset($opts['onDomReady'], $opts['cache'], $opts['clear']); - if (!$options['cache'] && $options['inline']) { - return $this->Html->scriptBlock($script, $opts); - } - if ($options['cache'] && $options['inline']) { $filename = md5($script); - if (!file_exists(JS . $filename . '.js')) { - cache(str_replace(WWW_ROOT, '', JS) . $filename . '.js', $script, '+999 days', 'public'); + if (file_exists(JS . $filename . '.js') + || cache(str_replace(WWW_ROOT, '', JS) . $filename . '.js', $script, '+999 days', 'public') + ) { + return $this->Html->script($filename); } - return $this->Html->script($filename); } - $this->Html->scriptBlock($script, $opts); + + $return = $this->Html->scriptBlock($script, $opts); + if ($options['inline']) { + return $return; + } return null; }