Permalink
Browse files

Cleaning up coding standards warnings

	- Adjusting docblock formatting
	- Dropping unnecessary mock classes
  • Loading branch information...
1 parent 6fc4b4e commit fa4fe6bfeeb169304d59ee0f5dae4bd9fc1b18d7 @nateabele nateabele committed Apr 17, 2013
View
@@ -465,7 +465,7 @@ protected function _parseAccept() {
* ability to act conditionally on different aspects of the request. See `Media::type()` (the
* section on content negotiation) and the routing system for more information.
*
- * _Note_: All keys should be _lower-cased_, even when getting HTTP headers.
+ * _Note_: All keys should be _lower-cased_, even when getting HTTP headers.
*
* @see lithium\action\Request::env()
* @see lithium\net\http\Media::type()
View
@@ -1023,14 +1023,16 @@ public static function scope($name = null, Closure $closure = null) {
* ));
* }}}
*
- * @param string $name Name of the media you wish to attach.
- * @param array $config
+ * @param string $name The name of the media you wish to attach.
+ * @param array $config Asset configuration options for the given scope.
* - `'path'` _string_: Path of the media.
* - `'prefix'` _string_: Contains the uri prefix. Such as `css`.
* - `'absolute'` _boolean_: Defaults to `false`. If you want to generate
* absolute URL's.
- * - `'host'` _mixed_: String host, or array of hosts, of the media, if absolute is `true`.
- * - `'scheme'` _mixed_: String scheme, or array of sc, of the media, if absolute is `true`.
+ * - `'host'` _mixed_: String host, or array of hosts, of the media, if absolute is
+ * `true`.
+ * - `'scheme'` _mixed_: String scheme, or array of sc, of the media, if absolute is
+ * `true`.
* @return void
*/
public static function attach($name, $config = null) {
View
@@ -145,9 +145,9 @@ public static function check($password, $hash) {
*/
public static function salt($type = null, $count = null) {
switch (true) {
- case CRYPT_BLOWFISH == 1 && (!$type || $type === 'bf'):
+ case CRYPT_BLOWFISH === 1 && (!$type || $type === 'bf'):
return static::_genSaltBf($count);
- case CRYPT_EXT_DES == 1 && (!$type || $type === 'xdes'):
+ case CRYPT_EXT_DES === 1 && (!$type || $type === 'xdes'):
return static::_genSaltXDES($count);
default:
return static::_genSaltMD5();
@@ -221,7 +221,8 @@ public function clear(array $options = array()) {
/**
* Determines if PHP sessions are enabled.
*
- * @return boolean True if enabled (php session functionality can be disabled completely), false otherwise
+ * @return boolean Returns `true` if enabled (PHP session functionality can be disabled
+ * completely), `false` otherwise.
*/
public static function enabled() {
if (function_exists("session_status")) {
View
@@ -203,7 +203,7 @@ protected function _attribute($key, $value, array $options = array()) {
$options += $defaults;
if (in_array($key, $this->_minimized)) {
- $isMini = ($value == 1 || $value === true || $value == $key);
+ $isMini = ($value === 1 || $value === true || $value === $key);
if (!($value = $isMini ? $key : $value)) {
return null;
}
@@ -289,8 +289,8 @@ public function testRenderPropertyInheritance() {
$controller = new MockRenderAltController();
$expected = array(
- 'data' => array('foo' => 'bar'), 'layout' => 'alternate', 'type' => null, 'auto' => true,
- 'template' => null, 'hasRendered' => false, 'negotiate' => false
+ 'data' => array('foo' => 'bar'), 'layout' => 'alternate', 'type' => null,
+ 'auto' => true, 'template' => null, 'hasRendered' => false, 'negotiate' => false
);
$result = $controller->access('_render');
$this->assertEqual($expected, $result);
@@ -10,9 +10,6 @@
use lithium\core\Libraries;
use lithium\action\Request;
-use lithium\tests\mocks\action\MockIisRequest;
-use lithium\tests\mocks\action\MockNginxRequest;
-use lithium\tests\mocks\action\MockCgiRequest;
class RequestTest extends \lithium\test\Unit {
@@ -24,6 +21,60 @@ class RequestTest extends \lithium\test\Unit {
protected $_env = array();
+ protected $_iisConfig = array(
+ 'env' => array(
+ 'PLATFORM' => 'IIS',
+ 'SCRIPT_NAME' => '\index.php',
+ 'SCRIPT_FILENAME' => false,
+ 'DOCUMENT_ROOT' => false,
+ 'PATH_TRANSLATED' => '\lithium\app\webroot\index.php',
+ 'HTTP_PC_REMOTE_ADDR' => '123.456.789.000'
+ ),
+ 'globals' => false
+ );
+
+ protected $_cgiConfig = array(
+ 'env' => array(
+ 'PLATFORM' => 'CGI',
+ 'SCRIPT_FILENAME' => false,
+ 'DOCUMENT_ROOT' => false,
+ 'SCRIPT_URL' => '/lithium/app/webroot/index.php'
+ ),
+ 'globals' => false
+ );
+
+ protected $_nginxConfig = array(
+ 'env' => array(
+ 'FCGI_ROLE' => 'RESPONDER',
+ 'PATH_INFO' => '',
+ 'PATH_TRANSLATED' => '/lithium/app/webroot/index.php',
+ 'QUERY_STRING' => '',
+ 'REQUEST_METHOD' => 'GET',
+ 'CONTENT_TYPE' => '',
+ 'CONTENT_LENGTH' => '',
+ 'SCRIPT_NAME' => '/index.php',
+ 'SCRIPT_FILENAME' => '/lithium/app/webroot/index.php',
+ 'REQUEST_URI' => '/',
+ 'DOCUMENT_URI' => '/index.php',
+ 'DOCUMENT_ROOT' => '/lithium/app/webroot',
+ 'SERVER_PROTOCOL' => 'HTTP/1.1',
+ 'GATEWAY_INTERFACE' => 'CGI/1.1',
+ 'REMOTE_ADDR' => '127.0.0.1',
+ 'REMOTE_PORT' => '52987',
+ 'SERVER_ADDR' => '127.0.0.1',
+ 'SERVER_PORT' => '80',
+ 'SERVER_NAME' => 'sandbox.local',
+ 'HTTP_HOST' => 'sandbox.local',
+ 'HTTP_USER_AGENT' => 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7) AppleWebKit/...etc.',
+ 'HTTP_ACCEPT' => 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
+ 'HTTP_ACCEPT_LANGUAGE' => 'en-us',
+ 'HTTP_ACCEPT_ENCODING' => 'gzip, deflate',
+ 'HTTP_CONNECTION' => 'keep-alive',
+ 'PHP_SELF' => '/index.php'
+ ),
+ 'globals' => false
+ );
+
public function setUp() {
$resources = Libraries::get(true, 'resources') . '/tmp/tests';
$this->skipIf(!is_writable($resources), "Can't write to resources directory.");
@@ -101,13 +152,13 @@ public function testScriptFilename() {
}
public function testPlatform() {
- $request = new MockIisRequest();
+ $request = new Request($this->_iisConfig);
$result = $request->env('PLATFORM');
$this->assertEqual('IIS', $result);
}
public function testScriptFilenameTranslatedForIIS() {
- $request = new MockIisRequest();
+ $request = new Request($this->_iisConfig);
$this->assertEqual('\lithium\app\webroot\index.php', $request->env('SCRIPT_FILENAME'));
$request = new Request(array(
@@ -129,11 +180,9 @@ public function testDocumentRoot() {
}
public function testDocumentRootTranslatedForIIS() {
- $request = new MockIisRequest();
-
- $expected = '\lithium\app\webroot';
+ $request = new Request($this->_iisConfig);
$result = $request->env('DOCUMENT_ROOT');
- $this->assertEqual($expected, $result);
+ $this->assertEqual('\lithium\app\webroot', $result);
}
public function testScriptName() {
@@ -193,7 +242,7 @@ public function testRemoteAddr() {
}
public function testRemoteAddrFromHttpPcRemoteAddr() {
- $request = new MockIisRequest();
+ $request = new Request($this->_iisConfig);
$this->assertEqual('123.456.789.000', $request->env('REMOTE_ADDR'));
}
@@ -270,15 +319,12 @@ public function testServerHttpBase() {
}
public function testCgiPlatform() {
- $request = new MockCgiRequest();
-
- $result = $request->env('CGI_MODE');
- $this->assertTrue($result);
+ $request = new Request($this->_cgiConfig);
+ $this->assertTrue($request->env('CGI_MODE'));
}
public function testCgiScriptUrl() {
- $request = new MockCgiRequest();
-
+ $request = new Request($this->_cgiConfig);
$expected = '/lithium/app/webroot/index.php';
$result = $request->env('SCRIPT_NAME');
$this->assertEqual($expected, $result);
@@ -400,42 +446,30 @@ public function testType() {
}
public function testTypeforNginx() {
- $request = new MockNginxRequest();
-
+ $request = new Request($this->_nginxConfig);
$this->assertEqual('html', $request->type());
}
public function testRefererDefault() {
$request = new Request(array(
- 'env' => array(
- 'HTTP_REFERER' => null
- )
+ 'env' => array('HTTP_REFERER' => null)
));
-
- $expected = '/';
- $result = $request->referer('/');
- $this->assertEqual($expected, $result);
+ $this->assertEqual('/', $request->referer('/'));
}
public function testRefererNotLocal() {
- $request = new Request(array(
- 'env' => array(
- 'HTTP_REFERER' => 'http://lithium.com/posts/index',
- 'HTTP_HOST' => 'foo.com'
- )
- ));
+ $request = new Request(array('env' => array(
+ 'HTTP_REFERER' => 'http://lithium.com/posts/index',
+ 'HTTP_HOST' => 'foo.com'
+ )));
- $expected = 'http://lithium.com/posts/index';
$result = $request->referer('/');
- $this->assertEqual($expected, $result);
+ $this->assertEqual('http://lithium.com/posts/index', $result);
}
public function testRefererLocal() {
- $_SERVER['HTTP_REFERER'] = '/posts/index';
$request = new Request(array(
- 'env' => array(
- 'HTTP_REFERER' => '/posts/index'
- )
+ 'env' => array('HTTP_REFERER' => '/posts/index')
));
$expected = '/posts/index';
@@ -444,16 +478,13 @@ public function testRefererLocal() {
}
public function testRefererLocalWithHost() {
- $request = new Request(array(
- 'env' => array(
- 'HTTP_REFERER' => 'http://lithium.com/posts/index',
- 'HTTP_HOST' => 'lithium.com'
- )
- ));
+ $request = new Request(array('env' => array(
+ 'HTTP_REFERER' => 'http://lithium.com/posts/index',
+ 'HTTP_HOST' => 'lithium.com'
+ )));
- $expected = '/posts/index';
$result = $request->referer('/', true);
- $this->assertEqual($expected, $result);
+ $this->assertEqual('/posts/index', $result);
}
public function testRefererLocalFromNotLocal() {
@@ -204,7 +204,7 @@ public function testBrowserRedirection() {
}
public static function match($url) {
- if ($url == array('controller' => 'foo_bar', 'action' => 'index')) {
+ if ($url === array('controller' => 'foo_bar', 'action' => 'index')) {
return '/foo_bar';
}
}
@@ -32,7 +32,7 @@ public function tearDown() {
public function testNamespaceToFileTranslation() {
$ds = DIRECTORY_SEPARATOR;
- $invalidDS = $ds == '/' ? '\\' : '/';
+ $invalidDS = $ds === '/' ? '\\' : '/';
$result = Libraries::path('\lithium\core\Libraries');
$this->assertNotEmpty(strpos($result, "${ds}lithium${ds}core${ds}Libraries.php"));
@@ -1602,7 +1602,9 @@ public function testAssertNotExceptionPassesWithWrongException() {
}
public function testAssertNotExceptionFailsWithExactException() {
- $this->assertFalse($this->test->assertNotException('lithium\action\DispatchException', function() {
+ $class = 'lithium\action\DispatchException';
+
+ $this->assertFalse($this->test->assertNotException($class, function() {
throw new \lithium\action\DispatchException('Foo');
}));
}
@@ -1,27 +0,0 @@
-<?php
-/**
- * Lithium: the most rad php framework
- *
- * @copyright Copyright 2013, Union of RAD (http://union-of-rad.org)
- * @license http://opensource.org/licenses/bsd-license.php The BSD License
- */
-
-namespace lithium\tests\mocks\action;
-
-class MockCgiRequest extends \lithium\action\Request {
-
- public function __construct(array $config = array()) {
- $config = array(
- 'env' => array(
- 'PLATFORM' => 'CGI',
- 'SCRIPT_FILENAME' => false,
- 'DOCUMENT_ROOT' => false,
- 'SCRIPT_URL' => '/lithium/app/webroot/index.php'
- ),
- 'globals' => false
- );
- parent::__construct($config);
- }
-}
-
-?>
@@ -1,29 +0,0 @@
-<?php
-/**
- * Lithium: the most rad php framework
- *
- * @copyright Copyright 2013, Union of RAD (http://union-of-rad.org)
- * @license http://opensource.org/licenses/bsd-license.php The BSD License
- */
-
-namespace lithium\tests\mocks\action;
-
-class MockIisRequest extends \lithium\action\Request {
-
- public function __construct(array $config = array()) {
- $config = array(
- 'env' => array(
- 'PLATFORM' => 'IIS',
- 'SCRIPT_NAME' => '\index.php',
- 'SCRIPT_FILENAME' => false,
- 'DOCUMENT_ROOT' => false,
- 'PATH_TRANSLATED' => '\lithium\app\webroot\index.php',
- 'HTTP_PC_REMOTE_ADDR' => '123.456.789.000'
- ),
- 'globals' => false
- );
- parent::__construct($config);
- }
-}
-
-?>
Oops, something went wrong.

0 comments on commit fa4fe6b

Please sign in to comment.