Skip to content

Commit

Permalink
Fix a bunch of failing tests/errors.
Browse files Browse the repository at this point in the history
  • Loading branch information
markstory committed Mar 15, 2013
1 parent 752d589 commit dd02aee
Show file tree
Hide file tree
Showing 13 changed files with 53 additions and 120 deletions.
11 changes: 0 additions & 11 deletions lib/Cake/Console/Command/Task/ExtractTask.php
Expand Up @@ -182,17 +182,6 @@ public function execute() {
$this->_extractCore = strtolower($response) === 'y';
}

if (!empty($this->params['exclude-plugins']) && $this->_isExtractingApp()) {
$this->_exclude = array_merge($this->_exclude, App::path('plugins'));
}

if (!empty($this->params['ignore-model-validation']) || (!$this->_isExtractingApp() && empty($plugin))) {
$this->_extractValidation = false;
}
if (!empty($this->params['validation-domain'])) {
$this->_validationDomain = $this->params['validation-domain'];
}

if (!empty($this->params['exclude-plugins']) && $this->_isExtractingApp()) {
$this->_exclude = array_merge($this->_exclude, App::path('Plugin'));
}
Expand Down
8 changes: 7 additions & 1 deletion lib/Cake/Console/Shell.php
Expand Up @@ -263,6 +263,10 @@ public function __isset($name) {
if ($name === $class) {
return $this->loadModel($modelClass);
}
list(, $class) = namespaceSplit($modelClass);
if ($name === $class) {
return $this->loadModel($class);
}
}
}
}
Expand Down Expand Up @@ -291,7 +295,9 @@ public function loadModel($modelClass = null, $id = null) {
}

