Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
80 changes: 20 additions & 60 deletions tests/Feature/BlueprintTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,7 @@ protected function setUp(): void
$this->subject = new Blueprint();
}

/**
* @test
*/
/** @test */
public function it_parses_models()
{
$blueprint = $this->fixture('drafts/models-only.yaml');
Expand Down Expand Up @@ -68,9 +66,7 @@ public function it_parses_seeders()
], $this->subject->parse($blueprint));
}

/**
* @test
*/
/** @test */
public function it_parses_controllers()
{
$blueprint = $this->fixture('drafts/controllers-only.yaml');
Expand All @@ -95,9 +91,7 @@ public function it_parses_controllers()
], $this->subject->parse($blueprint));
}

/**
* @test
*/
/** @test */
public function it_parses_shorthands()
{
$blueprint = $this->fixture('drafts/shorthands.yaml');
Expand All @@ -118,9 +112,7 @@ public function it_parses_shorthands()
], $this->subject->parse($blueprint));
}

/**
* @test
*/
/** @test */
public function it_parses_uuid_shorthand()
{
$blueprint = $this->fixture('drafts/uuid-shorthand.yaml');
Expand All @@ -135,9 +127,7 @@ public function it_parses_uuid_shorthand()
], $this->subject->parse($blueprint));
}

/**
* @test
*/
/** @test */
public function it_parses_shorthands_with_timezones()
{
$blueprint = $this->fixture('drafts/with-timezones.yaml');
Expand All @@ -152,9 +142,7 @@ public function it_parses_shorthands_with_timezones()
], $this->subject->parse($blueprint));
}

/**
* @test
*/
/** @test */
public function it_parses_longhands()
{
$blueprint = $this->fixture('drafts/longhands.yaml');
Expand All @@ -179,9 +167,7 @@ public function it_parses_longhands()
], $this->subject->parse($blueprint));
}

/**
* @test
*/
/** @test */
public function it_parses_resource_shorthands()
{
$blueprint = $this->fixture('drafts/with-timezones.yaml');
Expand All @@ -196,9 +182,7 @@ public function it_parses_resource_shorthands()
], $this->subject->parse($blueprint));
}

/**
* @test
*/
/** @test */
public function it_parses_the_readme_example()
{
$blueprint = $this->fixture('drafts/readme-example.yaml');
Expand Down Expand Up @@ -232,9 +216,7 @@ public function it_parses_the_readme_example()
], $this->subject->parse($blueprint));
}

/**
* @test
*/
/** @test */
public function it_parses_the_readme_example_with_different_platform_eols()
{
$definition = $this->fixture('drafts/readme-example.yaml');
Expand Down Expand Up @@ -278,9 +260,7 @@ public function it_parses_the_readme_example_with_different_platform_eols()
$this->assertEquals($expected, $this->subject->parse($definition_windows_eol));
}

/**
* @test
*/
/** @test */
public function it_parses_yaml_with_dashed_syntax()
{
$definition = $this->fixture('drafts/readme-example-dashes.yaml');
Expand Down Expand Up @@ -310,9 +290,7 @@ public function it_parses_yaml_with_dashed_syntax()
$this->assertEquals($expected, $this->subject->parse($definition));
}

/**
* @test
*/
/** @test */
public function it_allows_parsing_without_stripping_dashes()
{
$sequence = [
Expand All @@ -322,9 +300,7 @@ public function it_allows_parsing_without_stripping_dashes()
$this->assertEquals($sequence, $this->subject->parse($this->subject->dump($sequence), false));
}

/**
* @test
*/
/** @test */
public function it_throws_a_custom_error_when_parsing_fails()
{
$this->expectException(ParseException::class);
Expand All @@ -334,9 +310,7 @@ public function it_throws_a_custom_error_when_parsing_fails()
$this->subject->parse($blueprint);
}

/**
* @test
*/
/** @test */
public function analyze_return_default_tree_for_empty_tokens()
{
$tokens = [];
Expand All @@ -350,9 +324,7 @@ public function analyze_return_default_tree_for_empty_tokens()
);
}

/**
* @test
*/
/** @test */
public function analyze_uses_register_lexers_to_analyze_tokens()
{
$lexer = \Mockery::mock(Lexer::class);
Expand All @@ -370,9 +342,7 @@ public function analyze_uses_register_lexers_to_analyze_tokens()
], $this->subject->analyze($tokens)->toArray());
}

/**
* @test
*/
/** @test */
public function generate_uses_registered_generators_and_returns_generated_files()
{
$generatorOne = \Mockery::mock(Generator::class);
Expand Down Expand Up @@ -417,9 +387,7 @@ public function generate_uses_registered_generators_and_returns_generated_files(
], $this->subject->generate($tree));
}

