Permalink
Browse files

Fixing misc. QA issues and adding docblocks.

  • Loading branch information...
1 parent 99f687c commit 6cbb2cd3d1ef742950785f68ce549283b38d8385 @nateabele nateabele committed Mar 12, 2011
@@ -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 @@ public function run() {
* -------- ------
* / {"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"}
* }}}
@@ -134,6 +134,16 @@ public static function handler($name, $info) {
* 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()) {
@@ -818,10 +818,6 @@ protected static function _locateAll(array $params, array $options = array()) {
$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);
@@ -339,9 +339,9 @@ public function update($id = null, array $data = array()) {
* @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 @@ public function increment($field, $value = 1) {
* @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);
View
No changes.
@@ -12,7 +12,7 @@
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
@@ -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,17 +43,18 @@ public function skip() {
* 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;',
'use lithium\core\Environment;',
'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 @@ public function setUp() {
* 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 @@ public function testShowWithHttpMethod() {
/**
* 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);
}
-
}
?>
@@ -387,7 +387,8 @@ public function testScopedUpdate() {
'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 @@ public function testQueryOperators() {
'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 @@ public function testQueryOperators() {
'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));
}
@@ -111,8 +111,7 @@ public function testMessageContentTypeParsing() {
$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',
@@ -24,9 +24,9 @@ public function testLogin() {
$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 @@ public function testLoginWithFilters() {
$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));
}
@@ -79,9 +79,11 @@ public function testCyclicDependency() {
}
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();

0 comments on commit 6cbb2cd

Please sign in to comment.