Browse Source

Merge branch 'master' into 2.4

mark_story 13 years ago
parent
commit
e97b3acebb

+ 23 - 1
lib/Cake/Test/Case/TestSuite/CakeTestFixtureTest.php

@@ -436,6 +436,10 @@ class CakeTestFixtureTest extends CakeTestCase {
 		$this->insertMulti['table'] = $table;
 		$this->insertMulti['fields'] = $fields;
 		$this->insertMulti['values'] = $values;
+		$this->insertMulti['fields_values'] = array();
+		foreach($values as $record) {
+			$this->insertMulti['fields_values'][] = array_combine($fields, $record);
+		}
 		return true;
 	}
 
@@ -454,13 +458,31 @@ class CakeTestFixtureTest extends CakeTestCase {
 		$this->assertTrue($this->criticDb->fullDebug);
 		$this->assertTrue($return);
 		$this->assertEquals('strings', $this->insertMulti['table']);
-		$this->assertEquals(array('email', 'name', 'age'), $this->insertMulti['fields']);
+		$this->assertEquals(array('name', 'email', 'age'), array_values($this->insertMulti['fields']));
 		$expected = array(
 			array('Mark Doe', 'mark.doe@email.com', null),
 			array('John Doe', 'john.doe@email.com', 20),
 			array('Jane Doe', 'jane.doe@email.com', 30),
 		);
 		$this->assertEquals($expected, $this->insertMulti['values']);
+		$expected = array(
+			array(
+				'name' => 'Mark Doe', 
+				'email' => 'mark.doe@email.com', 
+				'age' => null
+			),
+			array(
+				'name' => 'John Doe', 
+				'email' => 'john.doe@email.com', 
+				'age' => 20
+			),
+			array(
+				'name' => 'Jane Doe', 
+				'email' => 'jane.doe@email.com', 
+				'age' => 30
+			),
+		);
+		$this->assertEquals($expected, $this->insertMulti['fields_values']);
 	}
 
 /**

+ 38 - 0
lib/Cake/Test/Case/TestSuite/CakeTestSuiteDispatcherTest.php

@@ -0,0 +1,38 @@
+<?php
+
+class CakeTestSuiteDispatcherTest extends CakeTestCase {
+
+  public function setUp() {
+    $this->vendors = App::path('vendors');
+    $this->includePath = ini_get('include_path');
+  }
+
+  public function tearDown() {
+    App::build(array('Vendor' => $this->vendors), App::RESET);
+    ini_set('include_path', $this->includePath);
+  }
+
+  protected function clearPaths() {
+    App::build(array('Vendor' => array('junk')), App::RESET);
+    ini_set('include_path', 'junk');
+  }
+
+  public function testLoadTestFramework() {
+    $dispatcher = new CakeTestSuiteDispatcher();
+
+    $this->assertTrue($dispatcher->loadTestFramework());
+
+    $this->clearPaths();
+
+    $exception = null;
+
+    try {
+      $dispatcher->loadTestFramework();
+    } catch (Exception $ex) {
+      $exception = $ex;
+    }
+
+    $this->assertEquals(get_class($exception), "PHPUnit_Framework_Error_Warning");
+  }
+
+}

+ 4 - 0
lib/Cake/Test/Case/Utility/HashTest.php

@@ -873,6 +873,10 @@ class HashTest extends CakeTestCase {
 		$result = Hash::extract($data, '{n}.Article[title=/^First/]');
 		$expected = array($data[0]['Article']);
 		$this->assertEquals($expected, $result);
+
+		$result = Hash::extract($data, '{n}.Article[title=/^Fir[a-z]+/]');
+		$expected = array($data[0]['Article']);
+		$this->assertEquals($expected, $result);
 	}
 
 /**

+ 1 - 0
lib/Cake/Test/Case/Utility/ValidationTest.php

@@ -175,6 +175,7 @@ class ValidationTest extends CakeTestCase {
 
 		$this->assertFalse(Validation::alphaNumeric('12 234'));
 		$this->assertFalse(Validation::alphaNumeric('dfd 234'));
+		$this->assertFalse(Validation::alphaNumeric("0\n"));
 		$this->assertFalse(Validation::alphaNumeric("\n"));
 		$this->assertFalse(Validation::alphaNumeric("\t"));
 		$this->assertFalse(Validation::alphaNumeric("\r"));

+ 1 - 1
lib/Cake/Test/Case/View/JsonViewTest.php

@@ -106,7 +106,7 @@ class JsonViewTest extends CakeTestCase {
 		App::build(array(
 			'View' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS)
 		));
-		$Request = new CakeRequest();
+		$Request = new CakeRequest(null, false);
 		$Request->params['named'] = array('page' => 2);
 		$Response = new CakeResponse();
 		$Controller = new Controller($Request, $Response);

+ 3 - 2
lib/Cake/TestSuite/CakeTestSuiteDispatcher.php

@@ -138,13 +138,14 @@ class CakeTestSuiteDispatcher {
  */
 	public function loadTestFramework() {
 		foreach (App::path('vendors') as $vendor) {
-			if (is_dir($vendor . 'PHPUnit')) {
+      $vendor = rtrim($vendor, DS);
+			if (is_dir($vendor . DS . 'PHPUnit')) {
 				ini_set('include_path', $vendor . PATH_SEPARATOR . ini_get('include_path'));
 				break;
 			}
 		}
 
-		return include 'PHPUnit' . DS . 'Autoload.php';
+		return (include('PHPUnit' . DS . 'Autoload.php')) !== false;
 	}
 
 /**

+ 0 - 1
lib/Cake/TestSuite/Fixture/CakeTestFixture.php

@@ -277,7 +277,6 @@ class CakeTestFixture {
 				$fields = array_unique($fields);
 				$default = array_fill_keys($fields, null);
 				foreach ($this->records as $record) {
-					$fields = array_keys($record);
 					$values[] = array_values(array_merge($default, $record));
 				}
 				$nested = $db->useNestedTransactions;

+ 1 - 1
lib/Cake/Utility/Hash.php

@@ -170,7 +170,7 @@ class Hash {
  */
 	protected static function _matches(array $data, $selector) {
 		preg_match_all(
-			'/(\[ (?<attr>[^=><!]+?) (\s* (?<op>[><!]?[=]|[><]) \s* (?<val>[^\]]+) )? \])/x',
+			'/(\[ (?<attr>[^=><!]+?) (\s* (?<op>[><!]?[=]|[><]) \s* (?<val>(?:\/.*?\/ | [^\]]+)) )? \])/x',
 			$selector,
 			$conditions,
 			PREG_SET_ORDER

+ 1 - 1
lib/Cake/Utility/Validation.php

@@ -92,7 +92,7 @@ class Validation {
 		if (empty($check) && $check != '0') {
 			return false;
 		}
-		return self::_check($check, '/^[\p{Ll}\p{Lm}\p{Lo}\p{Lt}\p{Lu}\p{Nd}]+$/mu');
+		return self::_check($check, '/^[\p{Ll}\p{Lm}\p{Lo}\p{Lt}\p{Lu}\p{Nd}]+$/Du');
 	}
 
 /**