diff --git a/.editorconfig b/.editorconfig
new file mode 100644
index 00000000000..217a0e30cb6
--- /dev/null
+++ b/.editorconfig
@@ -0,0 +1,13 @@
+; This file is for unifying the coding style for different editors and IDEs.
+; More information at http://editorconfig.org
+
+root = true
+
+[*]
+indent_style = tab
+end_of_line = lf
+insert_final_newline = true
+trim_trailing_whitespace = true
+
+[*.bat]
+end_of_line = crlf
diff --git a/.travis.yml b/.travis.yml
index 5af60d8d8f0..f7705b81788 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -10,6 +10,16 @@ env:
- DB=pgsql
- DB=sqlite
+matrix:
+ allow_failures:
+ - php: 5.4
+ env:
+ - PHPCS=1
+ include:
+ - php: 5.4
+ env:
+ - PHPCS=1
+
before_script:
- sh -c "if [ '$DB' = 'mysql' ]; then mysql -e 'CREATE DATABASE cakephp_test;'; fi"
- sh -c "if [ '$DB' = 'mysql' ]; then mysql -e 'CREATE DATABASE cakephp_test2;'; fi"
@@ -23,6 +33,9 @@ before_script:
server.listen(80, 'localhost');
console.log('TCP server listening on port 80 at localhost.');" > app/tmp/socket.js
- sudo node ./app/tmp/socket.js &
+ - pear channel-discover pear.cakephp.org
+ - pear install --alldeps cakephp/CakePHP_CodeSniffer
+ - phpenv rehash
- set +H
- echo " app/Config/database.php
script:
- - ./lib/Cake/Console/cake test core AllTests --stderr
+ - sh -c "if [ '$PHPCS' != '1' ]; then ./lib/Cake/Console/cake test core AllTests --stderr; else phpcs --extensions=php --standard=CakePHP ./lib/Cake; fi"
notifications:
email: false
\ No newline at end of file
diff --git a/app/Config/Schema/i18n.php b/app/Config/Schema/i18n.php
index 8de0052ddcd..08aab843b08 100644
--- a/app/Config/Schema/i18n.php
+++ b/app/Config/Schema/i18n.php
@@ -19,14 +19,17 @@
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
+// @codingStandardsIgnoreStart
+
/*
*
* Using the Schema command line utility
* cake schema run create i18n
- *
*/
class i18nSchema extends CakeSchema {
+// @codingStandardsIgnoreEnd
+
public $name = 'i18n';
public function before($event = array()) {
diff --git a/app/Config/core.php b/app/Config/core.php
index 99198539f5d..e0527538d41 100644
--- a/app/Config/core.php
+++ b/app/Config/core.php
@@ -42,7 +42,8 @@
* Options:
*
* - `handler` - callback - The callback to handle errors. You can set this to any callable type,
- * including anonymous functions.
+ * including anonymous functions.
+ * Make sure you add App::uses('MyHandler', 'Error'); when using a custom handler class
* - `level` - int - The level of errors you are interested in capturing.
* - `trace` - boolean - Include stack traces for errors in log files.
*
@@ -64,6 +65,7 @@
*
* - `handler` - callback - The callback to handle exceptions. You can set this to any callback type,
* including anonymous functions.
+ * Make sure you add App::uses('MyHandler', 'Error'); when using a custom handler class
* - `renderer` - string - The class responsible for rendering uncaught exceptions. If you choose a custom class you
* should place the file for that class in app/Lib/Error. This class needs to implement a render method.
* - `log` - boolean - Should Exceptions be logged?
diff --git a/build.xml b/build.xml
index fca6ec4ae19..daf292fab59 100644
--- a/build.xml
+++ b/build.xml
@@ -40,6 +40,9 @@
Lorem ipsum dolor sit amet,
consectetur adipiscing elit.
Donec ac turpis orci, non commodo odio.
Morbi nibh nisi, vehicula pellentesque accumsan amet.
Lorem ipsum dolor sit amet,
consectetur adipiscing elit.
Donec ac',
'turpis orci, non commodo odio.
Morbi nibh nisi, vehicula',
@@ -1383,7 +1383,7 @@ public function testWrap() {
$this->assertSame($expected, $result);
$text = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec ac turpis orci, non commodo odio. Morbi nibh nisi, vehicula pellentesque accumsan amet.';
- $result = $this->CakeEmail->wrap($text);
+ $result = $this->CakeEmail->wrap($text, CakeEmail::LINE_LENGTH_SHOULD);
$expected = array(
'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec ac',
'turpis orci, non commodo odio. Morbi nibh',
@@ -1393,7 +1393,7 @@ public function testWrap() {
$this->assertSame($expected, $result);
$text = 'Lorem ipsum ok';
- $result = $this->CakeEmail->wrap($text);
+ $result = $this->CakeEmail->wrap($text, CakeEmail::LINE_LENGTH_SHOULD);
$expected = array(
'Lorem ipsum',
'',
@@ -1403,7 +1403,7 @@ public function testWrap() {
$this->assertSame($expected, $result);
$text = 'Lorem ipsum withonewordverybigMorethanthelineshouldsizeofrfcspecificationbyieeeavailableonieeesite ok.';
- $result = $this->CakeEmail->wrap($text);
+ $result = $this->CakeEmail->wrap($text, CakeEmail::LINE_LENGTH_SHOULD);
$expected = array(
'Lorem ipsum',
'withonewordverybigMorethanthelineshouldsizeofrfcspecificationbyieeeavailableonieeesite',
diff --git a/lib/Cake/Test/Case/Network/Http/HttpSocketTest.php b/lib/Cake/Test/Case/Network/Http/HttpSocketTest.php
index dfd7db98b21..a742adbed14 100644
--- a/lib/Cake/Test/Case/Network/Http/HttpSocketTest.php
+++ b/lib/Cake/Test/Case/Network/Http/HttpSocketTest.php
@@ -762,6 +762,38 @@ public function testRequestCustomResponse() {
$this->assertEquals('HTTP/1.x 2', $response->first10);
}
+/**
+ * Test that redirect urls are urldecoded
+ *
+ * @return void
+ */
+ public function testRequestWithRedirectUrlEncoded() {
+ $request = array(
+ 'uri' => 'http://localhost/oneuri',
+ 'redirect' => 1
+ );
+ $serverResponse1 = "HTTP/1.x 302 Found\r\nDate: Mon, 16 Apr 2007 04:14:16 GMT\r\nServer: CakeHttp Server\r\nContent-Type: text/html\r\nLocation: http://i.cmpnet.com%2Ftechonline%2Fpdf%2Fa.pdf=\r\n\r\n";
+ $serverResponse2 = "HTTP/1.x 200 OK\r\nDate: Mon, 16 Apr 2007 04:14:16 GMT\r\nServer: CakeHttp Server\r\nContent-Type: text/html\r\n\r\nYou have been redirected
";
+
+ $this->Socket->expects($this->at(1))
+ ->method('read')
+ ->will($this->returnValue($serverResponse1));
+
+ $this->Socket->expects($this->at(3))
+ ->method('write')
+ ->with($this->logicalAnd(
+ $this->stringContains('Host: i.cmpnet.com'),
+ $this->stringContains('GET /techonline/pdf/a.pdf')
+ ));
+
+ $this->Socket->expects($this->at(4))
+ ->method('read')
+ ->will($this->returnValue($serverResponse2));
+
+ $response = $this->Socket->request($request);
+ $this->assertEquals('You have been redirected
', $response->body());
+ }
+
/**
* testRequestWithRedirect method
*
@@ -781,6 +813,11 @@ public function testRequestWithRedirectAsTrue() {
$this->assertEquals('You have been redirected
', $response->body());
}
+/**
+ * Test that redirects with a count limit are decremented.
+ *
+ * @return void
+ */
public function testRequestWithRedirectAsInt() {
$request = array(
'uri' => 'http://localhost/oneuri',
@@ -795,6 +832,11 @@ public function testRequestWithRedirectAsInt() {
$this->assertEquals(1, $this->Socket->request['redirect']);
}
+/**
+ * Test that redirects after the redirect count reaches 9 are not followed.
+ *
+ * @return void
+ */
public function testRequestWithRedirectAsIntReachingZero() {
$request = array(
'uri' => 'http://localhost/oneuri',
@@ -1509,7 +1551,6 @@ public function testBuildHeader() {
* testBuildCookies method
*
* @return void
- * @todo Test more scenarios
*/
public function testBuildCookies() {
$cookies = array(
diff --git a/lib/Cake/Test/Case/Routing/DispatcherTest.php b/lib/Cake/Test/Case/Routing/DispatcherTest.php
index a0e3df7ba6d..cf0ce8752d5 100644
--- a/lib/Cake/Test/Case/Routing/DispatcherTest.php
+++ b/lib/Cake/Test/Case/Routing/DispatcherTest.php
@@ -1574,7 +1574,7 @@ public function testFullPageCachingDispatch($url) {
$this->assertTextEquals($out, $cached);
- $filename = $this->__cachePath($request->here());
+ $filename = $this->_cachePath($request->here());
unlink($filename);
}
@@ -1657,79 +1657,13 @@ public function testHttpMethodOverrides() {
unset($_POST['_method']);
}
-/**
- * backupEnvironment method
- *
- * @return void
- */
- protected function __backupEnvironment() {
- return array(
- 'App' => Configure::read('App'),
- 'GET' => $_GET,
- 'POST' => $_POST,
- 'SERVER' => $_SERVER
- );
- }
-
-/**
- * reloadEnvironment method
- *
- * @return void
- */
- protected function __reloadEnvironment() {
- foreach ($_GET as $key => $val) {
- unset($_GET[$key]);
- }
- foreach ($_POST as $key => $val) {
- unset($_POST[$key]);
- }
- foreach ($_SERVER as $key => $val) {
- unset($_SERVER[$key]);
- }
- Configure::write('App', array());
- }
-
-/**
- * loadEnvironment method
- *
- * @param array $env
- * @return void
- */
- protected function __loadEnvironment($env) {
- if ($env['reload']) {
- $this->__reloadEnvironment();
- }
-
- if (isset($env['App'])) {
- Configure::write('App', $env['App']);
- }
-
- if (isset($env['GET'])) {
- foreach ($env['GET'] as $key => $val) {
- $_GET[$key] = $val;
- }
- }
-
- if (isset($env['POST'])) {
- foreach ($env['POST'] as $key => $val) {
- $_POST[$key] = $val;
- }
- }
-
- if (isset($env['SERVER'])) {
- foreach ($env['SERVER'] as $key => $val) {
- $_SERVER[$key] = $val;
- }
- }
- }
-
/**
* cachePath method
*
* @param string $here
* @return string
*/
- protected function __cachePath($here) {
+ protected function _cachePath($here) {
$path = $here;
if ($here == '/') {
$path = 'home';
diff --git a/lib/Cake/Test/Case/Routing/RouterTest.php b/lib/Cake/Test/Case/Routing/RouterTest.php
index b4c956de04e..dd12924ceda 100644
--- a/lib/Cake/Test/Case/Routing/RouterTest.php
+++ b/lib/Cake/Test/Case/Routing/RouterTest.php
@@ -111,7 +111,7 @@ public function testMapResources() {
$_SERVER['REQUEST_METHOD'] = 'GET';
$result = Router::parse('/posts/add');
- $this->assertEquals(array(), $result);
+ $this->assertSame(array(), $result);
Router::reload();
$resources = Router::mapResources('Posts', array('id' => '[a-z0-9_]+'));
@@ -1538,7 +1538,6 @@ public function testNamedArgsUrlParsing() {
* test url generation with legacy (1.2) style prefix routes.
*
* @return void
- * @todo Remove tests related to legacy style routes.
* @see testUrlGenerationWithAutoPrefixes
*/
public function testUrlGenerationWithLegacyPrefixes() {
@@ -1907,7 +1906,7 @@ public function testParsingWithPatternOnAction() {
$this->assertEquals($expected, $result);
$result = Router::parse('/blog/foobar');
- $this->assertEquals(array(), $result);
+ $this->assertSame(array(), $result);
$result = Router::url(array('controller' => 'blog_posts', 'action' => 'foo'));
$this->assertEquals('/blog_posts/foo', $result);
@@ -2117,7 +2116,7 @@ public function testRegexRouteMatching() {
$this->assertEquals($expected, $result);
$result = Router::parse('/badness/test/test_action');
- $this->assertEquals(array(), $result);
+ $this->assertSame(array(), $result);
Router::reload();
Router::connect('/:locale/:controller/:action/*', array(), array('locale' => 'dan|eng'));
diff --git a/lib/Cake/Test/Case/Utility/CakeTimeTest.php b/lib/Cake/Test/Case/Utility/CakeTimeTest.php
index 7185ef00fd5..f21d066c88a 100644
--- a/lib/Cake/Test/Case/Utility/CakeTimeTest.php
+++ b/lib/Cake/Test/Case/Utility/CakeTimeTest.php
@@ -340,14 +340,14 @@ public function testNice() {
$this->assertEquals(date('Y-d-m', $time), $this->Time->nice($time));
$this->assertEquals('%Y-%d-%m', $this->Time->niceFormat);
- CakeTime::$niceFormat = '%Y-%d-%m %H:%M:%S';
- $this->assertEquals(date('Y-d-m H:i:s', $time), $this->Time->nice($time));
- $this->assertEquals('%Y-%d-%m %H:%M:%S', $this->Time->niceFormat);
+ CakeTime::$niceFormat = '%Y-%d-%m %H:%M';
+ $this->assertEquals(date('Y-d-m H:i', $time), $this->Time->nice($time));
+ $this->assertEquals('%Y-%d-%m %H:%M', $this->Time->niceFormat);
date_default_timezone_set('UTC');
$result = $this->Time->nice(null, 'America/New_York');
$expected = $this->Time->nice(time(), 'America/New_York');
- $this->assertEquals($expected, $result);
+ $this->assertEquals(substr($expected, 0, -1), substr($result, 0, -1));
$this->_restoreSystemTimezone();
}
@@ -474,7 +474,7 @@ public function testToServer() {
date_default_timezone_set('UTC');
- $serverTime = new DateTime('now');
+ $serverTime = new DateTime('2012-12-11 14:15:20');
$timezones = array('Europe/London', 'Europe/Brussels', 'UTC', 'America/Denver', 'America/Caracas', 'Asia/Kathmandu');
foreach ($timezones as $timezone) {
@@ -509,17 +509,18 @@ public function testToAtom() {
* @return void
*/
public function testToRss() {
- $this->assertEquals(date('r'), $this->Time->toRss(time()));
-
- if (!$this->skipIf(!class_exists('DateTimeZone'), '%s DateTimeZone class not available.')) {
- $timezones = array('Europe/London', 'Europe/Brussels', 'UTC', 'America/Denver', 'America/Caracas', 'Asia/Kathmandu');
- foreach ($timezones as $timezone) {
- $yourTimezone = new DateTimeZone($timezone);
- $yourTime = new DateTime('now', $yourTimezone);
- $userOffset = $yourTimezone->getOffset($yourTime) / HOUR;
- $this->assertEquals($yourTime->format('r'), $this->Time->toRss(time(), $userOffset));
- $this->assertEquals($yourTime->format('r'), $this->Time->toRss(time(), $timezone));
- }
+ $date = '2012-08-12 12:12:45';
+ $time = strtotime($date);
+ $this->assertEquals(date('r', $time), $this->Time->toRss($time));
+
+ $timezones = array('Europe/London', 'Europe/Brussels', 'UTC', 'America/Denver', 'America/Caracas', 'Asia/Kathmandu');
+ foreach ($timezones as $timezone) {
+ $yourTimezone = new DateTimeZone($timezone);
+ $yourTime = new DateTime($date, $yourTimezone);
+ $userOffset = $yourTimezone->getOffset($yourTime) / HOUR;
+ $time = $yourTime->format('U');
+ $this->assertEquals($yourTime->format('r'), $this->Time->toRss($time, $userOffset), "Failed on $timezone");
+ $this->assertEquals($yourTime->format('r'), $this->Time->toRss($time, $timezone), "Failed on $timezone");
}
}
diff --git a/lib/Cake/Test/Case/Utility/DebuggerTest.php b/lib/Cake/Test/Case/Utility/DebuggerTest.php
index 8040073c338..ea6912122c7 100644
--- a/lib/Cake/Test/Case/Utility/DebuggerTest.php
+++ b/lib/Cake/Test/Case/Utility/DebuggerTest.php
@@ -84,7 +84,13 @@ public function testExcerpt() {
$this->assertTrue(is_array($result));
$this->assertEquals(4, count($result));
- $pattern = '/.*?<\?php/';
+ $pattern = '/
.*?.*?<\?php/';
+ $this->assertRegExp($pattern, $result[0]);
+
+ $result = Debugger::excerpt(__FILE__, 10, 2);
+ $this->assertEquals(5, count($result));
+
+ $pattern = '/\*<\/span>/';
$this->assertRegExp($pattern, $result[0]);
$return = Debugger::excerpt('[internal]', 2, 2);
diff --git a/lib/Cake/Test/Case/Utility/HashTest.php b/lib/Cake/Test/Case/Utility/HashTest.php
index 40fcd7b5483..059de1839ee 100644
--- a/lib/Cake/Test/Case/Utility/HashTest.php
+++ b/lib/Cake/Test/Case/Utility/HashTest.php
@@ -298,7 +298,6 @@ public function testFlatten() {
'Author' => array('id' => '3', 'user' => 'larry', 'password' => null),
)
);
-
$result = Hash::flatten($data);
$expected = array(
'0.Post.id' => '1',
@@ -317,6 +316,21 @@ public function testFlatten() {
);
$this->assertEquals($expected, $result);
+ $data = array(
+ array(
+ 'Post' => array('id' => '1', 'author_id' => null, 'title' => 'First Post'),
+ 'Author' => array(),
+ )
+ );
+ $result = Hash::flatten($data);
+ $expected = array(
+ '0.Post.id' => '1',
+ '0.Post.author_id' => null,
+ '0.Post.title' => 'First Post',
+ '0.Author' => array()
+ );
+ $this->assertEquals($expected, $result);
+
$data = array(
array('Post' => array('id' => 1)),
array('Post' => array('id' => 2)),
@@ -914,6 +928,9 @@ public function testExtractUnevenKeys() {
* @return void
*/
public function testSort() {
+ $result = Hash::sort(array(), '{n}.name', 'asc');
+ $this->assertEquals(array(), $result);
+
$a = array(
0 => array(
'Person' => array('name' => 'Jeff'),
@@ -2148,4 +2165,142 @@ public function testExpand() {
$this->assertEquals($result, $expected);
}
+/**
+ * Test that flattening a large complex set doesn't loop forever.
+ *
+ * @return void
+ */
+ public function testFlattenInfiniteLoop() {
+ $data = array(
+ 'Order.ASI' => '0',
+ 'Order.Accounting' => '0',
+ 'Order.Admin' => '0',
+ 'Order.Art' => '0',
+ 'Order.ArtChecker' => '0',
+ 'Order.Canned' => '0',
+ 'Order.Customer_Tags' => '',
+ 'Order.Embroidery' => '0',
+ 'Order.Item.0.Product.style_number' => 'a11222',
+ 'Order.Item.0.Product.slug' => 'a11222',
+ 'Order.Item.0.Product._id' => '4ff8b8d3d7bbe8ad30000000',
+ 'Order.Item.0.Product.Color.slug' => 'kelly_green',
+ 'Order.Item.0.Product.ColorSizes.0.Color.color' => 'Sport Grey',
+ 'Order.Item.0.Product.ColorSizes.0.Color.slug' => 'sport_grey',
+ 'Order.Item.0.Product.ColorSizes.1.Color.color' => 'Kelly Green',
+ 'Order.Item.0.Product.ColorSizes.1.Color.slug' => 'kelly_green',
+ 'Order.Item.0.Product.ColorSizes.2.Color.color' => 'Orange',
+ 'Order.Item.0.Product.ColorSizes.2.Color.slug' => 'orange',
+ 'Order.Item.0.Product.ColorSizes.3.Color.color' => 'Yellow Haze',
+ 'Order.Item.0.Product.ColorSizes.3.Color.slug' => 'yellow_haze',
+ 'Order.Item.0.Product.brand' => 'OUTER BANKS',
+ 'Order.Item.0.Product.style' => 'T-shirt',
+ 'Order.Item.0.Product.description' => 'uhiuhuih oin ooi ioo ioio',
+ 'Order.Item.0.Product.sizes.0.Size.qty' => '',
+ 'Order.Item.0.Product.sizes.0.Size.size' => '0-3mo',
+ 'Order.Item.0.Product.sizes.0.Size.id' => '38',
+ 'Order.Item.0.Product.sizes.1.Size.qty' => '',
+ 'Order.Item.0.Product.sizes.1.Size.size' => '3-6mo',
+ 'Order.Item.0.Product.sizes.1.Size.id' => '39',
+ 'Order.Item.0.Product.sizes.2.Size.qty' => '78',
+ 'Order.Item.0.Product.sizes.2.Size.size' => '6-9mo',
+ 'Order.Item.0.Product.sizes.2.Size.id' => '40',
+ 'Order.Item.0.Product.sizes.3.Size.qty' => '',
+ 'Order.Item.0.Product.sizes.3.Size.size' => '6-12mo',
+ 'Order.Item.0.Product.sizes.3.Size.id' => '41',
+ 'Order.Item.0.Product.sizes.4.Size.qty' => '',
+ 'Order.Item.0.Product.sizes.4.Size.size' => '12-18mo',
+ 'Order.Item.0.Product.sizes.4.Size.id' => '42',
+ 'Order.Item.0.Art.imprint_locations.0.id' => 2,
+ 'Order.Item.0.Art.imprint_locations.0.name' => 'Left Chest',
+ 'Order.Item.0.Art.imprint_locations.0.imprint_type.id' => 7,
+ 'Order.Item.0.Art.imprint_locations.0.imprint_type.type' => 'Embroidery',
+ 'Order.Item.0.Art.imprint_locations.0.art' => '',
+ 'Order.Item.0.Art.imprint_locations.0.num_colors' => 3,
+ 'Order.Item.0.Art.imprint_locations.0.description' => 'Wooo! This is Embroidery!!',
+ 'Order.Item.0.Art.imprint_locations.0.lines.0' => 'Platen',
+ 'Order.Item.0.Art.imprint_locations.0.lines.1' => 'Logo',
+ 'Order.Item.0.Art.imprint_locations.0.height' => 4,
+ 'Order.Item.0.Art.imprint_locations.0.width' => 5,
+ 'Order.Item.0.Art.imprint_locations.0.stitch_density' => 'Light',
+ 'Order.Item.0.Art.imprint_locations.0.metallic_thread' => true,
+ 'Order.Item.0.Art.imprint_locations.1.id' => 4,
+ 'Order.Item.0.Art.imprint_locations.1.name' => 'Full Back',
+ 'Order.Item.0.Art.imprint_locations.1.imprint_type.id' => 6,
+ 'Order.Item.0.Art.imprint_locations.1.imprint_type.type' => 'Screenprinting',
+ 'Order.Item.0.Art.imprint_locations.1.art' => '',
+ 'Order.Item.0.Art.imprint_locations.1.num_colors' => 3,
+ 'Order.Item.0.Art.imprint_locations.1.description' => 'Wooo! This is Screenprinting!!',
+ 'Order.Item.0.Art.imprint_locations.1.lines.0' => 'Platen',
+ 'Order.Item.0.Art.imprint_locations.1.lines.1' => 'Logo',
+ 'Order.Item.0.Art.imprint_locations.2.id' => 26,
+ 'Order.Item.0.Art.imprint_locations.2.name' => 'HS - JSY Name Below',
+ 'Order.Item.0.Art.imprint_locations.2.imprint_type.id' => 9,
+ 'Order.Item.0.Art.imprint_locations.2.imprint_type.type' => 'Names',
+ 'Order.Item.0.Art.imprint_locations.2.description' => 'Wooo! This is Names!!',
+ 'Order.Item.0.Art.imprint_locations.2.sizes.S.0.active' => 1,
+ 'Order.Item.0.Art.imprint_locations.2.sizes.S.0.name' => 'Benjamin Talavera',
+ 'Order.Item.0.Art.imprint_locations.2.sizes.S.0.color' => 'Red',
+ 'Order.Item.0.Art.imprint_locations.2.sizes.S.0.height' => '3',
+ 'Order.Item.0.Art.imprint_locations.2.sizes.S.0.layout' => 'Arched',
+ 'Order.Item.0.Art.imprint_locations.2.sizes.S.0.style' => 'Classic',
+ 'Order.Item.0.Art.imprint_locations.2.sizes.S.1.active' => 0,
+ 'Order.Item.0.Art.imprint_locations.2.sizes.S.1.name' => 'Rishi Narayan',
+ 'Order.Item.0.Art.imprint_locations.2.sizes.S.1.color' => 'Cardinal',
+ 'Order.Item.0.Art.imprint_locations.2.sizes.S.1.height' => '4',
+ 'Order.Item.0.Art.imprint_locations.2.sizes.S.1.layout' => 'Straight',
+ 'Order.Item.0.Art.imprint_locations.2.sizes.S.1.style' => 'Team US',
+ 'Order.Item.0.Art.imprint_locations.2.sizes.M.0.active' => 1,
+ 'Order.Item.0.Art.imprint_locations.2.sizes.M.0.name' => 'Brandon Plasters',
+ 'Order.Item.0.Art.imprint_locations.2.sizes.M.0.color' => 'Red',
+ 'Order.Item.0.Art.imprint_locations.2.sizes.M.0.height' => '3',
+ 'Order.Item.0.Art.imprint_locations.2.sizes.M.0.layout' => 'Arched',
+ 'Order.Item.0.Art.imprint_locations.2.sizes.M.0.style' => 'Classic',
+ 'Order.Item.0.Art.imprint_locations.2.sizes.M.1.active' => 0,
+ 'Order.Item.0.Art.imprint_locations.2.sizes.M.1.name' => 'Andrew Reed',
+ 'Order.Item.0.Art.imprint_locations.2.sizes.M.1.color' => 'Cardinal',
+ 'Order.Item.0.Art.imprint_locations.2.sizes.M.1.height' => '4',
+ 'Order.Item.0.Art.imprint_locations.2.sizes.M.1.layout' => 'Straight',
+ 'Order.Item.0.Art.imprint_locations.2.sizes.M.1.style' => 'Team US',
+ 'Order.Job.0._id' => 'job-1',
+ 'Order.Job.0.type' => 'screenprinting',
+ 'Order.Job.0.postPress' => 'job-2',
+ 'Order.Job.1._id' => 'job-2',
+ 'Order.Job.1.type' => 'embroidery',
+ 'Order.Postpress' => '0',
+ 'Order.PriceAdjustment.0._id' => 'price-adjustment-1',
+ 'Order.PriceAdjustment.0.adjustment' => '-20',
+ 'Order.PriceAdjustment.0.adjustment_type' => 'percent',
+ 'Order.PriceAdjustment.0.type' => 'grand_total',
+ 'Order.PriceAdjustment.1.adjustment' => '20',
+ 'Order.PriceAdjustment.1.adjustment_type' => 'flat',
+ 'Order.PriceAdjustment.1.min-items' => '10',
+ 'Order.PriceAdjustment.1.type' => 'min-items',
+ 'Order.PriceAdjustment.1._id' => 'another-test-adjustment',
+ 'Order.Purchasing' => '0',
+ 'Order.QualityControl' => '0',
+ 'Order.Receiving' => '0',
+ 'Order.ScreenPrinting' => '0',
+ 'Order.Stage.art_approval' => 0,
+ 'Order.Stage.draft' => 1,
+ 'Order.Stage.quote' => 1,
+ 'Order.Stage.order' => 1,
+ 'Order.StoreLiason' => '0',
+ 'Order.Tag_UI_Email' => '',
+ 'Order.Tags' => '',
+ 'Order._id' => 'test-2',
+ 'Order.add_print_location' => '',
+ 'Order.created' => '2011-Dec-29 05:40:18',
+ 'Order.force_admin' => '0',
+ 'Order.modified' => '2012-Jul-25 01:24:49',
+ 'Order.name' => 'towering power',
+ 'Order.order_id' => '135961',
+ 'Order.slug' => 'test-2',
+ 'Order.title' => 'test job 2',
+ 'Order.type' => 'ttt'
+ );
+ $expanded = Hash::expand($data);
+ $flattened = Hash::flatten($expanded);
+ $this->assertEquals($data, $flattened);
+ }
+
}
diff --git a/lib/Cake/Test/Case/Utility/InflectorTest.php b/lib/Cake/Test/Case/Utility/InflectorTest.php
index cd19892480a..9e7d43add10 100644
--- a/lib/Cake/Test/Case/Utility/InflectorTest.php
+++ b/lib/Cake/Test/Case/Utility/InflectorTest.php
@@ -109,6 +109,7 @@ public function testInflectingSingulars() {
$this->assertEquals(Inflector::singularize('roofs'), 'roof');
$this->assertEquals(Inflector::singularize('foes'), 'foe');
$this->assertEquals(Inflector::singularize('databases'), 'database');
+ $this->assertEquals(Inflector::singularize('cookies'), 'cookie');
$this->assertEquals(Inflector::singularize(''), '');
}
@@ -160,6 +161,7 @@ public function testInflectingPlurals() {
$this->assertEquals(Inflector::pluralize('cafe'), 'cafes');
$this->assertEquals(Inflector::pluralize('roof'), 'roofs');
$this->assertEquals(Inflector::pluralize('foe'), 'foes');
+ $this->assertEquals(Inflector::pluralize('cookie'), 'cookies');
$this->assertEquals(Inflector::pluralize(''), '');
}
diff --git a/lib/Cake/Test/Case/Utility/SetTest.php b/lib/Cake/Test/Case/Utility/SetTest.php
index e1c18a8a5b0..4dd79f7ab0f 100644
--- a/lib/Cake/Test/Case/Utility/SetTest.php
+++ b/lib/Cake/Test/Case/Utility/SetTest.php
@@ -152,6 +152,9 @@ public function testMerge() {
$r = Set::merge('foo', 'bar');
$this->assertEquals(array('foo', 'bar'), $r);
+ $r = Set::merge(array('foo'), array(), array('bar'));
+ $this->assertEquals(array('foo', 'bar'), $r);
+
$r = Set::merge('foo', array('user' => 'bob', 'no-bar'), 'bar');
$this->assertEquals(array('foo', 'user' => 'bob', 'no-bar', 'bar'), $r);
@@ -222,6 +225,9 @@ public function testMerge() {
* @return void
*/
public function testSort() {
+ $result = Set::sort(array(), '{n}.name', 'asc');
+ $this->assertEquals(array(), $result);
+
$a = array(
0 => array('Person' => array('name' => 'Jeff'), 'Friend' => array(array('name' => 'Nate'))),
1 => array('Person' => array('name' => 'Tracy'),'Friend' => array(array('name' => 'Lindsay')))
@@ -1967,7 +1973,7 @@ public function testCombine() {
$this->assertEquals($expected, $result);
$result = Set::combine($a, 'fail', 'fail');
- $this->assertEquals(array(), $result);
+ $this->assertSame(array(), $result);
}
/**
@@ -3054,6 +3060,7 @@ public function testStrictKeyCheck() {
/**
* Tests Set::flatten
*
+ * @see Hash test cases, as Set::flatten() is just a proxy.
* @return void
*/
public function testFlatten() {
@@ -3064,6 +3071,21 @@ public function testFlatten() {
$data[9] = 'Shemp';
$result = Set::flatten($data);
$this->assertEquals($data, $result);
+
+ $data = array(
+ array(
+ 'Post' => array('id' => '1', 'author_id' => null, 'title' => 'First Post'),
+ 'Author' => array(),
+ )
+ );
+ $result = Set::flatten($data);
+ $expected = array(
+ '0.Post.id' => '1',
+ '0.Post.author_id' => null,
+ '0.Post.title' => 'First Post',
+ '0.Author' => array()
+ );
+ $this->assertEquals($expected, $result);
}
/**
diff --git a/lib/Cake/Test/Case/Utility/ValidationTest.php b/lib/Cake/Test/Case/Utility/ValidationTest.php
index 22afee2c904..db9a27d941d 100644
--- a/lib/Cake/Test/Case/Utility/ValidationTest.php
+++ b/lib/Cake/Test/Case/Utility/ValidationTest.php
@@ -1655,6 +1655,11 @@ public function testEmail() {
$this->assertTrue(Validation::email('abc@example.travel'));
$this->assertTrue(Validation::email('someone@st.t-com.hr'));
+ // gTLD's
+ $this->assertTrue(Validation::email('example@host.local'));
+ $this->assertTrue(Validation::email('example@x.org'));
+ $this->assertTrue(Validation::email('example@host.xxx'));
+
// strange, but technically valid email addresses
$this->assertTrue(Validation::email('S=postmaster/OU=rz/P=uni-frankfurt/A=d400/C=de@gateway.d400.de'));
$this->assertTrue(Validation::email('customer/department=shipping@example.com'));
@@ -1669,7 +1674,6 @@ public function testEmail() {
$this->assertFalse(Validation::email('abc.@example.com'));
$this->assertFalse(Validation::email('abc@example..com'));
$this->assertFalse(Validation::email('abc@example.com.a'));
- $this->assertFalse(Validation::email('abc@example.toolong'));
$this->assertFalse(Validation::email('abc;@example.com'));
$this->assertFalse(Validation::email('abc@example.com;'));
$this->assertFalse(Validation::email('abc@efg@example.com'));
@@ -1839,11 +1843,11 @@ public function testUrl() {
$this->assertTrue(Validation::url('http://example.com/~userdir/'));
$this->assertTrue(Validation::url('http://underscore_subdomain.example.org'));
$this->assertTrue(Validation::url('http://_jabber._tcp.gmail.com'));
+ $this->assertTrue(Validation::url('http://www.domain.longttldnotallowed'));
$this->assertFalse(Validation::url('ftps://256.168.0.1/pub/cake'));
$this->assertFalse(Validation::url('ftp://256.168.0.1/pub/cake'));
$this->assertFalse(Validation::url('http://w_w.domain.co_m'));
$this->assertFalse(Validation::url('http://www.domain.12com'));
- $this->assertFalse(Validation::url('http://www.domain.longttldnotallowed'));
$this->assertFalse(Validation::url('http://www.-invaliddomain.tld'));
$this->assertFalse(Validation::url('http://www.domain.-invalidtld'));
$this->assertFalse(Validation::url('http://this-domain-is-too-loooooong-by-icann-rules-maximum-length-is-63.com'));
diff --git a/lib/Cake/Test/Case/Utility/XmlTest.php b/lib/Cake/Test/Case/Utility/XmlTest.php
index 7108d75a791..e90217d9330 100644
--- a/lib/Cake/Test/Case/Utility/XmlTest.php
+++ b/lib/Cake/Test/Case/Utility/XmlTest.php
@@ -177,6 +177,7 @@ public static function invalidDataProvider() {
array(null),
array(false),
array(''),
+ array('http://localhost/notthere.xml'),
);
}
diff --git a/lib/Cake/Test/Case/View/Helper/FormHelperTest.php b/lib/Cake/Test/Case/View/Helper/FormHelperTest.php
index 9da345458d1..ae5b8fc9155 100644
--- a/lib/Cake/Test/Case/View/Helper/FormHelperTest.php
+++ b/lib/Cake/Test/Case/View/Helper/FormHelperTest.php
@@ -115,10 +115,19 @@ class Contact extends CakeTestModel {
'required_one' => array('required' => array('rule' => array('notEmpty'))),
'imnotrequired' => array('required' => false, 'rule' => 'alphaNumeric', 'allowEmpty' => true),
'imalsonotrequired' => array(
+ 'alpha' => array('rule' => 'alphaNumeric', 'allowEmpty' => true),
+ 'between' => array('rule' => array('between', 5, 30)),
+ ),
+ 'imalsonotrequired2' => array(
'alpha' => array('rule' => 'alphaNumeric', 'allowEmpty' => true),
'between' => array('rule' => array('between', 5, 30), 'allowEmpty' => true),
),
'imnotrequiredeither' => array('required' => true, 'rule' => array('between', 5, 30), 'allowEmpty' => true),
+ 'iamrequiredalways' => array(
+ 'email' => array('rule' => 'email'),
+ 'rule_on_create' => array('rule' => array('maxLength', 50), 'on' => 'create'),
+ 'rule_on_update' => array('rule' => array('between', 1, 50), 'on' => 'update'),
+ ),
);
/**
@@ -2144,6 +2153,23 @@ public function testInput() {
$this->assertTags($result, $expected);
}
+/**
+ * Test that inputs with 0 can be created.
+ *
+ * @return void
+ */
+ public function testInputZero() {
+ $this->Form->create('User');
+ $result = $this->Form->input('0');
+ $expected = array(
+ 'div' => array('class' => 'input text'),
+ 'label' => array('for' => 'User0'), '/label',
+ 'input' => array('type' => 'text', 'name' => 'data[User][0]', 'id' => 'User0'),
+ '/div'
+ );
+ $this->assertTags($result, $expected);
+ }
+
/**
* test input() with checkbox creation
*
@@ -2224,9 +2250,9 @@ public function testInputTime() {
'type' => 'time',
'selected' => '18:15'
));
- $this->assertRegExp('##', $result);
- $this->assertRegExp('##', $result);
- $this->assertRegExp('##', $result);
+ $this->assertContains('', $result);
+ $this->assertContains('', $result);
+ $this->assertContains('', $result);
}
/**
@@ -2235,6 +2261,24 @@ public function testInputTime() {
* @return void
*/
public function testTimeSelectedWithInterval() {
+ $result = $this->Form->input('Model.start_time', array(
+ 'type' => 'time',
+ 'interval' => 15,
+ 'selected' => array('hour' => '3', 'min' => '57', 'meridian' => 'pm')
+ ));
+ $this->assertContains('', $result);
+ $this->assertContains('', $result);
+ $this->assertContains('', $result);
+
+ $result = $this->Form->input('Model.start_time', array(
+ 'type' => 'time',
+ 'interval' => 15,
+ 'selected' => '2012-10-23 15:57:00'
+ ));
+ $this->assertContains('', $result);
+ $this->assertContains('', $result);
+ $this->assertContains('', $result);
+
$result = $this->Form->input('Model.start_time', array(
'timeFormat' => 24,
'type' => 'time',
@@ -2614,6 +2658,36 @@ public function testInputOverridingMagicSelectType() {
$this->assertTags($result, $expected);
}
+/**
+ * Test that magic input() selects are created for type=number
+ *
+ * @return void
+ */
+ public function testInputMagicSelectForTypeNumber() {
+ $this->View->viewVars['balances'] = array(0 => 'nothing', 1 => 'some', 100 => 'a lot');
+ $this->Form->request->data = array('ValidateUser' => array('balance' => 1));
+ $result = $this->Form->input('ValidateUser.balance');
+ $expected = array(
+ 'div' => array('class' => 'input select'),
+ 'label' => array('for' => 'ValidateUserBalance'),
+ 'Balance',
+ '/label',
+ 'select' => array('name' => 'data[ValidateUser][balance]', 'id' => 'ValidateUserBalance'),
+ array('option' => array('value' => '0')),
+ 'nothing',
+ '/option',
+ array('option' => array('value' => '1', 'selected' => 'selected')),
+ 'some',
+ '/option',
+ array('option' => array('value' => '100')),
+ 'a lot',
+ '/option',
+ '/select',
+ '/div'
+ );
+ $this->assertTags($result, $expected);
+ }
+
/**
* Test that magic input() selects can easily be converted into radio types without error.
*
@@ -3220,83 +3294,6 @@ public function testRadio() {
);
$this->assertTags($result, $expected);
- $result = $this->Form->input('Newsletter.subscribe', array('legend' => 'Legend title', 'type' => 'radio', 'options' => array('0' => 'Unsubscribe', '1' => 'Subscribe')));
- $expected = array(
- 'div' => array('class' => 'input radio'),
- 'fieldset' => array(),
- 'legend' => array(),
- 'Legend title',
- '/legend',
- 'input' => array('type' => 'hidden', 'name' => 'data[Newsletter][subscribe]', 'value' => '', 'id' => 'NewsletterSubscribe_'),
- array('input' => array('type' => 'radio', 'name' => 'data[Newsletter][subscribe]', 'value' => '0', 'id' => 'NewsletterSubscribe0')),
- array('label' => array('for' => 'NewsletterSubscribe0')),
- 'Unsubscribe',
- '/label',
- array('input' => array('type' => 'radio', 'name' => 'data[Newsletter][subscribe]', 'value' => '1', 'id' => 'NewsletterSubscribe1')),
- array('label' => array('for' => 'NewsletterSubscribe1')),
- 'Subscribe',
- '/label',
- '/fieldset',
- '/div'
- );
- $this->assertTags($result, $expected);
-
- $result = $this->Form->input('Newsletter.subscribe', array('legend' => false, 'type' => 'radio', 'options' => array('0' => 'Unsubscribe', '1' => 'Subscribe')));
- $expected = array(
- 'div' => array('class' => 'input radio'),
- 'input' => array('type' => 'hidden', 'name' => 'data[Newsletter][subscribe]', 'value' => '', 'id' => 'NewsletterSubscribe_'),
- array('input' => array('type' => 'radio', 'name' => 'data[Newsletter][subscribe]', 'value' => '0', 'id' => 'NewsletterSubscribe0')),
- array('label' => array('for' => 'NewsletterSubscribe0')),
- 'Unsubscribe',
- '/label',
- array('input' => array('type' => 'radio', 'name' => 'data[Newsletter][subscribe]', 'value' => '1', 'id' => 'NewsletterSubscribe1')),
- array('label' => array('for' => 'NewsletterSubscribe1')),
- 'Subscribe',
- '/label',
- '/div'
- );
- $this->assertTags($result, $expected);
-
- $result = $this->Form->input('Newsletter.subscribe', array('legend' => 'Legend title', 'label' => false, 'type' => 'radio', 'options' => array('0' => 'Unsubscribe', '1' => 'Subscribe')));
- $expected = array(
- 'div' => array('class' => 'input radio'),
- 'fieldset' => array(),
- 'legend' => array(),
- 'Legend title',
- '/legend',
- 'input' => array('type' => 'hidden', 'name' => 'data[Newsletter][subscribe]', 'value' => '', 'id' => 'NewsletterSubscribe_'),
- array('input' => array('type' => 'radio', 'name' => 'data[Newsletter][subscribe]', 'value' => '0', 'id' => 'NewsletterSubscribe0')),
- 'Unsubscribe',
- array('input' => array('type' => 'radio', 'name' => 'data[Newsletter][subscribe]', 'value' => '1', 'id' => 'NewsletterSubscribe1')),
- 'Subscribe',
- '/fieldset',
- '/div'
- );
- $this->assertTags($result, $expected);
-
- $result = $this->Form->input('Newsletter.subscribe', array('legend' => false, 'label' => false, 'type' => 'radio', 'options' => array('0' => 'Unsubscribe', '1' => 'Subscribe')));
- $expected = array(
- 'div' => array('class' => 'input radio'),
- 'input' => array('type' => 'hidden', 'name' => 'data[Newsletter][subscribe]', 'value' => '', 'id' => 'NewsletterSubscribe_'),
- array('input' => array('type' => 'radio', 'name' => 'data[Newsletter][subscribe]', 'value' => '0', 'id' => 'NewsletterSubscribe0')),
- 'Unsubscribe',
- array('input' => array('type' => 'radio', 'name' => 'data[Newsletter][subscribe]', 'value' => '1', 'id' => 'NewsletterSubscribe1')),
- 'Subscribe',
- '/div'
- );
- $this->assertTags($result, $expected);
-
- $result = $this->Form->input('Newsletter.subscribe', array('legend' => false, 'label' => false, 'type' => 'radio', 'value' => '1', 'options' => array('0' => 'Unsubscribe', '1' => 'Subscribe')));
- $expected = array(
- 'div' => array('class' => 'input radio'),
- array('input' => array('type' => 'radio', 'name' => 'data[Newsletter][subscribe]', 'value' => '0', 'id' => 'NewsletterSubscribe0')),
- 'Unsubscribe',
- array('input' => array('type' => 'radio', 'name' => 'data[Newsletter][subscribe]', 'value' => '1', 'id' => 'NewsletterSubscribe1', 'checked' => 'checked')),
- 'Subscribe',
- '/div'
- );
- $this->assertTags($result, $expected);
-
$result = $this->Form->radio('Employee.gender', array('male' => 'Male', 'female' => 'Female'));
$expected = array(
'fieldset' => array(),
@@ -3410,10 +3407,11 @@ public function testRadio() {
/**
* Test that radios with a 0 value are selected under the correct conditions.
+ * Also ensure that values that are booleanish are handled correctly.
*
* @return void
*/
- public function testRadioOptionWithZeroValue() {
+ public function testRadioOptionWithBooleanishValues() {
$expected = array(
'fieldset' => array(),
'legend' => array(),
@@ -3435,6 +3433,9 @@ public function testRadioOptionWithZeroValue() {
$result = $this->Form->radio('Model.field', array('1' => 'Yes', '0' => 'No'), array('value' => 0));
$this->assertTags($result, $expected);
+ $result = $this->Form->radio('Model.field', array('1' => 'Yes', '0' => 'No'), array('value' => false));
+ $this->assertTags($result, $expected);
+
$expected = array(
'fieldset' => array(),
'legend' => array(),
@@ -3459,6 +3460,30 @@ public function testRadioOptionWithZeroValue() {
$result = $this->Form->radio('Model.field', array('1' => 'Yes', '0' => 'No'));
$this->assertTags($result, $expected);
+
+ $expected = array(
+ 'fieldset' => array(),
+ 'legend' => array(),
+ 'Field',
+ '/legend',
+ array('input' => array('type' => 'radio', 'name' => 'data[Model][field]', 'checked' => 'checked', 'value' => '1', 'id' => 'ModelField1')),
+ array('label' => array('for' => 'ModelField1')),
+ 'Yes',
+ '/label',
+ array('input' => array('type' => 'radio', 'name' => 'data[Model][field]', 'value' => '0', 'id' => 'ModelField0')),
+ array('label' => array('for' => 'ModelField0')),
+ 'No',
+ '/label',
+ '/fieldset'
+ );
+ $result = $this->Form->radio('Model.field', array('1' => 'Yes', '0' => 'No'), array('value' => 1));
+ $this->assertTags($result, $expected);
+
+ $result = $this->Form->radio('Model.field', array('1' => 'Yes', '0' => 'No'), array('value' => '1'));
+ $this->assertTags($result, $expected);
+
+ $result = $this->Form->radio('Model.field', array('1' => 'Yes', '0' => 'No'), array('value' => true));
+ $this->assertTags($result, $expected);
}
/**
@@ -5621,26 +5646,10 @@ public function testHour() {
$this->Form->request->data['Model']['field'] = '';
$result = $this->Form->hour('Model.field', true, array('value' => '23'));
- $expected = array(
- array('select' => array('name' => 'data[Model][field][hour]', 'id' => 'ModelFieldHour')),
- array('option' => array('value' => '')),
- '/option',
- array('option' => array('value' => '00')),
- '0',
- '/option',
- array('option' => array('value' => '01')),
- '1',
- '/option',
- array('option' => array('value' => '02')),
- '2',
- '/option',
- $hoursRegex,
- array('option' => array('value' => '23', 'selected' => 'selected')),
- '23',
- '/option',
- '/select',
- );
- $this->assertTags($result, $expected);
+ $this->assertContains('', $result);
+
+ $result = $this->Form->hour('Model.field', false, array('value' => '23'));
+ $this->assertContains('', $result);
$this->Form->request->data['Model']['field'] = '2006-10-10 00:12:32';
$result = $this->Form->hour('Model.field', true);
@@ -5960,6 +5969,10 @@ public function testFileUploadField() {
'/div'
);
$this->assertTags($result, $expected);
+
+ $this->Form->request->data['Model']['upload'] = 'no data should be set in value';
+ $result = $this->Form->file('Model.upload');
+ $this->assertTags($result, array('input' => array('type' => 'file', 'name' => 'data[Model][upload]', 'id' => 'ModelUpload')));
}
/**
@@ -7022,6 +7035,20 @@ public function testFormInputRequiredDetection() {
);
$this->assertTags($result, $expected);
+ $result = $this->Form->input('Contact.imalsonotrequired2');
+ $expected = array(
+ 'div' => array('class' => 'input text'),
+ 'label' => array('for' => 'ContactImalsonotrequired2'),
+ 'Imalsonotrequired2',
+ '/label',
+ 'input' => array(
+ 'type' => 'text', 'name' => 'data[Contact][imalsonotrequired2]',
+ 'id' => 'ContactImalsonotrequired2'
+ ),
+ '/div'
+ );
+ $this->assertTags($result, $expected);
+
$result = $this->Form->input('Contact.imnotrequiredeither');
$expected = array(
'div' => array('class' => 'input text'),
@@ -7035,6 +7062,20 @@ public function testFormInputRequiredDetection() {
'/div'
);
$this->assertTags($result, $expected);
+
+ $result = $this->Form->input('Contact.iamrequiredalways');
+ $expected = array(
+ 'div' => array('class' => 'input text required'),
+ 'label' => array('for' => 'ContactIamrequiredalways'),
+ 'Iamrequiredalways',
+ '/label',
+ 'input' => array(
+ 'type' => 'text', 'name' => 'data[Contact][iamrequiredalways]',
+ 'id' => 'ContactIamrequiredalways'
+ ),
+ '/div'
+ );
+ $this->assertTags($result, $expected);
}
/**
diff --git a/lib/Cake/Test/Case/View/Helper/JqueryEngineHelperTest.php b/lib/Cake/Test/Case/View/Helper/JqueryEngineHelperTest.php
index 4823f1ec5fc..4114b65e3f0 100644
--- a/lib/Cake/Test/Case/View/Helper/JqueryEngineHelperTest.php
+++ b/lib/Cake/Test/Case/View/Helper/JqueryEngineHelperTest.php
@@ -215,6 +215,18 @@ public function testRequest() {
$this->assertEquals($expected, $result);
}
+/**
+ * Test that querystring arguments are not double escaped.
+ *
+ * @return void
+ */
+ public function testRequestWithQueryStringArguments() {
+ $url = '/users/search/sort:User.name/direction:desc?nome=&cpm=&audience=public';
+ $result = $this->Jquery->request($url);
+ $expected = '$.ajax({url:"\\/users\\/search\\/sort:User.name\\/direction:desc?nome=&cpm=&audience=public"});';
+ $this->assertEquals($expected, $result);
+ }
+
/**
* test that alternate jQuery object values work for request()
*
diff --git a/lib/Cake/Test/Case/View/Helper/JsHelperTest.php b/lib/Cake/Test/Case/View/Helper/JsHelperTest.php
index 950e5c22125..53b8cce9708 100644
--- a/lib/Cake/Test/Case/View/Helper/JsHelperTest.php
+++ b/lib/Cake/Test/Case/View/Helper/JsHelperTest.php
@@ -29,7 +29,9 @@ class JsEncodingObject {
protected $_title = 'Old thing';
+ //@codingStandardsIgnoreStart
private $__noshow = 'Never ever';
+ //@codingStandardsIgnoreEnd
}
@@ -366,7 +368,9 @@ public function testWriteScriptsInFile() {
$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]);
+ if (file_exists(WWW_ROOT . $filename[1])) {
+ unlink(WWW_ROOT . $filename[1]);
+ }
Configure::write('Cache.disable', true);
$this->Js->buffer('one = 1;');
@@ -904,7 +908,7 @@ public function testObject() {
public function testOptionMapping() {
$JsEngine = new OptionEngineHelper($this->View);
$result = $JsEngine->testMap();
- $this->assertEquals(array(), $result);
+ $this->assertSame(array(), $result);
$result = $JsEngine->testMap(array('foo' => 'bar', 'baz' => 'sho'));
$this->assertEquals(array('foo' => 'bar', 'baz' => 'sho'), $result);
diff --git a/lib/Cake/Test/Case/View/HelperTest.php b/lib/Cake/Test/Case/View/HelperTest.php
index 65d9d8eb5d9..6cecf1ea1d4 100644
--- a/lib/Cake/Test/Case/View/HelperTest.php
+++ b/lib/Cake/Test/Case/View/HelperTest.php
@@ -622,6 +622,9 @@ public function testAssetUrl() {
$result = $this->Helper->assetUrl('style', array('ext' => '.css'));
$this->assertEquals('style.css', $result);
+ $result = $this->Helper->assetUrl('dir/sub dir/my image', array('ext' => '.jpg'));
+ $this->assertEquals('dir/sub%20dir/my%20image.jpg', $result);
+
$result = $this->Helper->assetUrl('foo.jpg?one=two&three=four');
$this->assertEquals('foo.jpg?one=two&three=four', $result);
}
diff --git a/lib/Cake/Test/Case/View/MediaViewTest.php b/lib/Cake/Test/Case/View/MediaViewTest.php
index 3b723c0bfea..a027c60e1ac 100644
--- a/lib/Cake/Test/Case/View/MediaViewTest.php
+++ b/lib/Cake/Test/Case/View/MediaViewTest.php
@@ -36,7 +36,10 @@ class MediaViewTest extends CakeTestCase {
public function setUp() {
parent::setUp();
$this->MediaView = $this->getMock('MediaView', array('_isActive', '_clearBuffer', '_flushBuffer'));
- $this->MediaView->response = $this->getMock('CakeResponse');
+ $this->MediaView->response = $this->getMock(
+ 'CakeResponse',
+ array('send', 'cache', 'type', 'download', 'statusCode')
+ );
}
/**
@@ -83,20 +86,6 @@ public function testRender() {
->with('css')
->will($this->returnArgument(0));
- $this->MediaView->response->expects($this->at(1))
- ->method('header')
- ->with(array(
- 'Date' => gmdate('D, d M Y H:i:s', time()) . ' GMT',
- 'Expires' => '0',
- 'Cache-Control' => 'private, must-revalidate, post-check=0, pre-check=0',
- 'Pragma' => 'no-cache'
- ));
-
- $this->MediaView->response->expects($this->at(2))
- ->method('header')
- ->with(array(
- 'Content-Length' => 31
- ));
$this->MediaView->response->expects($this->once())->method('send');
$this->MediaView->expects($this->once())->method('_clearBuffer');
$this->MediaView->expects($this->once())->method('_flushBuffer');
@@ -106,6 +95,16 @@ public function testRender() {
$output = ob_get_clean();
$this->assertEquals('this is the test asset css file', $output);
$this->assertTrue($result !== false);
+
+ $headers = $this->MediaView->response->header();
+ $this->assertEquals(31, $headers['Content-Length']);
+ $this->assertEquals(0, $headers['Expires']);
+ $this->assertEquals(
+ 'private, must-revalidate, post-check=0, pre-check=0',
+ $headers['Cache-Control']
+ );
+ $this->assertEquals('no-cache', $headers['Pragma']);
+ $this->assertContains(gmdate('D, d M Y H:i', time()), $headers['Date']);
}
/**
@@ -130,29 +129,10 @@ public function testRenderWithUnknownFileTypeGeneric() {
->with('ini')
->will($this->returnValue(false));
- $this->MediaView->response->expects($this->at(1))
- ->method('header')
- ->with(array(
- 'Date' => gmdate('D, d M Y H:i:s', time()) . ' GMT',
- 'Expires' => '0',
- 'Cache-Control' => 'private, must-revalidate, post-check=0, pre-check=0',
- 'Pragma' => 'no-cache'
- ));
-
$this->MediaView->response->expects($this->once())
->method('download')
->with('no_section.ini');
- $this->MediaView->response->expects($this->at(3))
- ->method('header')
- ->with(array(
- 'Accept-Ranges' => 'bytes'
- ));
-
- $this->MediaView->response->expects($this->at(4))
- ->method('header')
- ->with('Content-Length', 35);
-
$this->MediaView->response->expects($this->once())->method('send');
$this->MediaView->expects($this->once())->method('_clearBuffer');
$this->MediaView->expects($this->once())->method('_flushBuffer');
@@ -165,6 +145,17 @@ public function testRenderWithUnknownFileTypeGeneric() {
if ($currentUserAgent !== null) {
$_SERVER['HTTP_USER_AGENT'] = $currentUserAgent;
}
+
+ $headers = $this->MediaView->response->header();
+ $this->assertEquals(35, $headers['Content-Length']);
+ $this->assertEquals(0, $headers['Expires']);
+ $this->assertEquals('bytes', $headers['Accept-Ranges']);
+ $this->assertEquals(
+ 'private, must-revalidate, post-check=0, pre-check=0',
+ $headers['Cache-Control']
+ );
+ $this->assertEquals('no-cache', $headers['Pragma']);
+ $this->assertContains(gmdate('D, d M Y H:i', time()), $headers['Date']);
}
/**
@@ -190,15 +181,6 @@ public function testRenderWithUnknownFileTypeOpera() {
->will($this->returnValue(false));
$this->MediaView->response->expects($this->at(1))
- ->method('header')
- ->with(array(
- 'Date' => gmdate('D, d M Y H:i:s', time()) . ' GMT',
- 'Expires' => '0',
- 'Cache-Control' => 'private, must-revalidate, post-check=0, pre-check=0',
- 'Pragma' => 'no-cache'
- ));
-
- $this->MediaView->response->expects($this->at(2))
->method('type')
->with('application/octetstream')
->will($this->returnValue(false));
@@ -207,16 +189,6 @@ public function testRenderWithUnknownFileTypeOpera() {
->method('download')
->with('no_section.ini');
- $this->MediaView->response->expects($this->at(4))
- ->method('header')
- ->with(array(
- 'Accept-Ranges' => 'bytes'
- ));
-
- $this->MediaView->response->expects($this->at(5))
- ->method('header')
- ->with('Content-Length', 35);
-
$this->MediaView->response->expects($this->once())->method('send');
$this->MediaView->expects($this->once())->method('_clearBuffer');
$this->MediaView->expects($this->once())->method('_flushBuffer');
@@ -229,6 +201,17 @@ public function testRenderWithUnknownFileTypeOpera() {
if ($currentUserAgent !== null) {
$_SERVER['HTTP_USER_AGENT'] = $currentUserAgent;
}
+
+ $headers = $this->MediaView->response->header();
+ $this->assertEquals(35, $headers['Content-Length']);
+ $this->assertEquals(0, $headers['Expires']);
+ $this->assertEquals('bytes', $headers['Accept-Ranges']);
+ $this->assertEquals(
+ 'private, must-revalidate, post-check=0, pre-check=0',
+ $headers['Cache-Control']
+ );
+ $this->assertEquals('no-cache', $headers['Pragma']);
+ $this->assertContains(gmdate('D, d M Y H:i', time()), $headers['Date']);
}
/**
@@ -255,15 +238,6 @@ public function testRenderWithUnknownFileTypeIE() {
->will($this->returnValue(false));
$this->MediaView->response->expects($this->at(1))
- ->method('header')
- ->with(array(
- 'Date' => gmdate('D, d M Y H:i:s', time()) . ' GMT',
- 'Expires' => '0',
- 'Cache-Control' => 'private, must-revalidate, post-check=0, pre-check=0',
- 'Pragma' => 'no-cache'
- ));
-
- $this->MediaView->response->expects($this->at(2))
->method('type')
->with('application/force-download')
->will($this->returnValue(false));
@@ -272,16 +246,6 @@ public function testRenderWithUnknownFileTypeIE() {
->method('download')
->with('config.ini');
- $this->MediaView->response->expects($this->at(4))
- ->method('header')
- ->with(array(
- 'Accept-Ranges' => 'bytes'
- ));
-
- $this->MediaView->response->expects($this->at(5))
- ->method('header')
- ->with('Content-Length', 35);
-
$this->MediaView->response->expects($this->once())->method('send');
$this->MediaView->expects($this->once())->method('_clearBuffer');
$this->MediaView->expects($this->once())->method('_flushBuffer');
@@ -294,6 +258,17 @@ public function testRenderWithUnknownFileTypeIE() {
if ($currentUserAgent !== null) {
$_SERVER['HTTP_USER_AGENT'] = $currentUserAgent;
}
+
+ $headers = $this->MediaView->response->header();
+ $this->assertEquals(35, $headers['Content-Length']);
+ $this->assertEquals(0, $headers['Expires']);
+ $this->assertEquals('bytes', $headers['Accept-Ranges']);
+ $this->assertEquals(
+ 'private, must-revalidate, post-check=0, pre-check=0',
+ $headers['Cache-Control']
+ );
+ $this->assertEquals('no-cache', $headers['Pragma']);
+ $this->assertContains(gmdate('D, d M Y H:i', time()), $headers['Date']);
}
/**
diff --git a/lib/Cake/Test/Case/View/ScaffoldViewTest.php b/lib/Cake/Test/Case/View/ScaffoldViewTest.php
index a5f2d85c093..87bf9bd9abe 100644
--- a/lib/Cake/Test/Case/View/ScaffoldViewTest.php
+++ b/lib/Cake/Test/Case/View/ScaffoldViewTest.php
@@ -279,7 +279,7 @@ public function testViewScaffold() {
$this->assertRegExp('/
View Scaffold Mock<\/h2>/', $result);
$this->assertRegExp('/
/', $result);
- //TODO: add specific tests for fields.
+
$this->assertRegExp('/1<\/a>/', $result); //belongsTo links
$this->assertRegExp('/
Scaffold Mock<\/h2>/', $result);
$this->assertRegExp('/