Skip to content

Commit 2156dfc

Browse files
committed
tests:add tests for different package and project configs
1 parent 58553cf commit 2156dfc

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

tests/CommandTest.php

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
namespace RonasIT\Support\Tests;
44

55
use Carbon\Carbon;
6+
use Illuminate\Support\Facades\Config;
7+
use org\bovigo\vfs\vfsStream;
68
use RonasIT\Support\Exceptions\ClassNotExistsException;
79
use RonasIT\Support\Tests\Support\Command\CommandMockTrait;
810
use UnexpectedValueException;
@@ -113,4 +115,32 @@ public function testMakeOnly()
113115
$this->assertFileDoesNotExist('tests/fixtures/NovaPostTest/create_post_response.json');
114116
$this->assertFileDoesNotExist('tests/fixtures/NovaPostTest/update_post_request.json');
115117
}
118+
119+
public function testCallWithNotDefaultConfig()
120+
{
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);
131+
132+
Config::set('entity-generator', ['test' => 'changed']);
133+
134+
$this->artisan('make:entity Post')
135+
->expectsOutput('Config has been updated')
136+
->assertExitCode(0);
137+
138+
$configPath = $rootUrl . '/config/entity-generator.php';
139+
140+
$updated = include $configPath;
141+
142+
$this->assertTrue(file_exists($configPath));
143+
144+
$this->assertEquals(array_merge(['test' => 'changed'], config('entity-generator')), $updated);
145+
}
116146
}

0 commit comments

Comments
 (0)