Permalink
Browse files

Eliminating leading backslashes and inline namespace references.

  • Loading branch information...
1 parent 10059fb commit 38d8f26aa8afb010eef8fc9a3c0bd776c83d8bff @nateabele nateabele committed Feb 10, 2012
View
@@ -265,7 +265,7 @@ public function header($text, $line = 80) {
* also get passed down to the `out()` method, which allow custom formatting. Passing something
* like `$this->columns($output, array('style' => 'red)` would print the table in red.
*
- * @see \lithium\console\Response::styles()
+ * @see lithium\console\Response::styles()
* @param array $rows The rows to print, with each column as an array element.
* @param array $options Optional params:
* - separator : Different column separator, defaults to `\t`
View
@@ -10,6 +10,8 @@
use BadMethodCallException;
use InvalidArgumentException;
+use lithium\action\Request as ActionRequest;
+use lithium\console\Request as ConsoleRequest;
/**
* The `Locale` class provides methods to deal with locale identifiers. The locale
@@ -208,13 +210,14 @@ public static function lookup($locales, $locale) {
* @param object|array $request An action or console request object or an array of locales.
* @param array $available A list of locales to negotiate the preferred locale with.
* @return string The preferred locale in it's canonical form (i.e. `'fr_CA'`).
+ * @todo Rewrite this to remove hard-coded class names.
*/
public static function preferred($request, $available = null) {
if (is_array($request)) {
$result = $request;
- } elseif ($request instanceof \lithium\action\Request) {
+ } elseif ($request instanceof ActionRequest) {
$result = static::_preferredAction($request);
- } elseif ($request instanceof \lithium\console\Request) {
+ } elseif ($request instanceof ConsoleRequest) {
$result = static::_preferredConsole($request);
} else {
return null;
View
@@ -8,6 +8,8 @@
namespace lithium\net\socket;
+use lithium\net\http\Message;
+
/**
* A Curl-based socket adapter
*
@@ -137,7 +139,7 @@ public function write($data = null) {
}
$this->set(CURLOPT_URL, $data->to('url'));
- if ($data instanceof \lithium\net\http\Message) {
+ if ($data instanceof Message) {
if (!empty($this->_config['ignoreExpect'])) {
$data->headers('Expect', ' ');
}
@@ -9,6 +9,7 @@
namespace lithium\tests\cases\action;
use lithium\action\Request;
+use lithium\action\Response;
use lithium\action\Controller;
use lithium\tests\mocks\action\MockPostsController;
use lithium\tests\mocks\action\MockControllerRequest;
@@ -38,8 +39,7 @@ public function testMethodInvocation() {
$postsController = new MockPostsController();
$result = $postsController->__invoke(null, array('action' => 'index', 'args' => array()));
- $lithiumActionResponse = 'lithium\action\Response';
- $this->assertTrue($result instanceof $lithiumActionResponse);
+ $this->assertTrue($result instanceof Response);
$this->assertEqual('List of posts', $result->body());
$this->assertEqual(array('Content-type' => 'text/plain; charset=UTF-8'), $result->headers);
@@ -50,7 +50,7 @@ public function testMethodInvocation() {
$this->expectException('/Unhandled media type/');
$result = $postsController(null, array('action' => 'index', 'args' => array(true)));
- $this->assertTrue($result instanceof $lithiumActionResponse);
+ $this->assertTrue($result instanceof Response);
$this->assertEqual($result->body, '');
$headers = array('Content-type' => 'text/html; charset=UTF-8');
@@ -62,7 +62,7 @@ public function testMethodInvocation() {
$postsController = new MockPostsController();
$result = $postsController(null, array('action' => 'view', 'args' => array('2')));
- $this->assertTrue($result instanceof $lithiumActionResponse);
+ $this->assertTrue($result instanceof Response);
$this->assertEqual($result->body, "Array\n(\n [0] => This is a post\n)\n");
$headers = array('status' => 200, 'Content-type' => 'text/plain; charset=UTF-8');
@@ -9,6 +9,7 @@
namespace lithium\tests\cases\console;
use lithium\console\Request;
+use lithium\console\Response;
use lithium\tests\mocks\console\MockCommand;
class CommandTest extends \lithium\test\Unit {
@@ -38,8 +39,7 @@ public function testInvoke() {
$response = $command('testRun');
$result = $response;
- $expected = 'lithium\console\Response';
- $this->assertTrue($result instanceof $expected);
+ $this->assertTrue($result instanceof Response);
$expected = 'testRun';
$result = $response->testAction;
@@ -12,6 +12,7 @@
use SplFileInfo;
use lithium\util\Inflector;
use lithium\core\Libraries;
+use lithium\template\view\adapter\Simple;
class LibrariesTest extends \lithium\test\Unit {
@@ -352,7 +353,7 @@ public function testServiceLocateAll() {
public function testServiceLocateInstantiation() {
$result = Libraries::instance('adapter.template.view', 'Simple');
- $this->assertTrue($result instanceof \lithium\template\view\adapter\Simple);
+ $this->assertTrue($result instanceof Simple);
$this->expectException("Class `Foo` of type `adapter.template.view` not found.");
$result = Libraries::instance('adapter.template.view', 'Foo');
}
@@ -345,7 +345,7 @@ public function testItem() {
$data = array('title' => 'New Item');
$result = $this->db->item($model, $data);
- $this->assertTrue($result instanceof \lithium\data\entity\Document);
+ $this->assertTrue($result instanceof Document);
$expected = $data;
$result = $result->to('array');
@@ -8,6 +8,7 @@
namespace lithium\tests\cases\net\socket;
+use lithium\net\http\Response;
use lithium\net\http\Request;
use lithium\net\socket\Curl;
@@ -107,7 +108,7 @@ public function testSendWithNull() {
new Request($this->_testConfig),
array('response' => 'lithium\net\http\Response')
);
- $this->assertTrue($result instanceof \lithium\net\http\Response);
+ $this->assertTrue($result instanceof Response);
$this->assertPattern("/^HTTP/", (string) $result);
}
@@ -117,7 +118,7 @@ public function testSendWithArray() {
$result = $stream->send($this->_testConfig,
array('response' => 'lithium\net\http\Response')
);
- $this->assertTrue($result instanceof \lithium\net\http\Response);
+ $this->assertTrue($result instanceof Response);
$this->assertPattern("/^HTTP/", (string) $result);
}
@@ -128,7 +129,7 @@ public function testSendWithObject() {
new Request($this->_testConfig),
array('response' => 'lithium\net\http\Response')
);
- $this->assertTrue($result instanceof \lithium\net\http\Response);
+ $this->assertTrue($result instanceof Response);
$this->assertPattern("/^HTTP/", (string) $result);
}
@@ -8,6 +8,7 @@
namespace lithium\tests\cases\template;
+use Closure;
use lithium\template\View;
use lithium\action\Response;
use lithium\template\view\adapter\Simple;
@@ -170,7 +171,7 @@ public function testNolayout() {
)
)
);
- $this->assertTrue($renderData[0]['data']['h'] instanceof \Closure);
+ $this->assertTrue($renderData[0]['data']['h'] instanceof Closure);
unset($renderData[0]['data']['h']);
$this->assertEqual($expected, $renderData);
}
@@ -8,31 +8,36 @@
namespace lithium\tests\cases\test;
+use lithium\test\Group;
+use lithium\test\Report;
use lithium\test\Dispatcher;
use lithium\util\Collection;
+use lithium\tests\mocks\test\cases\MockTest;
+use lithium\tests\mocks\test\cases\MockTestErrorHandling;
+use lithium\tests\mocks\test\cases\MockSkipThrowsException;
class DispatcherTest extends \lithium\test\Unit {
public function testRunDefaults() {
$report = Dispatcher::run();
- $this->assertTrue($report instanceof \lithium\test\Report);
+ $this->assertTrue($report instanceof Report);
$result = $report->group;
- $this->assertTrue($result instanceof \lithium\test\Group);
+ $this->assertTrue($result instanceof Group);
}
public function testRunWithReporter() {
$report = Dispatcher::run(null, array('reporter' => 'html'));
- $this->assertTrue($report instanceof \lithium\test\Report);
+ $this->assertTrue($report instanceof Report);
$result = $report->group;
- $this->assertTrue($result instanceof \lithium\test\Group);
+ $this->assertTrue($result instanceof Group);
}
public function testRunCaseWithString() {
- $report = Dispatcher::run('\lithium\tests\mocks\test\MockUnitTest');
+ $report = Dispatcher::run('lithium\tests\mocks\test\MockUnitTest');
- $expected = '\lithium\tests\mocks\test\MockUnitTest';
+ $expected = 'lithium\tests\mocks\test\MockUnitTest';
$result = $report->title;
$this->assertEqual($expected, $result);
@@ -46,19 +51,15 @@ public function testRunCaseWithString() {
}
public function testRunGroupWithString() {
- $report = Dispatcher::run('\lithium\tests\mocks\test');
+ $report = Dispatcher::run('lithium\tests\mocks\test');
- $expected = '\lithium\tests\mocks\test';
+ $expected = 'lithium\tests\mocks\test';
$result = $report->title;
$this->assertEqual($expected, $result);
- $expected = new Collection(array(
- 'data' => array(
- new \lithium\tests\mocks\test\cases\MockSkipThrowsException(),
- new \lithium\tests\mocks\test\cases\MockTest(),
- new \lithium\tests\mocks\test\cases\MockTestErrorHandling()
- )
- ));
+ $expected = new Collection(array('data' => array(
+ new MockSkipThrowsException(), new MockTest(), new MockTestErrorHandling()
+ )));
$result = $report->group->tests();
$this->assertEqual($expected, $result);
@@ -9,8 +9,15 @@
namespace lithium\tests\cases\test;
use lithium\test\Group;
-use lithium\util\Collection;
use lithium\core\Libraries;
+use lithium\util\Collection;
+use lithium\tests\cases\data\ModelTest;
+use lithium\tests\cases\core\ObjectTest;
+use lithium\tests\cases\g11n\CatalogTest;
+use lithium\tests\mocks\test\MockUnitTest;
+use lithium\tests\mocks\test\cases\MockTest;
+use lithium\tests\mocks\test\cases\MockTestErrorHandling;
+use lithium\tests\mocks\test\cases\MockSkipThrowsException;
class GroupTest extends \lithium\test\Unit {
@@ -26,13 +33,9 @@ public function testAddCaseThroughConstructor() {
$data = (array) "\lithium\\tests\mocks\\test";
$group = new Group(compact('data'));
- $expected = new Collection(array(
- 'data' => array(
- new \lithium\tests\mocks\test\cases\MockSkipThrowsException(),
- new \lithium\tests\mocks\test\cases\MockTest(),
- new \lithium\tests\mocks\test\cases\MockTestErrorHandling()
- )
- ));
+ $expected = new Collection(array('data' => array(
+ new MockSkipThrowsException(), new MockTest(), new MockTestErrorHandling()
+ )));
$result = $group->tests();
$this->assertEqual($expected, $result);
}
@@ -77,13 +80,9 @@ public function testAddByString() {
public function testAddByMixedThroughConstructor() {
$group = new Group(array('data' => array(
- 'lithium\tests\cases\data\ModelTest',
- new \lithium\tests\cases\core\ObjectTest()
- )));
- $expected = new Collection(array('data' => array(
- new \lithium\tests\cases\data\ModelTest(),
- new \lithium\tests\cases\core\ObjectTest()
+ 'lithium\tests\cases\data\ModelTest', new ObjectTest()
)));
+ $expected = new Collection(array('data' => array(new ModelTest(), new ObjectTest())));
$result = $group->tests();
$this->assertEqual($expected, $result);
}
@@ -97,10 +96,10 @@ public function testTests() {
$this->assertEqual($expected, $result);
$results = $group->tests();
- $this->assertTrue($results instanceof \lithium\util\Collection);
+ $this->assertTrue($results instanceof Collection);
$results = $group->tests();
- $this->assertTrue($results->current() instanceof \lithium\tests\cases\g11n\CatalogTest);
+ $this->assertTrue($results->current() instanceof CatalogTest);
}
public function testAddEmptyTestsRun() {
@@ -110,8 +109,8 @@ public function testAddEmptyTestsRun() {
$this->assertEqual($expected, $result);
$results = $group->tests();
- $this->assertTrue($results instanceof \lithium\util\Collection);
- $this->assertTrue($results->current() instanceof \lithium\tests\mocks\test\MockUnitTest);
+ $this->assertTrue($results instanceof Collection);
+ $this->assertTrue($results->current() instanceof MockUnitTest);
$results = $group->tests()->run();
@@ -8,9 +8,10 @@
namespace lithium\tests\integration\net;
-use lithium\net\socket\Context;
use lithium\net\socket\Curl;
+use lithium\net\http\Response;
use lithium\net\socket\Stream;
+use lithium\net\socket\Context;
class SocketTest extends \lithium\test\Integration {
@@ -35,7 +36,7 @@ public function testContextAdapter() {
$socket = new Context($this->_testConfig);
$this->assertTrue($socket->open());
$response = $socket->send();
- $this->assertTrue($response instanceof \lithium\net\http\Response);
+ $this->assertTrue($response instanceof Response);
$expected = 'google.com';
$result = $response->host;
@@ -52,7 +53,7 @@ public function testCurlAdapter() {
$socket = new Curl($this->_testConfig);
$this->assertTrue($socket->open());
$response = $socket->send();
- $this->assertTrue($response instanceof \lithium\net\http\Response);
+ $this->assertTrue($response instanceof Response);
$expected = 'google.com';
$result = $response->host;
@@ -66,7 +67,7 @@ public function testStreamAdapter() {
$socket = new Stream($this->_testConfig);
$this->assertTrue($socket->open());
$response = $socket->send();
- $this->assertTrue($response instanceof \lithium\net\http\Response);
+ $this->assertTrue($response instanceof Response);
$expected = 'google.com';
$result = $response->host;

0 comments on commit 38d8f26

Please sign in to comment.