Permalink
Browse files

Merge branch 'master' into 2.4

  • Loading branch information...
2 parents 8e299fc + 6d30139 commit e97b3acebbc0ca405d6cd7eca2d4163751f75a43 @markstory markstory committed Mar 15, 2013
@@ -436,6 +436,10 @@ public function insertCallback($table, $fields, $values) {
$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 @@ public function testInsertStrings() {
$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']);
}
/**
@@ -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");
+ }
+
+}
@@ -873,6 +873,10 @@ public function testExtractAttributePattern() {
$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);
}
/**
@@ -175,6 +175,7 @@ public function testAlphaNumeric() {
$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"));
@@ -106,7 +106,7 @@ public function testRenderWithView() {
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);
@@ -138,13 +138,14 @@ protected function _checkPHPUnit() {
*/
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;
}
/**
@@ -277,7 +277,6 @@ public function insert($db) {
$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;
@@ -170,7 +170,7 @@ protected static function _matchToken($key, $token) {
*/
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
@@ -92,7 +92,7 @@ public static function alphaNumeric($check) {
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');
}
/**

0 comments on commit e97b3ac

Please sign in to comment.