mirror of
https://github.com/barryvdh/laravel-ide-helper.git
synced 2026-08-18 10:07:12 +00:00
* install spatie/phpunit-snapshot-assertions * switch GenerateBasicPhpdocFinal test to snapshot assertion * use v3 of spatie/phpunit-snapshot-assertions to be PHP7.2 compatible * add txt snapshot driver * fix EloquentCommandTest * replace all heredocs by snapshots * make test compatible with old/deprecated versions * Update composer.json * normalize composer.json * fix merge conflict * Allow older snapshot versions * normalize composer.json Co-authored-by: Barry vd. Heuvel <[email protected]> Co-authored-by: barryvdh <[email protected]>
72 lines
2.0 KiB
PHP
72 lines
2.0 KiB
PHP
<?php declare(strict_types=1);
|
|
|
|
namespace Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\CustomDate;
|
|
|
|
use Barryvdh\LaravelIdeHelper\Console\ModelsCommand;
|
|
use Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\AbstractModelsCommand;
|
|
use Carbon\CarbonImmutable;
|
|
use Illuminate\Filesystem\Filesystem;
|
|
use Illuminate\Support\Carbon;
|
|
use Illuminate\Support\Facades\Date;
|
|
use Mockery;
|
|
|
|
class Test extends AbstractModelsCommand
|
|
{
|
|
protected function setUp(): void
|
|
{
|
|
parent::setUp();
|
|
|
|
Date::use(CarbonImmutable::class);
|
|
}
|
|
|
|
protected function tearDown(): void
|
|
{
|
|
Date::use(Carbon::class);
|
|
|
|
parent::tearDown();
|
|
}
|
|
|
|
protected function getEnvironmentSetUp($app)
|
|
{
|
|
parent::getEnvironmentSetUp($app);
|
|
|
|
$app['config']->set('ide-helper', [
|
|
'model_locations' => [
|
|
// This is calculated from the base_path() which points to
|
|
// vendor/orchestra/testbench-core/laravel
|
|
'/../../../../tests/Console/ModelsCommand/CustomDate/Models',
|
|
],
|
|
]);
|
|
}
|
|
|
|
public function test(): void
|
|
{
|
|
$actualContent = null;
|
|
$mockFilesystem = Mockery::mock(Filesystem::class);
|
|
$mockFilesystem
|
|
->shouldReceive('get')
|
|
->andReturn(file_get_contents(__DIR__ . '/Models/CustomDate.php'))
|
|
->once();
|
|
$mockFilesystem
|
|
->shouldReceive('put')
|
|
->with(
|
|
Mockery::any(),
|
|
Mockery::capture($actualContent)
|
|
)
|
|
->andReturn(1) // Simulate we wrote _something_ to the file
|
|
->once();
|
|
|
|
$this->instance(Filesystem::class, $mockFilesystem);
|
|
|
|
$command = $this->app->make(ModelsCommand::class);
|
|
|
|
$tester = $this->runCommand($command, [
|
|
'--write' => true,
|
|
]);
|
|
|
|
$this->assertSame(0, $tester->getStatusCode());
|
|
$this->assertEmpty($tester->getDisplay());
|
|
$this->assertMatchesPhpSnapshot($actualContent);
|
|
}
|
|
}
|