Skip to content

Commit dc3010d

Browse files
committed
refactor: move vfs code to testcase class
1 parent 2156dfc commit dc3010d

File tree

2 files changed

+15
-15
lines changed

2 files changed

+15
-15
lines changed

tests/CommandTest.php

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -118,29 +118,21 @@ public function testMakeOnly()
118118

119119
public function testCallWithNotDefaultConfig()
120120
{
121-
$rootUrl = vfsStream::setup('root', null, [
122-
'config' => [
123-
'entity-generator.php' => "<?php return ['test' => 'original'];",
124-
],
125-
'routes' => [
126-
'api.php' => "",
127-
],
128-
])->url();
129-
130-
$this->app->instance('path.base', $rootUrl);
121+
$this->app->instance('path.base', $this->generatedFileBasePath);
131122

132123
Config::set('entity-generator', ['test' => 'changed']);
133124

134-
$this->artisan('make:entity Post')
125+
$this
126+
->artisan('make:entity Post')
135127
->expectsOutput('Config has been updated')
136128
->assertExitCode(0);
137129

138-
$configPath = $rootUrl . '/config/entity-generator.php';
130+
$configPath = "{$this->generatedFileBasePath}/config/entity-generator.php";
139131

140132
$updated = include $configPath;
141133

142134
$this->assertTrue(file_exists($configPath));
143-
144-
$this->assertEquals(array_merge(['test' => 'changed'], config('entity-generator')), $updated);
135+
136+
$this->assertEquals(json_decode($this->getFixture('changed_config.json'), true), $updated, true);
145137
}
146138
}

tests/TestCase.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
use org\bovigo\vfs\vfsStream;
1212
use RonasIT\Support\EntityGeneratorServiceProvider;
1313
use RonasIT\Support\Traits\FixturesTrait;
14+
use org\bovigo\vfs\vfsStreamFile;
1415

1516
class TestCase extends BaseTestCase
1617
{
@@ -26,7 +27,14 @@ public function setUp(): void
2627

2728
$this->mockConfigurations();
2829

29-
vfsStream::setup();
30+
$root = vfsStream::setup();
31+
32+
vfsStream::newDirectory('config')->at($root);
33+
$routesDir = vfsStream::newDirectory('routes')->at($root);
34+
35+
$apiRoute = new vfsStreamFile('api.php');
36+
37+
$routesDir->addChild($apiRoute);
3038

3139
Event::fake();
3240

0 commit comments

Comments
 (0)