Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make tests/cases/test/FixturesTest run on Windows. #6

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions test/Fixture.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ class Fixture extends \lithium\core\Adaptable {

/**
* A list of common classes to wrap your fixture data.
*
*
* @var array
*/
protected static $_classes = array(
Expand Down Expand Up @@ -120,7 +120,7 @@ public static function adapter($name = null) {
* @param array $options Additional options can be specified here. Possible options are:
* - `adapter`: the adapter to use to load the fixture
* - `class` : a class to wrap the data in
* - `library` : look for the fixtures in a different library
* - `library` : look for the fixtures in a different library
* - `path` : String-insert style file path
* - `sources`: add more parsing sources. Out of the box Json is used.
* @return array|object The array of data, optionally wrapped in a class such as
Expand All @@ -137,7 +137,7 @@ public static function load($file, array $options = array()) {
$options['adapter'] = $adapter = static::adapter($options['adapter']);
$file = static::file($file, $options);

if (is_readable($file)) {
if (file_exists($file) && is_readable($file) && !is_dir($file)) {
$data = $adapter::parse($file);
if ($options['class'] === false) {
return $data;
Expand All @@ -161,11 +161,11 @@ public static function load($file, array $options = array()) {
*
* @param string $file The name of the file. It will be lowercased and slugified
* by the inflector. Directory separators will be preserved.
* @param object|array $data If an instance of a Collection, data will
* @param object|array $data If an instance of a Collection, data will
* @param array $options Additional options can be specified here. Possible options are:
* - `adapter`: the adapter to use to load the fixture
* - `cast` : set to false to prevent `Collection` being converted to arrays.
* - `library` : save the fixtures in a different library
* - `library` : save the fixtures in a different library
* - `path`: can be an absolute or relative path to the fixture file.
* @return boolean Returns whether the file saving was successful or not.
*/
Expand Down
35 changes: 11 additions & 24 deletions tests/cases/test/FixtureTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -170,42 +170,29 @@ protected function _testLoad($posts) {
* sublcass of lithium\util\Collection in the current implementation).
*/
public function testLoadResultClass() {
$options = array(
'path' => dirname(dirname(__DIR__)).'/fixtures'
);
$ships = Fixture::load('Pirate', $options);
$path = dirname(dirname(__DIR__)).'/fixtures/{:file}.{:type}';
$options = array('path' => $path);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can change this to $options = compact('path');.

$ships = Fixture::load('models/Pirates', $options);
$expected = 'lithium\util\Collection';
$this->assertEqual($expected, get_class($ships));

$options = array(
'path' => dirname(dirname(__DIR__)).'/fixtures',
'collection' => 'Collection'
);
$ships = Fixture::load('Pirate', $options);
$options = array('path' => $path, 'collection' => 'Collection');
$ships = Fixture::load('models/Pirates', $options);
$expected = 'lithium\util\Collection';
$this->assertEqual($expected, get_class($ships));

$options = array(
'path' => dirname(dirname(__DIR__)).'/fixtures',
'collection' => 'DocumentSet'
);
$ships = Fixture::load('Pirate', $options);
$options = array('path' => $path, 'collection' => 'DocumentSet');
$ships = Fixture::load('models/Pirates', $options);
$expected = 'lithium\data\collection\DocumentSet';
$this->assertEqual($expected, get_class($ships));

$options = array(
'path' => dirname(dirname(__DIR__)).'/fixtures',
'collection' => 'DocumentArray'
);
$ships = Fixture::load('Pirate', $options);
$options = array('path' => $path, 'collection' => 'DocumentArray');
$ships = Fixture::load('models/Pirates', $options);
$expected = 'lithium\data\collection\DocumentArray';
$this->assertEqual($expected, get_class($ships));

$options = array(
'path' => dirname(dirname(__DIR__)).'/fixtures',
'collection' => 'RecordSet'
);
$ships = Fixture::load('Pirate', $options);
$options = array('path' => $path, 'collection' => 'RecordSet');
$ships = Fixture::load('models/Pirates', $options);
$expected = 'lithium\data\collection\RecordSet';
$this->assertEqual($expected, get_class($ships));

Expand Down