Commit: 6cbb2cd3d1ef742950785f68ce549283b38d8385

Author: Nate Abele | Date: 2011-03-12 12:42:38 -0500
Fixing misc. QA issues and adding docblocks.
diff --git a/libraries/lithium/console/command/Route.php b/libraries/lithium/console/command/Route.php index 9aeb0a8..86fd586 100644 --- a/libraries/lithium/console/command/Route.php +++ b/libraries/lithium/console/command/Route.php @@ -31,6 +31,9 @@ class Route extends \lithium\console\Command { /** * Load the routes file and set the environment. + * + * @param array $config The default configuration, wherein the absolute path to the routes file + * to load may be specified, using the `'routes_file'` key. */ public function __construct($config = array()) { $defaults = array('routes_file' => LITHIUM_APP_PATH . '/config/routes.php'); @@ -74,8 +77,6 @@ class Route extends \lithium\console\Command { * -------- ------ * / {"controller":"pages","action":"view"} * /pages/{:args} {"controller":"pages","action":"view"} - * /test/{:args} {"controller":"lithium\\test\\Controller","action":"index"} - * /test {"controller":"lithium\\test\\Controller","action":"index"} * /{:slug:[\w\-]+} {"controller":"posts","action":"show"} * /{:controller}/{:action}/{:args} {"action":"index"} * }}} diff --git a/libraries/lithium/core/ErrorHandler.php b/libraries/lithium/core/ErrorHandler.php index ec505eb..774f6fb 100644 --- a/libraries/lithium/core/ErrorHandler.php +++ b/libraries/lithium/core/ErrorHandler.php @@ -134,6 +134,16 @@ class ErrorHandler extends \lithium\core\StaticObject { * This method (`ErrorHandler::run()`) needs to be called as early as possible in the bootstrap * cycle; immediately after `require`-ing `bootstrap/libraries.php` is your best bet. * + * @param array $config The configuration with which to start the error handler. Available + * options include: + * - `'trapErrors'` _boolean_: Defaults to `false`. If set to `true`, PHP errors + * will be caught by `ErrorHandler` and handled in-place. Execution will resume + * in the same context in which the error occurred. + * - `'convertErrors'` _boolean_: Defaults to `true`, and specifies that all PHP + * errors should be converted to `ErrorException`s and thrown from the point + * where the error occurred. The exception will be caught at the first point in + * the stack trace inside a matching `try`/`catch` block, or that has a matching + * error handler applied using the `apply()` method. * @return void */ public static function run(array $config = array()) { diff --git a/libraries/lithium/core/Libraries.php b/libraries/lithium/core/Libraries.php index dfef107..ae751ad 100644 --- a/libraries/lithium/core/Libraries.php +++ b/libraries/lithium/core/Libraries.php @@ -818,10 +818,6 @@ class Libraries { $defaults = array('libraries' => null, 'recursive' => true, 'namespaces' => false); $options += $defaults; - if (!isset(static::$_paths[$params['type']])) { - var_dump($params['type']); - die(); - } $paths = (array) static::$_paths[$params['type']]; $libraries = $options['library'] ? $options['library'] : $options['libraries']; $libraries = static::get((array) $libraries); diff --git a/libraries/lithium/data/Entity.php b/libraries/lithium/data/Entity.php index 2d00d38..d49ea48 100644 --- a/libraries/lithium/data/Entity.php +++ b/libraries/lithium/data/Entity.php @@ -339,9 +339,9 @@ class Entity extends \lithium\core\Object { * @param string $field The name of the field to be incrememnted. * @param string $value The value to increment the field by. Defaults to `1` if this parameter * is not specified. - * @return int Returns the current value of `$field`, based on the value retrieved from the data - * source when the entity was loaded, plus any increments applied. Note that it may not - * reflect the most current value in the persistent backend data source. + * @return integer Returns the current value of `$field`, based on the value retrieved from the + * data source when the entity was loaded, plus any increments applied. Note that it may + * not reflect the most current value in the persistent backend data source. * @throws UnexpectedValueException Throws an exception when `$field` is set to a non-numeric * type. */ @@ -363,7 +363,7 @@ class Entity extends \lithium\core\Object { * @see lithium\data\Entity::increment() * @param string $field The name of the field to decrement. * @param string $value The value by which to decrement the field. Defaults to `1`. - * @return int Returns the new value of `$field`, after modification. + * @return integer Returns the new value of `$field`, after modification. */ public function decrement($field, $value = 1) { return $this->increment($field, $value * -1); diff --git a/libraries/lithium/data/source/Database.php b/libraries/lithium/data/source/Database.php old mode 100755 new mode 100644 diff --git a/libraries/lithium/data/source/database/adapter/Sqlite3.php b/libraries/lithium/data/source/database/adapter/Sqlite3.php index 2b32499..6f24e31 100644 --- a/libraries/lithium/data/source/database/adapter/Sqlite3.php +++ b/libraries/lithium/data/source/database/adapter/Sqlite3.php @@ -12,7 +12,7 @@ namespace lithium\data\source\database\adapter; use SQLite3 as SQLite; use SQLite3Result; use lithium\data\model\QueryException; -use \lithium\data\source\database\adapter\sqlite3\Result; +use lithium\data\source\database\adapter\sqlite3\Result; /** * Sqlite database driver diff --git a/libraries/lithium/tests/cases/console/command/RouteTest.php b/libraries/lithium/tests/cases/console/command/RouteTest.php index 68beb2f..ae3ae48 100644 --- a/libraries/lithium/tests/cases/console/command/RouteTest.php +++ b/libraries/lithium/tests/cases/console/command/RouteTest.php @@ -19,13 +19,15 @@ class RouteTest extends \lithium\test\Unit { /** * Holds config params. + * + * @var array */ - protected $_config = array( - 'routes_file' => '' - ); + protected $_config = array('routes_file' => ''); /** * Holds the temporary test path. + * + * @var string */ protected $_testPath = null; @@ -41,8 +43,9 @@ class RouteTest extends \lithium\test\Unit { * Create a temporary routes.php file for testing and reset the router. */ public function setUp() { - $this->_config['routes_file'] = $this->_testPath.'/routes.php'; + $this->_config['routes_file'] = "{$this->_testPath}/routes.php"; + $testParams = 'array("controller" => "lithium\test\Controller")'; $content = array( '<?php', 'use lithium\net\http\Router;', @@ -50,8 +53,8 @@ class RouteTest extends \lithium\test\Unit { 'Router::connect("/", "Pages::view");', 'Router::connect("/pages/{:args}", "Pages::view");', 'if (!Environment::is("production")) {', - 'Router::connect("/test/{:args}", array("controller" => "lithium\test\Controller"));', - 'Router::connect("/test", array("controller" => "lithium\test\Controller"));', + 'Router::connect("/test/{:args}", ' . $testParams . ');', + 'Router::connect("/test", ' . $testParams . ');', '}', '?>' ); @@ -64,7 +67,7 @@ class RouteTest extends \lithium\test\Unit { * Delete the temporary routes.php file. */ public function tearDown() { - if(file_exists($this->_config['routes_file'])) { + if (file_exists($this->_config['routes_file'])) { unlink($this->_config['routes_file']); } } @@ -274,11 +277,13 @@ class RouteTest extends \lithium\test\Unit { /** * Remove formatting whitespace, tabs and newlines for better sourcecode * readability. + * + * @param string $str A string from which to strip spaces + * @return string Returns the value of `$str` with all whitespace removed. */ protected function _strip($str) { return preg_replace('/\s/', '', $str); } - } ?> \ No newline at end of file diff --git a/libraries/lithium/tests/cases/data/source/DatabaseTest.php b/libraries/lithium/tests/cases/data/source/DatabaseTest.php index 2265082..84b6465 100644 --- a/libraries/lithium/tests/cases/data/source/DatabaseTest.php +++ b/libraries/lithium/tests/cases/data/source/DatabaseTest.php @@ -387,7 +387,8 @@ class DatabaseTest extends \lithium\test\Unit { 'data' => array('published' => false), 'model' => $this->_model )); - $sql = "UPDATE {mock_database_posts} SET {published} = 0 WHERE ({expires} >= '2010-05-13');"; + $sql = "UPDATE {mock_database_posts} SET {published} = 0 WHERE "; + $sql .= "({expires} >= '2010-05-13');"; $this->assertEqual($sql, $this->db->renderCommand($query)); } @@ -433,7 +434,8 @@ class DatabaseTest extends \lithium\test\Unit { 'field' => array('like' => '%value%') ) )); - $sql = "SELECT * FROM {mock_database_posts} AS {MockDatabasePost} WHERE ({field} like '%value%');"; + $sql = "SELECT * FROM {mock_database_posts} AS {MockDatabasePost} WHERE "; + $sql .= "({field} like '%value%');"; $this->assertEqual($sql, $this->db->renderCommand($query)); $query = new Query(array( @@ -442,15 +444,14 @@ class DatabaseTest extends \lithium\test\Unit { 'or' => array( 'field1' => 'value1', 'field2' => 'value2', - 'and' => array( - 'sField' => '1', - 'sField2' => '2' - ) + 'and' => array('sField' => '1', 'sField2' => '2') ), 'bField' => '3' ) )); - $sql = "SELECT * FROM {mock_database_posts} AS {MockDatabasePost} WHERE ({field1} = 'value1' OR {field2} = 'value2' OR ({sField} = 1 AND {sField2} = 2)) AND {bField} = 3;"; + $sql = "SELECT * FROM {mock_database_posts} AS {MockDatabasePost} WHERE "; + $sql .= "({field1} = 'value1' OR {field2} = 'value2' OR ({sField} = 1 AND {sField2} = 2))"; + $sql .= " AND {bField} = 3;"; $this->assertEqual($sql, $this->db->renderCommand($query)); } diff --git a/libraries/lithium/tests/cases/net/http/ResponseTest.php b/libraries/lithium/tests/cases/net/http/ResponseTest.php index feb95f7..94ce1b2 100644 --- a/libraries/lithium/tests/cases/net/http/ResponseTest.php +++ b/libraries/lithium/tests/cases/net/http/ResponseTest.php @@ -111,8 +111,7 @@ class ResponseTest extends \lithium\test\Unit { $response = new Response(array('message' => $message)); $this->assertEqual('application/json', $response->type); $this->assertEqual('ISO-8859-1', $response->encoding); - - // Content type WITH MULTIPLE spaces between type and charset + $message = join("\r\n", array( 'HTTP/1.1 200 OK', 'Content-Type: application/json; charset=iso-8859-1', diff --git a/libraries/lithium/tests/cases/security/auth/adapter/FormTest.php b/libraries/lithium/tests/cases/security/auth/adapter/FormTest.php index 54064e7..eac9e72 100644 --- a/libraries/lithium/tests/cases/security/auth/adapter/FormTest.php +++ b/libraries/lithium/tests/cases/security/auth/adapter/FormTest.php @@ -24,9 +24,9 @@ class FormTest extends \lithium\test\Unit { $request->data = array('username' => 'Person', 'password' => 'password'); $result = $subject->check($request); - $expected = array('username' => 'Person', - 'password' => 'b109f3bbbc244eb82441917ed06d618b9008dd09b3befd1b5e07394c706a8bb980b1d7'. - '785e5976ec049b46df5f1326af5a2ea6d103fd07c95385ffab0cacbc86'); + $password = 'b109f3bbbc244eb82441917ed06d618b9008dd09b3befd1b5e07394c706a8bb980b1d7'; + $password .= '785e5976ec049b46df5f1326af5a2ea6d103fd07c95385ffab0cacbc86'; + $expected = array('username' => 'Person') + compact('password'); $this->assertEqual($expected, $result); } @@ -35,11 +35,9 @@ class FormTest extends \lithium\test\Unit { $request = new Request(); $request->data = array('username' => 'Person', 'password' => 'password'); - $expected = array( - 'username' => sha1('Person'), - 'password' => 'b109f3bbbc244eb82441917ed06d618b9008dd09b3befd1b5e07394c706a8bb980b1d7'. - '785e5976ec049b46df5f1326af5a2ea6d103fd07c95385ffab0cacbc86' - ); + $password = 'b109f3bbbc244eb82441917ed06d618b9008dd09b3befd1b5e07394c706a8bb980b1d7'; + $password .= '785e5976ec049b46df5f1326af5a2ea6d103fd07c95385ffab0cacbc86'; + $expected = array('username' => sha1('Person')) + compact('password'); $this->assertEqual($expected, $subject->check($request)); } diff --git a/libraries/lithium/tests/cases/test/filter/AffectedTest.php b/libraries/lithium/tests/cases/test/filter/AffectedTest.php index d3d3ce8..756b0d5 100644 --- a/libraries/lithium/tests/cases/test/filter/AffectedTest.php +++ b/libraries/lithium/tests/cases/test/filter/AffectedTest.php @@ -79,9 +79,11 @@ class AffectedTest extends \lithium\test\Unit { } public function testAnalyze() { + $ns = 'lithium\tests\cases'; + $expected = array( - 'lithium\g11n\Message' => 'lithium\tests\cases\g11n\MessageTest', - 'lithium\console\command\g11n\Extract' => 'lithium\tests\cases\console\command\g11n\ExtractTest' + 'lithium\g11n\Message' => "{$ns}\g11n\MessageTest", + 'lithium\console\command\g11n\Extract' => "{$ns}\console\command\g11n\ExtractTest" ); $group = new Group();