Merge branch '1.2' into 1.3

This commit is contained in:
gwoo 2009-08-03 13:13:18 -07:00
commit 6775e0997e
11 changed files with 76 additions and 32 deletions

View file

@ -843,7 +843,7 @@ if (!function_exists('file_put_contents')) {
foreach ($args[0] as $valueKey => $valueData) { foreach ($args[0] as $valueKey => $valueData) {
for ($i = 1; $i < $argc; $i++) { for ($i = 1; $i < $argc; $i++) {
if (isset($args[$i][$valueKey])) { if (array_key_exists($valueKey, $args[$i])) {
continue 2; continue 2;
} }
} }

View file

@ -351,7 +351,7 @@ class SecurityComponent extends Object {
if (strtolower($options['type']) == 'digest') { if (strtolower($options['type']) == 'digest') {
$out[] = 'qop="auth"'; $out[] = 'qop="auth"';
$out[] = 'nonce="' . uniqid() . '"'; $out[] = 'nonce="' . uniqid("") . '"';
$out[] = 'opaque="' . md5($options['realm']).'"'; $out[] = 'opaque="' . md5($options['realm']).'"';
} }

View file

@ -1028,7 +1028,7 @@ class Controller extends Object {
} }
} elseif (empty($object) || $object === null) { } elseif (empty($object) || $object === null) {
if (isset($this->{$this->modelClass})) { if (isset($this->{$this->modelClass})) {
$object = $this->{$this->modelClass}; $object =& $this->{$this->modelClass};
} else { } else {
$className = null; $className = null;
$name = $this->uses[0]; $name = $this->uses[0];
@ -1036,9 +1036,9 @@ class Controller extends Object {
list($name, $className) = explode('.', $this->uses[0]); list($name, $className) = explode('.', $this->uses[0]);
} }
if ($className) { if ($className) {
$object = $this->{$className}; $object =& $this->{$className};
} else { } else {
$object = $this->{$name}; $object =& $this->{$name};
} }
} }
} }

View file