$this->{$modelClass} = ClassRegistry::init(array(
'class' => $plugin . $modelClass, 'alias' => $modelClass, 'id' => $id
'class' => $plugin . $modelClass,
'alias' => $modelClass,
'id' => $id
));
if (!$this->{$modelClass}) {
throw new MissingModelException($modelClass);
Expand Down
6 changes: 3 additions & 3 deletions lib/Cake/Controller/Component/Auth/BaseAuthenticate.php
Expand Up @@ -164,12 +164,12 @@ public function getUser(Request $request) {
/**
* Handle unauthenticated access attempt.
*
* @param CakeRequest $request A request object.
* @param CakeResponse $response A response object.
* @param Cake\Network\Request $request A request object.
* @param Cake\Network\Response $response A response object.
* @return mixed Either true to indicate the unauthenticated request has been
* dealt with and no more action is required by AuthComponent or void (default).
*/
public function unauthenticated(CakeRequest $request, CakeResponse $response) {
public function unauthenticated(Request $request, Response $response) {
}

}
14 changes: 2 additions & 12 deletions lib/Cake/Controller/Component/Auth/BasicAuthenticate.php
Expand Up @@ -92,20 +92,10 @@ public function __construct(ComponentCollection $collection, $settings) {
* @param Cake\Network\Response $response The response to add headers to.
* @return mixed Either false on failure, or an array of user data on success.
*/
public function authenticate(CakeRequest $request, CakeResponse $response) {
public function authenticate(Request $request, Response $response) {
return $this->getUser($request);
}

/**
* Get a user based on information in the request. Used by cookie-less auth for stateless clients.
*
* @param CakeRequest $request Request object.
* @return mixed Either false or an array of user information
*/
public function getUser(CakeRequest $request) {
$username = env('PHP_AUTH_USER');
}

/**
* Get a user based on information in the request. Used by cookie-less auth for stateless clients.
*
Expand All @@ -129,7 +119,7 @@ public function getUser(Request $request) {
* @param CakeResponse $response A response object.
* @return boolean True
*/
public function unauthenticated(CakeRequest $request, CakeResponse $response) {
public function unauthenticated(Request $request, Response $response) {
$response->header($this->loginHeaders());
$response->statusCode(401);
$response->send();
Expand Down
2 changes: 1 addition & 1 deletion lib/Cake/Model/ConnectionManager.php
Expand Up @@ -98,7 +98,7 @@ public static function getDataSource($name) {

$class = static::loadDataSource($name);

if (strpos(App::location($class), 'Datasource') === false) {
if (strpos($class, '\Datasource') === false) {
throw new Error\MissingDatasourceException(array(
'class' => $class,
'plugin' => null,
Expand Down
72 changes: 0 additions & 72 deletions lib/Cake/Test/TestCase/BasicsTest.php
Expand Up @@ -874,78 +874,6 @@ public function testPrCli() {
$this->assertEquals($expected, $result);
}

/**
* test stripslashes_deep()
*
* @return void
*/
public function testStripslashesDeep() {
$this->skipIf(ini_get('magic_quotes_sybase') === '1', 'magic_quotes_sybase is on.');

$this->assertEquals(stripslashes_deep("tes\'t"), "tes't");
$this->assertEquals(stripslashes_deep('tes\\' . chr(0) . 't'), 'tes' . chr(0) . 't');
$this->assertEquals(stripslashes_deep('tes\"t'), 'tes"t');
$this->assertEquals(stripslashes_deep("tes\'t"), "tes't");
$this->assertEquals(stripslashes_deep('te\\st'), 'test');

$nested = array(
'a' => "tes\'t",
'b' => 'tes\\' . chr(0) . 't',
'c' => array(
'd' => 'tes\"t',
'e' => "te\'s\'t",
array('f' => "tes\'t")
),
'g' => 'te\\st'
);
$expected = array(
'a' => "tes't",
'b' => 'tes' . chr(0) . 't',
'c' => array(
'd' => 'tes"t',
'e' => "te's't",
array('f' => "tes't")
),
'g' => 'test'
);
$this->assertEquals($expected, stripslashes_deep($nested));
}

/**
* test stripslashes_deep() with magic_quotes_sybase on
*
* @return void
*/
public function testStripslashesDeepSybase() {
if (!(ini_get('magic_quotes_sybase') === '1')) {
$this->markTestSkipped('magic_quotes_sybase is off');
}

$this->assertEquals(stripslashes_deep("tes\'t"), "tes\'t");

$nested = array(
'a' => "tes't",
'b' => "tes''t",
'c' => array(
'd' => "tes'''t",
'e' => "tes''''t",
array('f' => "tes''t")
),
'g' => "te'''''st"
);
$expected = array(
'a' => "tes't",
'b' => "tes't",
'c' => array(
'd' => "tes''t",
'e' => "tes''t",
array('f' => "tes't")
),
'g' => "te'''st"
);
$this->assertEquals($expected, stripslashes_deep($nested));
}

/**
* test pluginSplit
*
Expand Down
Expand Up @@ -248,7 +248,9 @@ public function testExtractExcludePlugins() {
array('_isExtractingApp', '_extractValidationMessages', 'in', 'out', 'err', 'clear', '_stop'),
array($this->out, $this->out, $this->in)
);
$this->Task->expects($this->exactly(2))->method('_isExtractingApp')->will($this->returnValue(true));
$this->Task->expects($this->exactly(2))
->method('_isExtractingApp')
->will($this->returnValue(true));

$this->Task->params['paths'] = CAKE . 'Test/TestApp/';
$this->Task->params['output'] = $this->path . DS;
Expand Down Expand Up @@ -305,7 +307,9 @@ public function testExtractModelValidation() {
array('_isExtractingApp', 'in', 'out', 'err', 'clear', '_stop'),
array($this->out, $this->out, $this->in)
);
$this->Task->expects($this->exactly(2))->method('_isExtractingApp')->will($this->returnValue(true));
$this->Task->expects($this->exactly(2))
->method('_isExtractingApp')
->will($this->returnValue(true));

$this->Task->params['paths'] = CAKE . 'Test/TestApp/';
$this->Task->params['output'] = $this->path . DS;
Expand Down
30 changes: 22 additions & 8 deletions lib/Cake/Test/TestCase/Console/ShellTest.php
Expand Up @@ -16,12 +16,24 @@

use Cake\Console\Shell;
use Cake\Core\App;
use Cake\Core\Configure;
use Cake\Core\Plugin;
use Cake\Log\Log;
use Cake\TestSuite\TestCase;
use Cake\Utility\Folder;
use Cake\Utility\Hash;

/**
* Class for testing merging vars
*/
class MergeShell extends Shell {

public $tasks = array('DbConfig', 'Fixture');

public $uses = array('Comment');

}

/**
* ShellTestShell class
*
Expand Down Expand Up @@ -158,6 +170,7 @@ public function testInitialize() {
'Plugin' => array(CAKE . 'Test/TestApp/Plugin/'),
'Model' => array(CAKE . 'Test/TestApp/Model/')
), App::RESET);
Configure::write('App.namespace', 'TestApp');

Plugin::load('TestPlugin');
$this->Shell->uses = array('TestPlugin.TestPluginPost');
Expand All @@ -172,7 +185,7 @@ public function testInitialize() {
$this->Shell->initialize();
$this->assertTrue(isset($this->Shell->Comment));
$this->assertInstanceOf('TestApp\Model\Comment', $this->Shell->Comment);
$this->assertEquals('Comment', $this->Shell->modelClass);
$this->assertEquals('TestApp\Model\Comment', $this->Shell->modelClass);

App::build();
}
Expand All @@ -184,23 +197,24 @@ public function testInitialize() {
*/
public function testLoadModel() {
App::build(array(
'Plugin' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS),
'Model' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'Model' . DS)
'Plugin' => array(CAKE . 'Test' . DS . 'TestApp' . DS . 'Plugin' . DS),
'Model' => array(CAKE . 'Test' . DS . 'TestApp' . DS . 'Model' . DS)
), App::RESET);
Configure::write('App.namespace', 'TestApp');

$Shell = new TestMergeShell();
$Shell = new MergeShell();
$this->assertEquals('Comment', $Shell->Comment->alias);
$this->assertInstanceOf('Comment', $Shell->Comment);
$this->assertInstanceOf('TestApp\Model\Comment', $Shell->Comment);
$this->assertEquals('Comment', $Shell->modelClass);

CakePlugin::load('TestPlugin');
Plugin::load('TestPlugin');
$this->Shell->loadModel('TestPlugin.TestPluginPost');
$this->assertTrue(isset($this->Shell->TestPluginPost));
$this->assertInstanceOf('TestPluginPost', $this->Shell->TestPluginPost);
$this->assertInstanceOf('TestPlugin\Model\TestPluginPost', $this->Shell->TestPluginPost);
$this->assertEquals('TestPluginPost', $this->Shell->modelClass);
CakePlugin::unload('TestPlugin');

App::build();
Plugin::unload('TestPlugin');
}

/**
Expand Down
Expand Up @@ -24,6 +24,7 @@
use Cake\Controller\Controller;
use Cake\Core\App;
use Cake\Core\Configure;
use Cake\Model\Datasource\Session;
use Cake\Network\Request;
use Cake\Network\Response;
use Cake\Routing\Dispatcher;
Expand Down Expand Up @@ -1104,9 +1105,9 @@ public function testUser() {
* @return void
*/
public function testStatelessAuthNoRedirect() {
if (CakeSession::id()) {
if (Session::id()) {
session_destroy();
CakeSession::$id = null;
Session::$id = null;
}
$_SESSION = null;

Expand All @@ -1125,7 +1126,7 @@ public function testStatelessAuthNoRedirect() {
$this->assertFalse($result);

$this->assertNull($this->Controller->testUrl);
$this->assertNull(CakeSession::id());
$this->assertNull(Session::id());
}

/**
Expand All @@ -1134,9 +1135,9 @@ public function testStatelessAuthNoRedirect() {
* @return void
*/
public function testStatelessAuthNoSessionStart() {
if (CakeSession::id()) {
if (Session::id()) {
session_destroy();
CakeSession::$id = null;
Session::$id = null;
}
$_SESSION = null;

Expand All @@ -1151,7 +1152,7 @@ public function testStatelessAuthNoSessionStart() {
$result = $this->Auth->startup($this->Controller);
$this->assertTrue($result);

$this->assertNull(CakeSession::id());
$this->assertNull(Session::id());
}

/**
Expand Down
6 changes: 3 additions & 3 deletions lib/Cake/Test/TestCase/View/Helper/FormHelperTest.php
Expand Up @@ -5872,7 +5872,7 @@ public function testMonth() {
$result = $this->Form->month('Project.release');

$expected = array(
array('select' => array('name' => 'data[Project][release][month]', 'id' => 'ProjectReleaseMonth')),
array('select' => array('name' => 'Project[release][month]', 'id' => 'ProjectReleaseMonth')),
array('option' => array('value' => '')),
'/option',
array('option' => array('value' => '01')),
Expand Down Expand Up @@ -5977,7 +5977,7 @@ public function testDay() {
$result = $this->Form->day('Project.release');

$expected = array(
array('select' => array('name' => 'data[Project][release][day]', 'id' => 'ProjectReleaseDay')),
array('select' => array('name' => 'Project[release][day]', 'id' => 'ProjectReleaseDay')),
array('option' => array('value' => '')),
'/option',
array('option' => array('value' => '01')),
Expand Down Expand Up @@ -6168,7 +6168,7 @@ public function testHour() {
$this->Form->request->data['Model']['field'] = '2050-10-10 01:12:32';
$result = $this->Form->hour('Model.field', true);
$expected = array(
array('select' => array('name' => 'data[Model][field][hour]', 'id' => 'ModelFieldHour')),
array('select' => array('name' => 'Model[field][hour]', 'id' => 'ModelFieldHour')),
array('option' => array('value' => '')),
'/option',
array('option' => array('value' => '00')),
Expand Down
1 change: 0 additions & 1 deletion lib/Cake/TestSuite/Fixture/FixtureManager.php
Expand Up @@ -234,7 +234,6 @@ public function unload(TestCase $test) {
* @throws UnexpectedValueException if $name is not a previously loaded class
*/
public function loadSingle($name, $db = null, $dropTables = true) {
$name .= 'Fixture';
if (isset($this->_fixtureMap[$name])) {
$fixture = $this->_fixtureMap[$name];
if (!$db) {
Expand Down
1 change: 1 addition & 0 deletions lib/Cake/Utility/Xml.php
Expand Up @@ -24,6 +24,7 @@
use Cake\Core\Configure;
use Cake\Error;
use Cake\Network\Http\Client;
use \DOMDocument;

/**
* XML handling for Cake.
Expand Down
1 change: 1 addition & 0 deletions lib/Cake/View/Helper/FormHelper.php
Expand Up @@ -23,6 +23,7 @@
use Cake\Utility\Security;
use Cake\View\Helper;
use Cake\View\View;
use \DateTime;

/**
* Form helper library.
Expand Down

0 comments on commit dd02aee

Please sign in to comment.