Skip to content
Permalink
Browse files

Fix failing tests after a merge with 2.5

  • Loading branch information...
markstory committed Oct 16, 2013
1 parent 8393dac commit a7c654df3849c063293e0b8e9ea620348640b596
@@ -17,6 +17,7 @@
use Cake\Cache\CacheEngine;
use Cake\Error;
use Cake\Utility\Inflector;
use \Memcached;
/**
* Memcached storage engine for cache. Memcached has some limitations in the amount of
@@ -85,7 +86,6 @@ public function init($settings = array()) {
$settings['prefix'] = Inflector::slug(APP_DIR) . '_';
}
$settings += array(
'engine' => 'Memcached',
'servers' => array('127.0.0.1'),
'compress' => false,
'persistent' => false,
@@ -9,19 +9,17 @@
*
* @copyright Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
* @link http://cakephp.org CakePHP Project
* @package Cake.Console.Command
* @since CakePHP v 2.5
* @license http://www.opensource.org/licenses/mit-license.php MIT License
*/
namespace Cake\Console\Command;
App::uses('AppShell', 'Console/Command');
use Cake\Console\Shell;
/**
* Provide command completion shells such as bash.
*
* @package Cake.Console.Command
*/
class CompletionShell extends AppShell {
class CompletionShell extends Shell {
/**
* Contains tasks to load and instantiate
@@ -12,15 +12,21 @@
* @since CakePHP(tm) v 2.5
* @license http://www.opensource.org/licenses/mit-license.php MIT License
*/
namespace Cake\Console\Command\Task;
App::uses('AppShell', 'Console/Command');
use Cake\Console\ConsoleOptionParser;
use Cake\Console\Shell;
use Cake\Core\App;
use Cake\Core\Plugin;
use Cake\Utility\Inflector;
use \ReflectionClass;
use \ReflectionMethod;
/**
* Base class for Shell Command reflection.
*
* @package Cake.Console.Command.Task
*/
class CommandTask extends AppShell {
class CommandTask extends Shell {
/**
* Gets the shell command listing.
@@ -30,7 +36,7 @@ class CommandTask extends AppShell {
public function getShellList() {
$skipFiles = array('AppShell');
$plugins = CakePlugin::loaded();
$plugins = Plugin::loaded();
$shellList = array_fill_keys($plugins, null) + array('CORE' => null, 'app' => null);
$corePath = App::core('Console/Command');
@@ -100,22 +106,22 @@ public function subCommands($commandName) {
return array();
}
$taskMap = TaskCollection::normalizeObjectArray((array)$Shell->tasks);
$taskMap = $this->Tasks->normalizeArray((array)$Shell->tasks);
$return = array_keys($taskMap);
$return = array_map('Inflector::underscore', $return);
$return = array_map('Cake\Utility\Inflector::underscore', $return);
$ShellReflection = new ReflectionClass('AppShell');
$shellMethods = $ShellReflection->getMethods(ReflectionMethod::IS_PUBLIC);
$shellMethodNames = array('main', 'help');
foreach ($shellMethods as $method) {
$shellMethodNames[] = $method->getName();
}
$baseClasses = ['Object', 'Shell', 'AppShell'];
$Reflection = new ReflectionClass($Shell);
$methods = $Reflection->getMethods(ReflectionMethod::IS_PUBLIC);
$methodNames = array();
foreach ($methods as $method) {
$methodNames[] = $method->getName();
$declaringClass = $method->getDeclaringClass()->getShortName();
if (!in_array($declaringClass, $baseClasses)) {
$methodNames[] = $method->getName();
}
}
$return += array_diff($methodNames, $shellMethodNames);
@@ -144,8 +150,10 @@ public function getShell($commandName) {
$name = Inflector::camelize($name);
$pluginDot = Inflector::camelize($pluginDot);
$class = $name . 'Shell';
APP::uses($class, $pluginDot . 'Console/Command');
$class = App::classname($pluginDot . $name, 'Console/Command', 'Shell');
if (!$class) {
return false;
}
$Shell = new $class();
$Shell->plugin = trim($pluginDot, '.');
@@ -21,6 +21,7 @@
use Cake\Core\Configure;
use Cake\Error;
use Cake\Event\Event;
use Cake\Network\Request;
use Cake\Network\Response;
use Cake\Routing\Router;
use Cake\Utility\Inflector;
@@ -410,7 +411,7 @@ public function requestedWith($type = null) {
list($contentType) = explode(';', env('CONTENT_TYPE'));
if ($contentType === '') {
list($contentType) = explode(';', CakeRequest::header('CONTENT_TYPE'));
list($contentType) = explode(';', Request::header('CONTENT_TYPE'));
}
if (!$type) {
return $this->response->mapType($contentType);
@@ -15,6 +15,9 @@ endif;
<p>
<a href="http://cakephp.org/changelogs/<?php echo Configure::version(); ?>"><?php echo __d('cake_dev', 'Read the changelog'); ?> </a>
</p>
<?php
if (file_exists(WWW_ROOT . 'css' . DS . 'cake.generic.css')):
?>
<p id="url-rewriting-warning" style="background-color:#e32; color:#fff;">
<?php echo __d('cake_dev', 'URL rewriting is not properly configured on your server.'); ?>
1) <a target="_blank" href="http://book.cakephp.org/2.0/en/installation/url-rewriting.html" style="color:#fff;">Help me configure it</a>
@@ -94,7 +97,7 @@ endif;
?>
</p>
<?php
if (!Validation::alphaNumeric('cakephp')) {
if (!Validation::alphaNumeric('cakephp')):
echo '<p><span class="notice">';
echo __d('cake_dev', 'PCRE has not been compiled with Unicode support.');
echo '<br/>';
@@ -418,17 +418,18 @@ public function testEnableDisableEnabled() {
* @return void
*/
public function testRemember() {
$this->_configCache();
$counter = 0;
$cacher = function () use ($counter){
return 'This is some data ' . $counter;
};
$expected = 'This is some data 0';
$result = Cache::remember('test_key', $cacher, 'default');
$result = Cache::remember('test_key', $cacher, 'tests');
$this->assertEquals($expected, $result);
$counter = 1;
$result = Cache::remember('test_key', $cacher, 'default');
$result = Cache::remember('test_key', $cacher, 'tests');
$this->assertEquals($expected, $result);
}
@@ -20,6 +20,7 @@
use Cake\Cache\Engine\MemcachedEngine;
use Cake\Core\Configure;
use Cake\TestSuite\TestCase;
use \Memcached;
/**
* Class TestMemcachedEngine
@@ -111,7 +112,6 @@ public function testSettings() {
'servers' => array('127.0.0.1'),
'persistent' => false,
'compress' => false,
'engine' => 'Memcached',
'login' => null,
'password' => null,
'groups' => array(),
@@ -153,14 +153,14 @@ public function testCompressionSetting() {
public function testInvalidSerializerSetting() {
$Memcached = new TestMemcachedEngine();
$settings = array(
'engine' => 'Memcached',
'className' => 'Memcached',
'servers' => array('127.0.0.1:11211'),
'persistent' => false,
'serialize' => 'invalid_serializer'
);
$this->setExpectedException(
'CacheException', 'invalid_serializer is not a valid serializer engine for Memcached'
'Cake\Error\Exception', 'invalid_serializer is not a valid serializer engine for Memcached'
);
$Memcached->init($settings);
}
@@ -173,7 +173,7 @@ public function testInvalidSerializerSetting() {
public function testPhpSerializerSetting() {
$Memcached = new TestMemcachedEngine();
$settings = array(
'engine' => 'Memcached',
'className' => 'Memcached',
'servers' => array('127.0.0.1:11211'),
'persistent' => false,
'serialize' => 'php'
@@ -242,14 +242,14 @@ public function testJsonSerializerThrowException() {
$Memcached = new TestMemcachedEngine();
$settings = array(
'engine' => 'Memcached',
'className' => 'Memcached',
'servers' => array('127.0.0.1:11211'),
'persistent' => false,
'serialize' => 'json'
);
$this->setExpectedException(
'CacheException', 'Memcached extension is not compiled with json support'
'Cake\Error\Exception', 'Memcached extension is not compiled with json support'
);
$Memcached->init($settings);
}
@@ -274,7 +274,7 @@ public function testIgbinarySerializerThrowException() {
);
$this->setExpectedException(
'CacheException', 'Memcached extension is not compiled with igbinary support'
'Cake\Error\Exception', 'Memcached extension is not compiled with igbinary support'
);
$Memcached->init($settings);
}
@@ -1,9 +1,5 @@
<?php
/**
* CommandListShellTest file
*
* PHP 5
*
* CakePHP : Rapid Development Framework (http://cakephp.org)
* Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
*
@@ -64,7 +60,7 @@ public function setUp() {
);
$this->Shell->Command = $this->getMock(
'CommandTask',
'Cake\Console\Command\Task\CommandTask',
array('in', '_stop', 'clear'),
array($out, $out, $in)
);
@@ -96,7 +92,7 @@ public function testMain() {
$expected = "/\[.*TestPluginTwo.*\] example, welcome/";
$this->assertRegExp($expected, $output);
$expected = "/\[.*CORE.*\] acl, api, bake, completion, command_list, i18n, schema, server, test, upgrade/";
$expected = "/\[.*CORE.*\] acl, api, bake, command_list, completion, i18n, schema, server, test, upgrade/";
$this->assertRegExp($expected, $output);
$expected = "/\[.*app.*\] sample/";
@@ -1,9 +1,5 @@
<?php
/**
* CompletionShellTest file
*
* PHP 5
*
* CakePHP : Rapid Development Framework (http://cakephp.org)
* Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
*
@@ -13,21 +9,22 @@
*
* @copyright Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
* @link http://cakephp.org CakePHP Project
* @package Cake.Test.Case.Console.Command
* @since CakePHP v 2.5
* @license http://www.opensource.org/licenses/mit-license.php MIT License
*/
namespace Cake\Console\Command;
App::uses('CompletionShell', 'Console/Command');
App::uses('ConsoleOutput', 'Console');
App::uses('ConsoleInput', 'Console');
App::uses('Shell', 'Console');
App::uses('CommandTask', 'Console/Command/Task');
use Cake\Console\Command\CompletionShell;
use Cake\Console\Command\Task\CommandTask;
use Cake\Console\ConsoleOutput;
use Cake\Console\ConsoleInput;
use Cake\Console\Shell;
use Cake\Core\Plugin;
use Cake\TestSuite\TestCase;
/**
* Class TestCompletionStringOutput
*
* @package Cake.Test.Case.Console.Command
*/
class TestCompletionStringOutput extends ConsoleOutput {
@@ -41,10 +38,8 @@ protected function _write($message) {
/**
* Class CompletionShellTest
*
* @package Cake.Test.Case.Console.Command
*/
class CompletionShellTest extends CakeTestCase {
class CompletionShellTest extends TestCase {
/**
* setUp method
@@ -53,27 +48,19 @@ class CompletionShellTest extends CakeTestCase {
*/
public function setUp() {
parent::setUp();
App::build(array(
'Plugin' => array(
CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS
),
'Console/Command' => array(
CAKE . 'Test' . DS . 'test_app' . DS . 'Console' . DS . 'Command' . DS
)
), App::RESET);
CakePlugin::load(array('TestPlugin', 'TestPluginTwo'));
Plugin::load(array('TestPlugin', 'TestPluginTwo'));
$out = new TestCompletionStringOutput();
$in = $this->getMock('ConsoleInput', array(), array(), '', false);
$in = $this->getMock('Cake\Console\ConsoleInput', array(), array(), '', false);
$this->Shell = $this->getMock(
'CompletionShell',
'Cake\Console\Command\CompletionShell',
array('in', '_stop', 'clear'),
array($out, $out, $in)
);
$this->Shell->Command = $this->getMock(
'CommandTask',
'Cake\Console\Command\Task\CommandTask',
array('in', '_stop', 'clear'),
array($out, $out, $in)
);
@@ -87,7 +74,7 @@ public function setUp() {
public function tearDown() {
parent::tearDown();
unset($this->Shell);
CakePlugin::unload();
Plugin::unload();
}
/**
@@ -125,7 +112,7 @@ public function testCommands() {
$this->Shell->runCommand('commands', array());
$output = $this->Shell->stdout->output;
$expected = "TestPlugin.example TestPluginTwo.example TestPluginTwo.welcome acl api bake command_list completion console i18n schema server test testsuite upgrade sample\n";
$expected = "TestPlugin.example TestPluginTwo.example TestPluginTwo.welcome acl api bake command_list completion i18n schema server test upgrade sample\n";
$this->assertEquals($expected, $output);
}
@@ -139,7 +139,7 @@ public function testExecute() {
$this->assertRegExp($pattern, $result);
$pattern = '/\#: (\\\\|\/)extract\.ctp:14\n';
$pattern .= '\#: (\\\\|\/)home\.ctp:119\n';
$pattern .= '\#: (\\\\|\/)home\.ctp:125\n';
$pattern .= 'msgid "Editing this Page"\nmsgstr ""/';
$this->assertRegExp($pattern, $result);
@@ -254,7 +254,8 @@ public function testInititalizeFirefoxHeaderNotXml() {
$_SERVER['HTTP_ACCEPT'] = 'text/html,application/xhtml+xml,application/xml;image/png,image/jpeg,image/*;q=0.9,*/*;q=0.8';
Router::parseExtensions('xml', 'json');
$this->RequestHandler->initialize($this->Controller);
$event = new Event('Controller.initialize', $this->Controller);
$this->RequestHandler->initialize($event);
$this->assertNull($this->RequestHandler->ext);
}
@@ -952,7 +952,7 @@ public function testUseConfigString() {
*/
public function testSendWithNoContentDoesNotOverwriteViewVar() {
$this->CakeEmail->reset();
$this->CakeEmail->transport('Debug');
$this->CakeEmail->transport('debug');
$this->CakeEmail->from('cake@cakephp.org');
$this->CakeEmail->to('you@cakephp.org');
$this->CakeEmail->subject('My title');
Oops, something went wrong.

0 comments on commit a7c654d

Please sign in to comment.
You can’t perform that action at this time.