Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
update(config/model command): add option to force usage of FQN + tests (
- Loading branch information
Showing
5 changed files
with
267 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
tests/Console/ModelsCommand/GeneratePhpdocWithForcedFqn/Models/Post.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\GeneratePhpdocWithForcedFqn\Models; | ||
|
||
use Eloquent; | ||
use Illuminate\Database\Eloquent\{ | ||
Builder as EloquentBuilder, | ||
Collection, | ||
SoftDeletes | ||
}; | ||
use Illuminate\Database\Eloquent\Model; | ||
use Illuminate\Database\Eloquent\Relations\HasMany; | ||
use Illuminate\Database\Query\Builder as QueryBuilder; | ||
use Illuminate\Support\Carbon; | ||
|
||
class Post extends Model | ||
{ | ||
use SoftDeletes; | ||
|
||
public function posts(): HasMany | ||
{ | ||
return $this->hasMany(Post::class); | ||
} | ||
|
||
public function scopeNull($query, string $unusedParam) | ||
{ | ||
return $query; | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
tests/Console/ModelsCommand/GeneratePhpdocWithForcedFqn/Test.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\GeneratePhpdocWithForcedFqn; | ||
|
||
use Barryvdh\LaravelIdeHelper\Console\ModelsCommand; | ||
use Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\AbstractModelsCommand; | ||
|
||
class Test extends AbstractModelsCommand | ||
{ | ||
protected function getEnvironmentSetUp($app) | ||
{ | ||
parent::getEnvironmentSetUp($app); | ||
|
||
$app['config']->set('ide-helper.force_fqn', true); | ||
} | ||
|
||
public function test(): void | ||
{ | ||
$command = $this->app->make(ModelsCommand::class); | ||
|
||
$tester = $this->runCommand($command, [ | ||
'--write' => true, | ||
]); | ||
|
||
$this->assertSame(0, $tester->getStatusCode()); | ||
$this->assertStringContainsString('Written new phpDocBlock to', $tester->getDisplay()); | ||
$this->assertMatchesMockedSnapshot(); | ||
} | ||
} |
Oops, something went wrong.