/**
* @test
*/
/** @test */
public function generate_uses_swapped_generator_and_returns_generated_files()
{
$generatorOne = \Mockery::mock(Generator::class);
Expand Down Expand Up @@ -452,9 +420,7 @@ public function generate_uses_swapped_generator_and_returns_generated_files()
], $this->subject->generate($tree));
}

/**
* @test
*/
/** @test */
public function generate_only_one_specific_type()
{
$generatorFoo = \Mockery::mock(Generator::class);
Expand Down Expand Up @@ -503,9 +469,7 @@ public function generate_only_one_specific_type()
], $actual);
}

/**
* @test
*/
/** @test */
public function generate_only_specific_types()
{
$generatorFoo = \Mockery::mock(Generator::class);
Expand Down Expand Up @@ -554,9 +518,7 @@ public function generate_only_specific_types()
], $actual);
}

/**
* @test
*/
/** @test */
public function generate_should_skip_one_specific_type()
{
$generatorFoo = \Mockery::mock(Generator::class);
Expand Down Expand Up @@ -605,9 +567,7 @@ public function generate_should_skip_one_specific_type()
], $actual);
}

/**
* @test
*/
/** @test */
public function generate_should_skip_specific_types()
{
$generatorFoo = \Mockery::mock(Generator::class);
Expand Down
32 changes: 9 additions & 23 deletions tests/Feature/Commands/BuildCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,28 +6,26 @@
use Blueprint\Builder;
use Mockery\Adapter\Phpunit\MockeryPHPUnitIntegration;
use Tests\TestCase;
use Tests\Traits\MocksFilesystem;

/**
* @covers \Blueprint\Commands\BuildCommand
*/
class BuildCommandTest extends TestCase
{
use MockeryPHPUnitIntegration;
use MockeryPHPUnitIntegration, MocksFilesystem;

/** @test */
public function it_uses_the_default_draft_file()
{
$filesystem = \Mockery::mock(\Illuminate\Filesystem\Filesystem::class)->makePartial();
$this->swap('files', $filesystem);

$filesystem->shouldReceive('exists')
$this->files->shouldReceive('exists')
->with('draft.yaml')
->andReturnTrue();

$builder = $this->mock(Builder::class);

$builder->shouldReceive('execute')
->with(resolve(Blueprint::class), $filesystem, 'draft.yaml', '', '', false)
->with(resolve(Blueprint::class), $this->files, 'draft.yaml', '', '', false)
->andReturn(collect([]));

$this->artisan('blueprint:build')
Expand All @@ -37,17 +35,14 @@ public function it_uses_the_default_draft_file()
/** @test */
public function it_passes_the_command_args_to_the_builder_in_right_order()
{
$filesystem = \Mockery::mock(\Illuminate\Filesystem\Filesystem::class)->makePartial();
$this->swap('files', $filesystem);

$filesystem->shouldReceive('exists')
$this->files->shouldReceive('exists')
->with('test.yml')
->andReturnTrue();

$builder = $this->mock(Builder::class);

$builder->shouldReceive('execute')
->with(resolve(Blueprint::class), $filesystem, 'test.yml', 'a,b,c', 'x,y,z', false)
->with(resolve(Blueprint::class), $this->files, 'test.yml', 'a,b,c', 'x,y,z', false)
->andReturn(collect([]));

$this->artisan('blueprint:build test.yml --only=a,b,c --skip=x,y,z')
Expand All @@ -57,10 +52,7 @@ public function it_passes_the_command_args_to_the_builder_in_right_order()
/** @test */
public function it_fails_if_the_draft_file_not_exists()
{
$filesystem = \Mockery::mock(\Illuminate\Filesystem\Filesystem::class)->makePartial();
$this->swap('files', $filesystem);

$filesystem->shouldReceive('exists')
$this->files->shouldReceive('exists')
->with('test.yml')
->andReturnFalse();

Expand All @@ -75,24 +67,18 @@ public function it_fails_if_the_draft_file_not_exists()
/** @test */
public function it_shows_the_generated_files_groupbed_by_actions()
{
$filesystem = \Mockery::mock(\Illuminate\Filesystem\Filesystem::class)->makePartial();
$this->swap('files', $filesystem);

$filesystem->shouldReceive('exists')
$this->files->shouldReceive('exists')
->with('draft.yaml')
->andReturnTrue();

$builder = $this->mock(Builder::class);

$builder->shouldReceive('execute')
->with(resolve(Blueprint::class), $filesystem, 'draft.yaml', '', '', false)
->with(resolve(Blueprint::class), $this->files, 'draft.yaml', '', '', false)
->andReturn(collect([
"created" => [
"file1",
"file2",
]
]));

$this->artisan('blueprint:build')
->assertExitCode(0)
->expectsOutput('Created:')
Expand Down
Loading