Skip to content

Commit de322c2

Browse files
author
Nathan Esayeas
authored
View generator test and fixtures (#373)
1 parent a8bca2f commit de322c2

File tree

5 files changed

+31
-9
lines changed

5 files changed

+31
-9
lines changed

stubs/view.stub

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
@extends('layouts.app')
1+
{--
2+
@extends('layouts.app')
23

3-
@section('content')
4-
{{ view }} template
5-
@endsection
4+
@section('content')
5+
{{ view }} template
6+
@endsection
7+
--}

tests/Feature/Generators/Statements/ViewGeneratorTest.php

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,9 @@ public function output_writes_nothing_without_render_statements()
6868
*/
6969
public function output_writes_views_for_render_statements()
7070
{
71-
$template = $this->stub('view.stub');
7271
$this->files->expects('stub')
7372
->with('view.stub')
74-
->andReturn($template);
73+
->andReturn($this->stub('view.stub'));
7574

7675
$this->files->shouldReceive('exists')
7776
->times(2)
@@ -81,13 +80,13 @@ public function output_writes_views_for_render_statements()
8180
->with('resources/views/user/index.blade.php')
8281
->andReturnFalse();
8382
$this->files->expects('put')
84-
->with('resources/views/user/index.blade.php', str_replace('{{ view }}', 'user.index', $template));
83+
->with('resources/views/user/index.blade.php', $this->fixture('views/user.index.blade.php'));
8584

8685
$this->files->expects('exists')
8786
->with('resources/views/user/create.blade.php')
8887
->andReturnFalse();
8988
$this->files->expects('put')
90-
->with('resources/views/user/create.blade.php', str_replace('{{ view }}', 'user.create', $template));
89+
->with('resources/views/user/create.blade.php', $this->fixture('views/user.create.blade.php'));
9190

9291
$this->files->expects('exists')
9392
->with('resources/views/post')
@@ -98,7 +97,7 @@ public function output_writes_views_for_render_statements()
9897
$this->files->expects('makeDirectory')
9998
->with('resources/views/post', 0755, true);
10099
$this->files->expects('put')
101-
->with('resources/views/post/show.blade.php', str_replace('{{ view }}', 'post.show', $template));
100+
->with('resources/views/post/show.blade.php', $this->fixture('views/post.show.blade.php'));
102101

103102
$tokens = $this->blueprint->parse($this->fixture('drafts/render-statements.yaml'));
104103
$tree = $this->blueprint->analyze($tokens);
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{--
2+
@extends('layouts.app')
3+
4+
@section('content')
5+
post.show template
6+
@endsection
7+
--}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{--
2+
@extends('layouts.app')
3+
4+
@section('content')
5+
user.create template
6+
@endsection
7+
--}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{--
2+
@extends('layouts.app')
3+
4+
@section('content')
5+
user.index template
6+
@endsection
7+
--}

0 commit comments

Comments
 (0)