Skip to content
Browse files

Misc fixes and cleanup.

  • Loading branch information...
1 parent 6509e1e commit c1aa99127ce357fa0cc06169edaf50f001888ca8 @daschl committed
View
3 config/bootstrap.php
@@ -8,6 +8,9 @@
use lithium\core\Libraries;
+/**
+ * Adds the appropriate library paths for the li3_fixtures library.
+ */
if (Libraries::paths('fixture') === null) {
Libraries::paths(array(
'fixture' => array(
View
42 test/Fixture.php
@@ -48,13 +48,6 @@
class Fixture extends \lithium\core\Adaptable {
/**
- * Stores configurations for various authentication adapters.
- *
- * @var object `Collection` of authentication configurations.
- */
- protected static $_configurations = array();
-
- /**
* Specifies the default values that get loaded.
* @var array
*/
@@ -75,6 +68,13 @@ class Fixture extends \lithium\core\Adaptable {
protected static $_adapters = 'fixture.test.fixture';
/**
+ * Stores configurations for various fixture adapters.
+ *
+ * @var object `Collection` of fixture configurations.
+ */
+ protected static $_configurations = array();
+
+ /**
* A list of common classes to wrap your fixture data.
*
* @var array
@@ -86,6 +86,12 @@ class Fixture extends \lithium\core\Adaptable {
'RecordSet' => 'lithium\data\collection\RecordSet'
);
+ /**
+ * Sets or gets the current adapter.
+ *
+ * @param string $name Class name of adapter to load.
+ * @return object Adapter object.
+ */
public static function adapter($name = null) {
if (!isset(static::$_configurations[$name])) {
$config = array(
@@ -102,13 +108,13 @@ public static function adapter($name = null) {
}
/**
- * Loads Fixture data
+ * Loads Fixture data.
*
- * The load method loads the fixture file based on the $file param and then hands
- * it over to the source parser (json by default). After parsing, it returns the
- * data. If you specify an optional class parameter, if will wrap the data in the
- * class and pass the data into the class constructor's data param. This is
- * compatible with the way Lithium `Collection` classes work.
+ * The load method loads the fixture file based on the $file param and then hands it over to
+ * the source parser (json by default). After parsing, it returns the data. If you specify an
+ * optional class parameter, if will wrap the data in the class and pass the data into the
+ * class constructor's data param. This is compatible with the way how Lithium `Collection`
+ * classes work.
*
* @param string $file The name of the file without the file extension.
* @param array $options Additional options can be specified here. Possible options are:
@@ -151,7 +157,7 @@ public static function load($file, array $options = array()) {
}
/**
- * Saves data to a fixture
+ * Saves data to a fixture file.
*
* @param string $file The name of the file. It will be lowercased and slugified
* by the inflector. Directory separators will be preserved.
@@ -161,7 +167,7 @@ public static function load($file, array $options = array()) {
* - `cast` : set to false to prevent `Collection` being converted to arrays.
* - `library` : save the fixtures in a different library
* - `path`: can be an absolute or relative path to the fixture file.
- * @return boolean
+ * @return boolean Returns whether the file saving was successful or not.
*/
public static function save($file, $data, array $options = array()) {
$options = $options + static::$_defaults;
@@ -190,10 +196,10 @@ public static function save($file, $data, array $options = array()) {
}
/**
- * Returns the path to a fixture file
+ * Returns the path to a fixture file.
*
- * @param string $file
- * @param array $options
+ * @param string $file The filepath of the fixture file.
+ * @param array $options Additional options to pass.
* @see li3_fixtures\test\Fixture::load()
*/
public static function file($file, array $options = array()) {
View
9 test/fixture/adapter/Json.php
@@ -12,12 +12,12 @@
use RuntimeException;
/**
- * Parses a given json file and returns it as an associative array.
+ * Parses a given json source file and returns it as an associative array.
*/
class Json extends \lithium\core\StaticObject {
/**
- * The file extension for the fixture files
+ * The file extension for the fixture files.
*
* @var string
*/
@@ -26,9 +26,8 @@ class Json extends \lithium\core\StaticObject {
/**
* Parses the file and returns it as an associative array.
*
- * If an error occurs during the parsing process, a RuntimeException is
- * raised instead of the array. This will then usually be shown in the
- * Testing-Webinterface.
+ * If an error occurs during the parsing process, a RuntimeException is raised instead of the
+ * array. This will then usually be shown in the Testing-Webinterface.
*
* @param string $file Filepath to the json file.
* @return array Fixtures as an associative array.
View
20 test/fixture/adapter/Php.php
@@ -11,12 +11,12 @@
use RuntimeException;
/**
- * Parses a given php file and returns the data from it.
+ * Parses a given PHP source file and returns the data from it.
*/
class Php extends \lithium\core\StaticObject {
/**
- * The file extension for the fixture files
+ * The file extension for the fixture files.
*
* @var string
*/
@@ -25,14 +25,12 @@ class Php extends \lithium\core\StaticObject {
/**
* Parses the file and returns it as an associative array.
*
- * The php file is expected to contain one var named `$data` that is
- * an associative array.
+ * The php file is expected to contain one var named `$data` that is an associative array.
*
- * If an error occurs during the parsing process, a RuntimeException is
- * raised instead of the array. This will then usually be shown in the
- * Testing-Webinterface.
+ * If an error occurs during the parsing process, a RuntimeException is raised instead of the
+ * array. This will then usually be shown in the Testing-Webinterface.
*
- * @param string $file Filepath to the json file.
+ * @param string $file Filepath to the PHP file.
* @return array Fixtures as an associative array.
*/
public static function parse($file) {
@@ -44,10 +42,10 @@ public static function parse($file) {
}
/**
- * Encodes data in prep of saving to a file
+ * Encodes data in prep of saving to a file.
*
- * @param array $data
- * @return string
+ * @param array $data The data to encode.
+ * @return string The encoded string.
*/
public static function encode($data) {
return "<?php\n\n\$data = " . var_export($data, true) . ";\n\n?>\n";
View
15 tests/cases/test/FixtureTest.php
@@ -76,23 +76,18 @@ public function testLoadWithDocumentArray() {
}
/**
- * Also test with DocumentSet instead of Collection.
- *
- * Currently, the RecordSet is commented out because of a
- * possible bug. If this situation is resolved, this should
- * be commented in again.
+ * Also test with RecordSet instead of Collection.
*
- * @see http://rad-dev.org/lithium/tickets/view/259
*/
- /*public function testLoadWithRecordSet() {
+ public function testLoadWithRecordSet() {
$options = $this->_loadOptions;
$options['collection'] = 'RecordSet';
$posts = Fixture::load('models/Posts', $options);
$this->_testLoad($posts);
- }*/
+ }
/**
- * Test Load with custom class
+ * Test Load with custom class.
*/
public function testLoadWithCustomCollection() {
$options = $this->_loadOptions;
@@ -102,7 +97,7 @@ public function testLoadWithCustomCollection() {
}
/**
- * Test Load without automatically wrapping the object into a Collection class
+ * Test Load without automatically wrapping the object into a Collection class.
*/
public function testLoadWithoutWrap() {
$options = array(
View
9 tests/integration/test/FixtureTest.php
@@ -16,14 +16,14 @@
class FixtureTest extends \lithium\test\Integration {
/**
- * Holds options for all tests
+ * Holds options for all tests.
*/
protected $_options = array(
'library' => 'li3_fixtures'
);
/**
- * Tests the Load Method Full Stack
+ * Tests the Load Method Full Stack.
*/
public function testLoad() {
$ships = Fixture::load('models/Pirates', $this->_options);
@@ -48,9 +48,12 @@ public function testLoad() {
}
/**
- * Tests the Save Method Full Stack
+ * Tests the Save Method Full Stack.
*/
public function testSave() {
+ $file = LITHIUM_LIBRARY_PATH . '/li3_fixtures/tests/fixtures/models/pirates.json';
+ $this->skipIf(!is_writable($file), "$file is not writable.");
+
$expected = Fixture::load('models/Pirates', $this->_options);
$result = Fixture::save('models/Pirates', $expected, $this->_options);
$this->assertTrue($result);

0 comments on commit c1aa991

Please sign in to comment.
Something went wrong with that request. Please try again.