@ -60,6 +60,36 @@ class BasicsTest extends CakeTestCase {
Configure::write('Config.language', $this->_language); Configure::write('Config.language', $this->_language);
} }
/**
* 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 * testHttpBase method
* *

View file

@ -92,7 +92,7 @@ class AclShellTest extends CakeTestCase {
function startTest() { function startTest() {
$this->Dispatcher =& new TestAclShellMockShellDispatcher(); $this->Dispatcher =& new TestAclShellMockShellDispatcher();
$this->Task =& new MockAclShell($this->Dispatcher); $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->params['datasource'] = 'test_suite';
$this->Task->Acl =& new AclComponent(); $this->Task->Acl =& new AclComponent();
$controller = null; $controller = null;

View file

@ -66,7 +66,7 @@ class ApiShellTest extends CakeTestCase {
function startTest() { function startTest() {
$this->Dispatcher =& new ApiShellMockShellDispatcher(); $this->Dispatcher =& new ApiShellMockShellDispatcher();
$this->Shell =& new MockApiShell($this->Dispatcher); $this->Shell =& new MockApiShell($this->Dispatcher);
$this->Shell->Dispatch = new $this->Dispatcher; $this->Shell->Dispatch =& $this->Dispatcher;
} }
/** /**

View file

@ -40,10 +40,9 @@ if (!class_exists('ShellDispatcher')) {
ob_end_clean(); ob_end_clean();
} }
Mock::generatePartial( Mock::generatePartial('ShellDispatcher', 'TestShellMockShellDispatcher', array(
'ShellDispatcher', 'TestShellMockShellDispatcher', 'getInput', 'stdout', 'stderr', '_stop', '_initEnvironment'
array('getInput', 'stdout', 'stderr', '_stop', '_initEnvironment') ));
);
/** /**
* TestShell class * TestShell class
@ -52,6 +51,14 @@ Mock::generatePartial(
* @subpackage cake.tests.cases.console.libs * @subpackage cake.tests.cases.console.libs
*/ */
class TestShell extends Shell { class TestShell extends Shell {
/*
* name property
*
* @var name
* @access public
*/
var $name = 'TestShell';
/** /**
* stopped property * stopped property
* *
@ -59,6 +66,7 @@ class TestShell extends Shell {
* @access public * @access public
*/ */
var $stopped; var $stopped;
/** /**
* stop method * stop method
* *

View file

@ -391,6 +391,14 @@ class SecurityComponentTest extends CakeTestCase {
* @return void * @return void
*/ */
function testDigestAuth() { 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'; $this->Controller->action = 'posted';
$_SERVER['PHP_AUTH_DIGEST'] = $digest = <<<DIGEST $_SERVER['PHP_AUTH_DIGEST'] = $digest = <<<DIGEST
Digest username="Mufasa", Digest username="Mufasa",

View file

@ -254,12 +254,12 @@ class ScaffoldViewTest extends CakeTestCase {
var $fixtures = array('core.article', 'core.user', 'core.comment'); var $fixtures = array('core.article', 'core.user', 'core.comment');
/** /**
* setUp method * startTest method
* *
* @access public * @access public
* @return void * @return void
*/ */
function setUp() { function startTest() {
$this->Controller =& new ScaffoldMockController(); $this->Controller =& new ScaffoldMockController();
App::build(array( App::build(array(
@ -269,12 +269,12 @@ class ScaffoldViewTest extends CakeTestCase {
} }
/** /**
* tearDown method * endTest method
* *
* @access public * @access public
* @return void * @return void
*/ */
function tearDown() { function endTest() {
unset($this->Controller); unset($this->Controller);
App::build(); App::build();
@ -481,7 +481,6 @@ class ScaffoldViewTest extends CakeTestCase {
$this->assertPattern('/textarea name="data\[ScaffoldMock\]\[body\]" cols="30" rows="6" id="ScaffoldMockBody"/', $result); $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); $this->assertPattern('/<li><a href="\/scaffold_mock\/delete\/1"[^>]*>Delete<\/a>\s*<\/li>/', $result);
} }
/** /**
* Test Admin Index Scaffolding. * Test Admin Index Scaffolding.
* *
@ -596,22 +595,22 @@ class ScaffoldTest extends CakeTestCase {
var $fixtures = array('core.article', 'core.user', 'core.comment'); var $fixtures = array('core.article', 'core.user', 'core.comment');
/** /**
* setUp method * startTest method
* *
* @access public * @access public
* @return void * @return void
*/ */
function setUp() { function startTest() {
$this->Controller =& new ScaffoldMockController(); $this->Controller =& new ScaffoldMockController();
} }
/** /**
* tearDown method * endTest method
* *
* @access public * @access public
* @return void * @return void
*/ */
function tearDown() { function endTest() {
unset($this->Controller); unset($this->Controller);
} }
@ -647,7 +646,6 @@ class ScaffoldTest extends CakeTestCase {
$result = $Scaffold->getParams(); $result = $Scaffold->getParams();
$this->assertEqual($result['action'], 'admin_edit'); $this->assertEqual($result['action'], 'admin_edit');
} }
/** /**
* test that the proper names and variable values are set by Scaffold * test that the proper names and variable values are set by Scaffold
* *
@ -675,7 +673,7 @@ class ScaffoldTest extends CakeTestCase {
$this->Controller->base = '/'; $this->Controller->base = '/';
$this->Controller->constructClasses(); $this->Controller->constructClasses();
$Scaffold =& new TestScaffoldMock($this->Controller, $params); $Scaffold =& new TestScaffoldMock($this->Controller, $params);
$result = $this->Controller->viewVars; $result = $Scaffold->controller->viewVars;
$this->assertEqual($result['singularHumanName'], 'Scaffold Mock'); $this->assertEqual($result['singularHumanName'], 'Scaffold Mock');
$this->assertEqual($result['pluralHumanName'], 'Scaffold Mock'); $this->assertEqual($result['pluralHumanName'], 'Scaffold Mock');

View file

@ -264,7 +264,7 @@ class TestBehavior extends ModelBehavior {
} }
echo "onError trigger success"; echo "onError trigger success";
} }
/** /**
* beforeTest method * beforeTest method
* *
* @param mixed $model * @param mixed $model
@ -272,8 +272,8 @@ class TestBehavior extends ModelBehavior {
* @return void * @return void
*/ */
function beforeTest(&$model) { function beforeTest(&$model) {
$model->beforeTestResult[] = get_class($this); $model->beforeTestResult[] = strtolower(get_class($this));
return get_class($this); return strtolower(get_class($this));
} }
/** /**
@ -1013,24 +1013,24 @@ class BehaviorTest extends CakeTestCase {
* @return void * @return void
*/ */
function testBehaviorTrigger() { function testBehaviorTrigger() {
$Apple = new Apple(); $Apple =& new Apple();
$Apple->Behaviors->attach('Test'); $Apple->Behaviors->attach('Test');
$Apple->Behaviors->attach('Test2'); $Apple->Behaviors->attach('Test2');
$Apple->Behaviors->attach('Test3'); $Apple->Behaviors->attach('Test3');
$Apple->beforeTestResult = array(); $Apple->beforeTestResult = array();
$Apple->Behaviors->trigger($Apple, 'beforeTest'); $Apple->Behaviors->trigger($Apple, 'beforeTest');
$expected = array('TestBehavior', 'Test2Behavior', 'Test3Behavior'); $expected = array('testbehavior', 'test2behavior', 'test3behavior');
$this->assertIdentical($Apple->beforeTestResult, $expected); $this->assertIdentical($Apple->beforeTestResult, $expected);
$Apple->beforeTestResult = array(); $Apple->beforeTestResult = array();
$Apple->Behaviors->trigger($Apple, 'beforeTest', array(), array('break' => true, 'breakOn' => 'Test2Behavior')); $Apple->Behaviors->trigger($Apple, 'beforeTest', array(), array('break' => true, 'breakOn' => 'test2behavior'));
$expected = array('TestBehavior', 'Test2Behavior'); $expected = array('testbehavior', 'test2behavior');
$this->assertIdentical($Apple->beforeTestResult, $expected); $this->assertIdentical($Apple->beforeTestResult, $expected);
$Apple->beforeTestResult = array(); $Apple->beforeTestResult = array();
$Apple->Behaviors->trigger($Apple, 'beforeTest', array(), array('break' => true, 'breakOn' => array('Test2Behavior', 'Test3Behavior'))); $Apple->Behaviors->trigger($Apple, 'beforeTest', array(), array('break' => true, 'breakOn' => array('test2behavior', 'test3behavior')));
$expected = array('TestBehavior', 'Test2Behavior'); $expected = array('testbehavior', 'test2behavior');
$this->assertIdentical($Apple->beforeTestResult, $expected); $this->assertIdentical($Apple->beforeTestResult, $expected);
} }

View file

@ -302,7 +302,7 @@ class PaginatorHelperTest extends CakeTestCase {
$this->assertEqual($result, $expected); $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'; $this->Paginator->params['paging']['Article']['options']['direction'] = 'desc';
$result = $this->Paginator->sortDir(); $result = $this->Paginator->sortDir();
$expected = 'desc'; $expected = 'desc';