Skip to content

Commit

Permalink
Fix - load factories using absolute paths
Browse files Browse the repository at this point in the history
  • Loading branch information
mnabialek committed Sep 22, 2016
1 parent cde0ced commit af65ecd
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 4 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
## Release notes

### v0.2.4 (2016-09-22)

- fix using absolute paths when loading factories

### v0.2.3 (2016-09-04)

- fix using absolute paths to verify whether files exists
Expand Down
2 changes: 1 addition & 1 deletion phpunit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
processIsolation="false"
stopOnFailure="false">
<testsuites>
<testsuite name="LaravelEloquentFilter">
<testsuite name="Tests">
<directory suffix="Test.php">./tests</directory>
</testsuite>
</testsuites>
Expand Down
3 changes: 2 additions & 1 deletion src/Services/Modular.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,8 @@ public function loadFactories($factory)
{
$this->withFactories()->each(function ($module) use ($factory) {
/* @var Module $module */
$this->loadFactoryFile($module->factoryFilePath(), $factory);
$this->loadFactoryFile($this->app->basePath() . DIRECTORY_SEPARATOR .
$module->factoryFilePath(), $factory);
});
}

Expand Down
7 changes: 5 additions & 2 deletions tests/Services/ModularTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -132,12 +132,15 @@ protected function verifyCorrectLoadingRoutesForType($type)
/** @test */
public function it_loads_valid_factories()
{
$basePath = 'base/path';
$moduleAFactoryFile = 'moduleA/factory.php';
$moduleBFactoryFile = 'moduleB/factory.php';

$moduleA = m::mock(stdClass::class);
$moduleB = m::mock(stdClass::class);

$this->app->shouldReceive('basePath')->times(2)->andReturn($basePath);

$factory = new Factory(new Faker());

$this->modular->shouldReceive('withFactories')->once()
Expand All @@ -147,13 +150,13 @@ public function it_loads_valid_factories()
->withNoArgs()->andReturn($moduleAFactoryFile);

$this->modular->shouldReceive('loadFactoryFile')->once()
->with($moduleAFactoryFile, $factory);
->with($basePath . DIRECTORY_SEPARATOR . $moduleAFactoryFile, $factory);

$moduleB->shouldReceive('factoryFilePath')->once()
->withNoArgs()->andReturn($moduleBFactoryFile);

$this->modular->shouldReceive('loadFactoryFile')->once()
->with($moduleBFactoryFile, $factory);
->with($basePath . DIRECTORY_SEPARATOR .$moduleBFactoryFile, $factory);

$this->assertSame(null, $this->modular->loadFactories($factory));
}
Expand Down

0 comments on commit af65ecd

Please sign in to comment.