ソースを参照

Fix failing tests after a merge with 2.5

mark_story 12 年 前
コミット
a7c654df38

+ 1 - 1
Cake/Cache/Engine/MemcachedEngine.php

@@ -17,6 +17,7 @@ namespace Cake\Cache\Engine;
 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 @@ class MemcachedEngine extends CacheEngine {
 			$settings['prefix'] = Inflector::slug(APP_DIR) . '_';
 		}
 		$settings += array(
-			'engine' => 'Memcached',
 			'servers' => array('127.0.0.1'),
 			'compress' => false,
 			'persistent' => false,

+ 3 - 5
lib/Cake/Console/Command/CompletionShell.php

@@ -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

+ 22 - 14
lib/Cake/Console/Command/Task/CommandTask.php

@@ -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 @@ class CommandTask extends AppShell {
 			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 @@ class CommandTask extends AppShell {
 
 		$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, '.');

+ 2 - 1
Cake/Controller/Component/RequestHandlerComponent.php

@@ -21,6 +21,7 @@ use Cake\Core\App;
 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 @@ class RequestHandlerComponent extends Component {
 
 		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);

+ 4 - 1
Cake/Test/TestApp/View/Pages/home.ctp

@@ -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/>';

+ 3 - 2
Cake/Test/TestCase/Cache/CacheTest.php

@@ -418,17 +418,18 @@ class CacheTest extends TestCase {
  * @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);
 	}
 

+ 7 - 7
Cake/Test/TestCase/Cache/Engine/MemcachedEngineTest.php

@@ -20,6 +20,7 @@ use Cake\Cache\Cache;
 use Cake\Cache\Engine\MemcachedEngine;
 use Cake\Core\Configure;
 use Cake\TestSuite\TestCase;
+use \Memcached;
 
 /**
  * Class TestMemcachedEngine
@@ -111,7 +112,6 @@ class MemcachedEngineTest extends TestCase {
 			'servers' => array('127.0.0.1'),
 			'persistent' => false,
 			'compress' => false,
-			'engine' => 'Memcached',
 			'login' => null,
 			'password' => null,
 			'groups' => array(),
@@ -153,14 +153,14 @@ class MemcachedEngineTest extends TestCase {
 	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 @@ class MemcachedEngineTest extends TestCase {
 	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 @@ class MemcachedEngineTest extends TestCase {
 
 		$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 @@ class MemcachedEngineTest extends TestCase {
 		);
 
 		$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);
 	}

+ 2 - 6
Cake/Test/TestCase/Console/Command/CommandListShellTest.php

@@ -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 @@ class CommandListShellTest extends TestCase {
 		);
 
 		$this->Shell->Command = $this->getMock(
-			'CommandTask',
+			'Cake\Console\Command\Task\CommandTask',
 			array('in', '_stop', 'clear'),
 			array($out, $out, $in)
 		);
@@ -96,7 +92,7 @@ class CommandListShellTest extends TestCase {
 		$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/";

+ 15 - 28
lib/Cake/Test/Case/Console/Command/CompletionShellTest.php

@@ -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 @@ class TestCompletionStringOutput extends ConsoleOutput {
 
 /**
  * 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 @@ class CompletionShellTest extends CakeTestCase {
 	public function tearDown() {
 		parent::tearDown();
 		unset($this->Shell);
-		CakePlugin::unload();
+		Plugin::unload();
 	}
 
 /**
@@ -125,7 +112,7 @@ class CompletionShellTest extends CakeTestCase {
 		$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);
 	}
 

+ 1 - 1
Cake/Test/TestCase/Console/Command/Task/ExtractTaskTest.php

@@ -139,7 +139,7 @@ class ExtractTaskTest extends TestCase {
 		$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);
 

+ 2 - 1
Cake/Test/TestCase/Controller/Component/RequestHandlerComponentTest.php

@@ -254,7 +254,8 @@ class RequestHandlerComponentTest extends TestCase {
 		$_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);
 	}
 

+ 1 - 1
Cake/Test/TestCase/Network/Email/EmailTest.php

@@ -952,7 +952,7 @@ class EmailTest extends TestCase {
  */
 	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');

+ 2 - 2
Cake/Test/TestCase/Network/RequestTest.php

@@ -1105,7 +1105,7 @@ class RequestTest extends TestCase {
 	public function testParseAcceptIgnoreAcceptExtensions() {
 		$_SERVER['HTTP_ACCEPT'] = 'application/json;level=1, text/plain, */*';
 
-		$request = new CakeRequest('/', false);
+		$request = new Request('/', false);
 		$result = $request->parseAccept();
 		$expected = array(
 			'1.0' => array('application/json', 'text/plain', '*/*'),
@@ -1122,7 +1122,7 @@ class RequestTest extends TestCase {
  */
 	public function testParseAcceptInvalidSyntax() {
 		$_SERVER['HTTP_ACCEPT'] = 'text/html,application/xhtml+xml,application/xml;image/png,image/jpeg,image/*;q=0.9,*/*;q=0.8';
-		$request = new CakeRequest('/', false);
+		$request = new Request('/', false);
 		$result = $request->parseAccept();
 		$expected = array(
 			'1.0' => array('text/html', 'application/xhtml+xml', 'application/xml', 'image/jpeg'),