Skip to content

Commit

Permalink
Merge branch '1.2' into 1.3
Browse files Browse the repository at this point in the history
  • Loading branch information
gwoo committed Aug 3, 2009
2 parents 33adb6e + 92fd7cf commit 6775e09
Show file tree
Hide file tree
Showing 11 changed files with 76 additions and 32 deletions.
2 changes: 1 addition & 1 deletion cake/basics.php
Expand Up @@ -843,7 +843,7 @@ function array_diff_key() {


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;
} }
} }
Expand Down
2 changes: 1 addition & 1 deletion cake/libs/controller/components/security.php
Expand Up @@ -351,7 +351,7 @@ function loginRequest($options = array()) {


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']).'"';
} }


Expand Down
6 changes: 3 additions & 3 deletions cake/libs/controller/controller.php
Expand Up @@ -1028,17 +1028,17 @@ function paginate($object = null, $scope = array(), $whitelist = array()) {
} }
} 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];
if (strpos($this->uses[0], '.') !== false) { if (strpos($this->uses[0], '.') !== false) {
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};
} }
} }
} }
Expand Down
30 changes: 30 additions & 0 deletions cake/tests/cases/basics.test.php
Expand Up @@ -60,6 +60,36 @@ function tearDown() {
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
* *
Expand Down
2 changes: 1 addition & 1 deletion cake/tests/cases/console/libs/acl.test.php
Expand Up @@ -92,7 +92,7 @@ function endCase() {
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;
Expand Down
2 changes: 1 addition & 1 deletion cake/tests/cases/console/libs/api.test.php
Expand Up @@ -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;
} }


/** /**
Expand Down
16 changes: 12 additions & 4 deletions cake/tests/cases/console/libs/shell.test.php
Expand Up @@ -40,10 +40,9 @@
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
Expand All @@ -52,13 +51,22 @@
* @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
* *
* @var integer * @var integer
* @access public * @access public
*/ */
var $stopped; var $stopped;

/** /**
* stop method * stop method
* *
Expand Down
8 changes: 8 additions & 0 deletions cake/tests/cases/libs/controller/components/security.test.php
Expand Up @@ -391,6 +391,14 @@ function testRequireLogin() {
* @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",
Expand Down
20 changes: 9 additions & 11 deletions cake/tests/cases/libs/controller/scaffold.test.php
Expand Up @@ -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(
Expand All @@ -269,12 +269,12 @@ function setUp() {
} }


/** /**
* 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();
Expand Down Expand Up @@ -481,7 +481,6 @@ function testEditScaffold() {
$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.
* *
Expand Down Expand Up @@ -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);
} }


Expand Down Expand Up @@ -647,7 +646,6 @@ function testScaffoldParams() {
$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
* *
Expand Down Expand Up @@ -675,7 +673,7 @@ function testScaffoldVariableSetting() {
$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');
Expand Down
18 changes: 9 additions & 9 deletions cake/tests/cases/libs/model/model_behavior.test.php
Expand Up @@ -264,16 +264,16 @@ function onError(&$model) {
} }
echo "onError trigger success"; echo "onError trigger success";
} }
/** /**
* beforeTest method * beforeTest method
* *
* @param mixed $model * @param mixed $model
* @access public * @access public
* @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));
} }


/** /**
Expand Down Expand Up @@ -1013,24 +1013,24 @@ function testBehaviorMethodDispatchingWithData() {
* @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);
} }


Expand Down
2 changes: 1 addition & 1 deletion cake/tests/cases/libs/view/helpers/paginator.test.php
Expand Up @@ -302,7 +302,7 @@ function testSortDir() {


$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';
Expand Down

0 comments on commit 6775e09

Please sign in to comment.