Skip to content

Commit

Permalink
Eliminating leading backslashes and inline namespace references.
Browse files Browse the repository at this point in the history
  • Loading branch information
nateabele committed Feb 10, 2012
1 parent 10059fb commit 38d8f26
Show file tree
Hide file tree
Showing 12 changed files with 62 additions and 53 deletions.
2 changes: 1 addition & 1 deletion console/Command.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ public function header($text, $line = 80) {
* also get passed down to the `out()` method, which allow custom formatting. Passing something * 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. * 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 $rows The rows to print, with each column as an array element.
* @param array $options Optional params: * @param array $options Optional params:
* - separator : Different column separator, defaults to `\t` * - separator : Different column separator, defaults to `\t`
Expand Down
7 changes: 5 additions & 2 deletions g11n/Locale.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@


use BadMethodCallException; use BadMethodCallException;
use InvalidArgumentException; 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 * The `Locale` class provides methods to deal with locale identifiers. The locale
Expand Down Expand Up @@ -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 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. * @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'`). * @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) { public static function preferred($request, $available = null) {
if (is_array($request)) { if (is_array($request)) {
$result = $request; $result = $request;
} elseif ($request instanceof \lithium\action\Request) { } elseif ($request instanceof ActionRequest) {
$result = static::_preferredAction($request); $result = static::_preferredAction($request);
} elseif ($request instanceof \lithium\console\Request) { } elseif ($request instanceof ConsoleRequest) {
$result = static::_preferredConsole($request); $result = static::_preferredConsole($request);
} else { } else {
return null; return null;
Expand Down
4 changes: 3 additions & 1 deletion net/socket/Curl.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@


namespace lithium\net\socket; namespace lithium\net\socket;


use lithium\net\http\Message;

/** /**
* A Curl-based socket adapter * A Curl-based socket adapter
* *
Expand Down Expand Up @@ -137,7 +139,7 @@ public function write($data = null) {
} }
$this->set(CURLOPT_URL, $data->to('url')); $this->set(CURLOPT_URL, $data->to('url'));


if ($data instanceof \lithium\net\http\Message) { if ($data instanceof Message) {
if (!empty($this->_config['ignoreExpect'])) { if (!empty($this->_config['ignoreExpect'])) {
$data->headers('Expect', ' '); $data->headers('Expect', ' ');
} }
Expand Down
8 changes: 4 additions & 4 deletions tests/cases/action/ControllerTest.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
namespace lithium\tests\cases\action; namespace lithium\tests\cases\action;


use lithium\action\Request; use lithium\action\Request;
use lithium\action\Response;
use lithium\action\Controller; use lithium\action\Controller;
use lithium\tests\mocks\action\MockPostsController; use lithium\tests\mocks\action\MockPostsController;
use lithium\tests\mocks\action\MockControllerRequest; use lithium\tests\mocks\action\MockControllerRequest;
Expand Down Expand Up @@ -38,8 +39,7 @@ public function testMethodInvocation() {
$postsController = new MockPostsController(); $postsController = new MockPostsController();
$result = $postsController->__invoke(null, array('action' => 'index', 'args' => array())); $result = $postsController->__invoke(null, array('action' => 'index', 'args' => array()));


$lithiumActionResponse = 'lithium\action\Response'; $this->assertTrue($result instanceof Response);
$this->assertTrue($result instanceof $lithiumActionResponse);
$this->assertEqual('List of posts', $result->body()); $this->assertEqual('List of posts', $result->body());
$this->assertEqual(array('Content-type' => 'text/plain; charset=UTF-8'), $result->headers); $this->assertEqual(array('Content-type' => 'text/plain; charset=UTF-8'), $result->headers);


Expand All @@ -50,7 +50,7 @@ public function testMethodInvocation() {
$this->expectException('/Unhandled media type/'); $this->expectException('/Unhandled media type/');
$result = $postsController(null, array('action' => 'index', 'args' => array(true))); $result = $postsController(null, array('action' => 'index', 'args' => array(true)));


$this->assertTrue($result instanceof $lithiumActionResponse); $this->assertTrue($result instanceof Response);
$this->assertEqual($result->body, ''); $this->assertEqual($result->body, '');


$headers = array('Content-type' => 'text/html; charset=UTF-8'); $headers = array('Content-type' => 'text/html; charset=UTF-8');
Expand All @@ -62,7 +62,7 @@ public function testMethodInvocation() {
$postsController = new MockPostsController(); $postsController = new MockPostsController();
$result = $postsController(null, array('action' => 'view', 'args' => array('2'))); $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"); $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'); $headers = array('status' => 200, 'Content-type' => 'text/plain; charset=UTF-8');
Expand Down
4 changes: 2 additions & 2 deletions tests/cases/console/CommandTest.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
namespace lithium\tests\cases\console; namespace lithium\tests\cases\console;


use lithium\console\Request; use lithium\console\Request;
use lithium\console\Response;
use lithium\tests\mocks\console\MockCommand; use lithium\tests\mocks\console\MockCommand;


class CommandTest extends \lithium\test\Unit { class CommandTest extends \lithium\test\Unit {
Expand Down Expand Up @@ -38,8 +39,7 @@ public function testInvoke() {
$response = $command('testRun'); $response = $command('testRun');


$result = $response; $result = $response;
$expected = 'lithium\console\Response'; $this->assertTrue($result instanceof Response);
$this->assertTrue($result instanceof $expected);


$expected = 'testRun'; $expected = 'testRun';
$result = $response->testAction; $result = $response->testAction;
Expand Down
3 changes: 2 additions & 1 deletion tests/cases/core/LibrariesTest.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
use SplFileInfo; use SplFileInfo;
use lithium\util\Inflector; use lithium\util\Inflector;
use lithium\core\Libraries; use lithium\core\Libraries;
use lithium\template\view\adapter\Simple;


class LibrariesTest extends \lithium\test\Unit { class LibrariesTest extends \lithium\test\Unit {


Expand Down Expand Up @@ -352,7 +353,7 @@ public function testServiceLocateAll() {


public function testServiceLocateInstantiation() { public function testServiceLocateInstantiation() {
$result = Libraries::instance('adapter.template.view', 'Simple'); $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."); $this->expectException("Class `Foo` of type `adapter.template.view` not found.");
$result = Libraries::instance('adapter.template.view', 'Foo'); $result = Libraries::instance('adapter.template.view', 'Foo');
} }
Expand Down
2 changes: 1 addition & 1 deletion tests/cases/data/source/MongoDbTest.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ public function testItem() {
$data = array('title' => 'New Item'); $data = array('title' => 'New Item');
$result = $this->db->item($model, $data); $result = $this->db->item($model, $data);


$this->assertTrue($result instanceof \lithium\data\entity\Document); $this->assertTrue($result instanceof Document);


$expected = $data; $expected = $data;
$result = $result->to('array'); $result = $result->to('array');
Expand Down
7 changes: 4 additions & 3 deletions tests/cases/net/socket/CurlTest.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@


namespace lithium\tests\cases\net\socket; namespace lithium\tests\cases\net\socket;


use lithium\net\http\Response;
use lithium\net\http\Request; use lithium\net\http\Request;
use lithium\net\socket\Curl; use lithium\net\socket\Curl;


Expand Down Expand Up @@ -107,7 +108,7 @@ public function testSendWithNull() {
new Request($this->_testConfig), new Request($this->_testConfig),
array('response' => 'lithium\net\http\Response') array('response' => 'lithium\net\http\Response')
); );
$this->assertTrue($result instanceof \lithium\net\http\Response); $this->assertTrue($result instanceof Response);
$this->assertPattern("/^HTTP/", (string) $result); $this->assertPattern("/^HTTP/", (string) $result);
} }


Expand All @@ -117,7 +118,7 @@ public function testSendWithArray() {
$result = $stream->send($this->_testConfig, $result = $stream->send($this->_testConfig,
array('response' => 'lithium\net\http\Response') array('response' => 'lithium\net\http\Response')
); );
$this->assertTrue($result instanceof \lithium\net\http\Response); $this->assertTrue($result instanceof Response);
$this->assertPattern("/^HTTP/", (string) $result); $this->assertPattern("/^HTTP/", (string) $result);
} }


Expand All @@ -128,7 +129,7 @@ public function testSendWithObject() {
new Request($this->_testConfig), new Request($this->_testConfig),
array('response' => 'lithium\net\http\Response') array('response' => 'lithium\net\http\Response')
); );
$this->assertTrue($result instanceof \lithium\net\http\Response); $this->assertTrue($result instanceof Response);
$this->assertPattern("/^HTTP/", (string) $result); $this->assertPattern("/^HTTP/", (string) $result);
} }


Expand Down
3 changes: 2 additions & 1 deletion tests/cases/template/ViewTest.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@


namespace lithium\tests\cases\template; namespace lithium\tests\cases\template;


use Closure;
use lithium\template\View; use lithium\template\View;
use lithium\action\Response; use lithium\action\Response;
use lithium\template\view\adapter\Simple; use lithium\template\view\adapter\Simple;
Expand Down Expand Up @@ -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']); unset($renderData[0]['data']['h']);
$this->assertEqual($expected, $renderData); $this->assertEqual($expected, $renderData);
} }
Expand Down
31 changes: 16 additions & 15 deletions tests/cases/test/DispatcherTest.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -8,31 +8,36 @@


namespace lithium\tests\cases\test; namespace lithium\tests\cases\test;


use lithium\test\Group;
use lithium\test\Report;
use lithium\test\Dispatcher; use lithium\test\Dispatcher;
use lithium\util\Collection; 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 { class DispatcherTest extends \lithium\test\Unit {


public function testRunDefaults() { public function testRunDefaults() {
$report = Dispatcher::run(); $report = Dispatcher::run();
$this->assertTrue($report instanceof \lithium\test\Report); $this->assertTrue($report instanceof Report);


$result = $report->group; $result = $report->group;
$this->assertTrue($result instanceof \lithium\test\Group); $this->assertTrue($result instanceof Group);
} }


public function testRunWithReporter() { public function testRunWithReporter() {
$report = Dispatcher::run(null, array('reporter' => 'html')); $report = Dispatcher::run(null, array('reporter' => 'html'));
$this->assertTrue($report instanceof \lithium\test\Report); $this->assertTrue($report instanceof Report);


$result = $report->group; $result = $report->group;
$this->assertTrue($result instanceof \lithium\test\Group); $this->assertTrue($result instanceof Group);
} }


public function testRunCaseWithString() { 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; $result = $report->title;
$this->assertEqual($expected, $result); $this->assertEqual($expected, $result);


Expand All @@ -46,19 +51,15 @@ public function testRunCaseWithString() {
} }


public function testRunGroupWithString() { 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; $result = $report->title;
$this->assertEqual($expected, $result); $this->assertEqual($expected, $result);


$expected = new Collection(array( $expected = new Collection(array('data' => array(
'data' => array( new MockSkipThrowsException(), new MockTest(), new MockTestErrorHandling()
new \lithium\tests\mocks\test\cases\MockSkipThrowsException(), )));
new \lithium\tests\mocks\test\cases\MockTest(),
new \lithium\tests\mocks\test\cases\MockTestErrorHandling()
)
));
$result = $report->group->tests(); $result = $report->group->tests();
$this->assertEqual($expected, $result); $this->assertEqual($expected, $result);


Expand Down
35 changes: 17 additions & 18 deletions tests/cases/test/GroupTest.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -9,8 +9,15 @@
namespace lithium\tests\cases\test; namespace lithium\tests\cases\test;


use lithium\test\Group; use lithium\test\Group;
use lithium\util\Collection;
use lithium\core\Libraries; 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 { class GroupTest extends \lithium\test\Unit {


Expand All @@ -26,13 +33,9 @@ public function testAddCaseThroughConstructor() {
$data = (array) "\lithium\\tests\mocks\\test"; $data = (array) "\lithium\\tests\mocks\\test";
$group = new Group(compact('data')); $group = new Group(compact('data'));


$expected = new Collection(array( $expected = new Collection(array('data' => array(
'data' => array( new MockSkipThrowsException(), new MockTest(), new MockTestErrorHandling()
new \lithium\tests\mocks\test\cases\MockSkipThrowsException(), )));
new \lithium\tests\mocks\test\cases\MockTest(),
new \lithium\tests\mocks\test\cases\MockTestErrorHandling()
)
));
$result = $group->tests(); $result = $group->tests();
$this->assertEqual($expected, $result); $this->assertEqual($expected, $result);
} }
Expand Down Expand Up @@ -77,13 +80,9 @@ public function testAddByString() {


public function testAddByMixedThroughConstructor() { public function testAddByMixedThroughConstructor() {
$group = new Group(array('data' => array( $group = new Group(array('data' => array(
'lithium\tests\cases\data\ModelTest', 'lithium\tests\cases\data\ModelTest', new ObjectTest()
new \lithium\tests\cases\core\ObjectTest()
)));
$expected = new Collection(array('data' => array(
new \lithium\tests\cases\data\ModelTest(),
new \lithium\tests\cases\core\ObjectTest()
))); )));
$expected = new Collection(array('data' => array(new ModelTest(), new ObjectTest())));
$result = $group->tests(); $result = $group->tests();
$this->assertEqual($expected, $result); $this->assertEqual($expected, $result);
} }
Expand All @@ -97,10 +96,10 @@ public function testTests() {
$this->assertEqual($expected, $result); $this->assertEqual($expected, $result);


$results = $group->tests(); $results = $group->tests();
$this->assertTrue($results instanceof \lithium\util\Collection); $this->assertTrue($results instanceof Collection);


$results = $group->tests(); $results = $group->tests();
$this->assertTrue($results->current() instanceof \lithium\tests\cases\g11n\CatalogTest); $this->assertTrue($results->current() instanceof CatalogTest);
} }


public function testAddEmptyTestsRun() { public function testAddEmptyTestsRun() {
Expand All @@ -110,8 +109,8 @@ public function testAddEmptyTestsRun() {
$this->assertEqual($expected, $result); $this->assertEqual($expected, $result);


$results = $group->tests(); $results = $group->tests();
$this->assertTrue($results instanceof \lithium\util\Collection); $this->assertTrue($results instanceof Collection);
$this->assertTrue($results->current() instanceof \lithium\tests\mocks\test\MockUnitTest); $this->assertTrue($results->current() instanceof MockUnitTest);


$results = $group->tests()->run(); $results = $group->tests()->run();


Expand Down
9 changes: 5 additions & 4 deletions tests/integration/net/SocketTest.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@


namespace lithium\tests\integration\net; namespace lithium\tests\integration\net;


use lithium\net\socket\Context;
use lithium\net\socket\Curl; use lithium\net\socket\Curl;
use lithium\net\http\Response;
use lithium\net\socket\Stream; use lithium\net\socket\Stream;
use lithium\net\socket\Context;


class SocketTest extends \lithium\test\Integration { class SocketTest extends \lithium\test\Integration {


Expand All @@ -35,7 +36,7 @@ public function testContextAdapter() {
$socket = new Context($this->_testConfig); $socket = new Context($this->_testConfig);
$this->assertTrue($socket->open()); $this->assertTrue($socket->open());
$response = $socket->send(); $response = $socket->send();
$this->assertTrue($response instanceof \lithium\net\http\Response); $this->assertTrue($response instanceof Response);


$expected = 'google.com'; $expected = 'google.com';
$result = $response->host; $result = $response->host;
Expand All @@ -52,7 +53,7 @@ public function testCurlAdapter() {
$socket = new Curl($this->_testConfig); $socket = new Curl($this->_testConfig);
$this->assertTrue($socket->open()); $this->assertTrue($socket->open());
$response = $socket->send(); $response = $socket->send();
$this->assertTrue($response instanceof \lithium\net\http\Response); $this->assertTrue($response instanceof Response);


$expected = 'google.com'; $expected = 'google.com';
$result = $response->host; $result = $response->host;
Expand All @@ -66,7 +67,7 @@ public function testStreamAdapter() {
$socket = new Stream($this->_testConfig); $socket = new Stream($this->_testConfig);
$this->assertTrue($socket->open()); $this->assertTrue($socket->open());
$response = $socket->send(); $response = $socket->send();
$this->assertTrue($response instanceof \lithium\net\http\Response); $this->assertTrue($response instanceof Response);


$expected = 'google.com'; $expected = 'google.com';
$result = $response->host; $result = $response->host;
Expand Down

0 comments on commit 38d8f26

Please sign in to comment.