Skip to content
Browse files

Merge branch '1.2' into 1.3

  • Loading branch information...
2 parents 33adb6e + 92fd7cf commit 6775e0997e2055138055c1e40dcf01401f7a787c gwoo committed Aug 3, 2009
View
2 cake/basics.php
@@ -843,7 +843,7 @@ function array_diff_key() {
foreach ($args[0] as $valueKey => $valueData) {
for ($i = 1; $i < $argc; $i++) {
- if (isset($args[$i][$valueKey])) {
+ if (array_key_exists($valueKey, $args[$i])) {
continue 2;
}
}
View
2 cake/libs/controller/components/security.php
@@ -351,7 +351,7 @@ function loginRequest($options = array()) {
if (strtolower($options['type']) == 'digest') {
$out[] = 'qop="auth"';
- $out[] = 'nonce="' . uniqid() . '"';
+ $out[] = 'nonce="' . uniqid("") . '"';
$out[] = 'opaque="' . md5($options['realm']).'"';
}
View
6 cake/libs/controller/controller.php
@@ -1028,17 +1028,17 @@ function paginate($object = null, $scope = array(), $whitelist = array()) {
}
} elseif (empty($object) || $object === null) {
if (isset($this->{$this->modelClass})) {
- $object = $this->{$this->modelClass};
+ $object =& $this->{$this->modelClass};
} else {
$className = null;
$name = $this->uses[0];
if (strpos($this->uses[0], '.') !== false) {
list($name, $className) = explode('.', $this->uses[0]);
}
if ($className) {
- $object = $this->{$className};
+ $object =& $this->{$className};
} else {
- $object = $this->{$name};
+ $object =& $this->{$name};
}
}
}
View
30 cake/tests/cases/basics.test.php
@@ -61,6 +61,36 @@ function tearDown() {
}
/**
+ * test the array_diff_key compatibility function.
+ *
+ * @return void
+ **/
+ function testArrayDiffKey() {
+ $one = array('one' => 1, 'two' => 2, 'three' => 3);
+ $two = array('one' => 'one', 'two' => 'two');
+ $result = array_diff_key($one, $two);
+ $expected = array('three' => 3);
+ $this->assertEqual($result, $expected);
+
+ $one = array('one' => array('value', 'value-two'), 'two' => 2, 'three' => 3);
+ $two = array('two' => 'two');
+ $result = array_diff_key($one, $two);
+ $expected = array('one' => array('value', 'value-two'), 'three' => 3);
+ $this->assertEqual($result, $expected);
+
+ $one = array('one' => null, 'two' => 2, 'three' => '', 'four' => 0);
+ $two = array('two' => 'two');
+ $result = array_diff_key($one, $two);
+ $expected = array('one' => null, 'three' => '', 'four' => 0);
+ $this->assertEqual($result, $expected);
+
+ $one = array('minYear' => null, 'maxYear' => null, 'separator' => '-', 'interval' => 1, 'monthNames' => true);
+ $two = array('minYear' => null, 'maxYear' => null, 'separator' => '-', 'interval' => 1, 'monthNames' => true);
+ $result = array_diff_key($one, $two);
+ $this->assertEqual($result, array());
+
+ }
+/**
* testHttpBase method
*
* @return void
View
2 cake/tests/cases/console/libs/acl.test.php
@@ -92,7 +92,7 @@ function endCase() {
function startTest() {
$this->Dispatcher =& new TestAclShellMockShellDispatcher();
$this->Task =& new MockAclShell($this->Dispatcher);
- $this->Task->Dispatch = new $this->Dispatcher;
+ $this->Task->Dispatch =& $this->Dispatcher;
$this->Task->params['datasource'] = 'test_suite';
$this->Task->Acl =& new AclComponent();
$controller = null;
View
2 cake/tests/cases/console/libs/api.test.php
@@ -66,7 +66,7 @@ class ApiShellTest extends CakeTestCase {
function startTest() {
$this->Dispatcher =& new ApiShellMockShellDispatcher();
$this->Shell =& new MockApiShell($this->Dispatcher);
- $this->Shell->Dispatch = new $this->Dispatcher;
+ $this->Shell->Dispatch =& $this->Dispatcher;
}
/**
View
16 cake/tests/cases/console/libs/shell.test.php
@@ -40,10 +40,9 @@
ob_end_clean();
}
-Mock::generatePartial(
- 'ShellDispatcher', 'TestShellMockShellDispatcher',
- array('getInput', 'stdout', 'stderr', '_stop', '_initEnvironment')
- );
+Mock::generatePartial('ShellDispatcher', 'TestShellMockShellDispatcher', array(
+ 'getInput', 'stdout', 'stderr', '_stop', '_initEnvironment'
+));
/**
* TestShell class
@@ -52,13 +51,22 @@
* @subpackage cake.tests.cases.console.libs
*/
class TestShell extends Shell {
+
+/*
+ * name property
+ *
+ * @var name
+ * @access public
+ */
+ var $name = 'TestShell';
/**
* stopped property
*
* @var integer
* @access public
*/
var $stopped;
+
/**
* stop method
*
View
8 cake/tests/cases/libs/controller/components/security.test.php
@@ -391,6 +391,14 @@ function testRequireLogin() {
* @return void
*/
function testDigestAuth() {
+ $skip = $this->skipIf((version_compare(PHP_VERSION, '5.1') == -1) XOR (!function_exists('apache_request_headers')),
+ "%s Cannot run Digest Auth test for PHP versions < 5.1"
+ );
+
+ if ($skip) {
+ return;
+ }
+
$this->Controller->action = 'posted';
$_SERVER['PHP_AUTH_DIGEST'] = $digest = <<<DIGEST
Digest username="Mufasa",
View
20 cake/tests/cases/libs/controller/scaffold.test.php
@@ -254,12 +254,12 @@ class ScaffoldViewTest extends CakeTestCase {
var $fixtures = array('core.article', 'core.user', 'core.comment');
/**
- * setUp method
+ * startTest method
*
* @access public
* @return void
*/
- function setUp() {
+ function startTest() {
$this->Controller =& new ScaffoldMockController();
App::build(array(
@@ -269,12 +269,12 @@ function setUp() {
}
/**
- * tearDown method
+ * endTest method
*
* @access public
* @return void
*/
- function tearDown() {
+ function endTest() {
unset($this->Controller);
App::build();
@@ -481,7 +481,6 @@ function testEditScaffold() {
$this->assertPattern('/textarea name="data\[ScaffoldMock\]\[body\]" cols="30" rows="6" id="ScaffoldMockBody"/', $result);
$this->assertPattern('/<li><a href="\/scaffold_mock\/delete\/1"[^>]*>Delete<\/a>\s*<\/li>/', $result);
}
-
/**
* Test Admin Index Scaffolding.
*
@@ -596,22 +595,22 @@ class ScaffoldTest extends CakeTestCase {
var $fixtures = array('core.article', 'core.user', 'core.comment');
/**
- * setUp method
+ * startTest method
*
* @access public
* @return void
*/
- function setUp() {
+ function startTest() {
$this->Controller =& new ScaffoldMockController();
}
/**
- * tearDown method
+ * endTest method
*
* @access public
* @return void
*/
- function tearDown() {
+ function endTest() {
unset($this->Controller);
}
@@ -647,7 +646,6 @@ function testScaffoldParams() {
$result = $Scaffold->getParams();
$this->assertEqual($result['action'], 'admin_edit');
}
-
/**
* test that the proper names and variable values are set by Scaffold
*
@@ -675,7 +673,7 @@ function testScaffoldVariableSetting() {
$this->Controller->base = '/';
$this->Controller->constructClasses();
$Scaffold =& new TestScaffoldMock($this->Controller, $params);
- $result = $this->Controller->viewVars;
+ $result = $Scaffold->controller->viewVars;
$this->assertEqual($result['singularHumanName'], 'Scaffold Mock');
$this->assertEqual($result['pluralHumanName'], 'Scaffold Mock');
View
18 cake/tests/cases/libs/model/model_behavior.test.php
@@ -264,16 +264,16 @@ function onError(&$model) {
}
echo "onError trigger success";
}
- /**
+/**
* beforeTest method
*
* @param mixed $model
* @access public
* @return void
*/
function beforeTest(&$model) {
- $model->beforeTestResult[] = get_class($this);
- return get_class($this);
+ $model->beforeTestResult[] = strtolower(get_class($this));
+ return strtolower(get_class($this));
}
/**
@@ -1013,24 +1013,24 @@ function testBehaviorMethodDispatchingWithData() {
* @return void
*/
function testBehaviorTrigger() {
- $Apple = new Apple();
+ $Apple =& new Apple();
$Apple->Behaviors->attach('Test');
$Apple->Behaviors->attach('Test2');
$Apple->Behaviors->attach('Test3');
$Apple->beforeTestResult = array();
$Apple->Behaviors->trigger($Apple, 'beforeTest');
- $expected = array('TestBehavior', 'Test2Behavior', 'Test3Behavior');
+ $expected = array('testbehavior', 'test2behavior', 'test3behavior');
$this->assertIdentical($Apple->beforeTestResult, $expected);
$Apple->beforeTestResult = array();
- $Apple->Behaviors->trigger($Apple, 'beforeTest', array(), array('break' => true, 'breakOn' => 'Test2Behavior'));
- $expected = array('TestBehavior', 'Test2Behavior');
+ $Apple->Behaviors->trigger($Apple, 'beforeTest', array(), array('break' => true, 'breakOn' => 'test2behavior'));
+ $expected = array('testbehavior', 'test2behavior');
$this->assertIdentical($Apple->beforeTestResult, $expected);
$Apple->beforeTestResult = array();
- $Apple->Behaviors->trigger($Apple, 'beforeTest', array(), array('break' => true, 'breakOn' => array('Test2Behavior', 'Test3Behavior')));
- $expected = array('TestBehavior', 'Test2Behavior');
+ $Apple->Behaviors->trigger($Apple, 'beforeTest', array(), array('break' => true, 'breakOn' => array('test2behavior', 'test3behavior')));
+ $expected = array('testbehavior', 'test2behavior');
$this->assertIdentical($Apple->beforeTestResult, $expected);
}
View
2 cake/tests/cases/libs/view/helpers/paginator.test.php
@@ -302,7 +302,7 @@ function testSortDir() {
$this->assertEqual($result, $expected);
- unset($this->paginator->params['paging']['article']['options']);
+ unset($this->Paginator->params['paging']['Article']['options']);
$this->Paginator->params['paging']['Article']['options']['direction'] = 'desc';
$result = $this->Paginator->sortDir();
$expected = 'desc';

0 comments on commit 6775e09

Please sign in to comment.
Something went wrong with that request. Please try again.