8
8
use Blueprint \Tracer ;
9
9
use Illuminate \Support \Facades \File ;
10
10
use Mockery \Adapter \Phpunit \MockeryPHPUnitIntegration ;
11
+ use Symfony \Component \Yaml \Yaml ;
11
12
use Tests \TestCase ;
12
13
13
14
/**
@@ -69,7 +70,7 @@ public function relative_class_name_removes_models_namespace()
69
70
$ this ->assertEquals ($ method ->invoke (new Tracer (), app ('App\Comment ' )), 'Comment ' );
70
71
$ this ->assertEquals ($ method ->invoke (new Tracer (), app ('App\Models\Tag ' )), 'Tag ' );
71
72
}
72
-
73
+
73
74
public function it_passes_the_command_path_to_tracer ()
74
75
{
75
76
$ this ->filesystem ->shouldReceive ('exists ' )
@@ -85,4 +86,50 @@ public function it_passes_the_command_path_to_tracer()
85
86
$ this ->artisan ('blueprint:trace --path=vendor/package/src/app/Models ' )
86
87
->assertExitCode (0 );
87
88
}
89
+
90
+ /** @test */
91
+ public function it_traces_models_with_differente_namespaces ()
92
+ {
93
+ $ this ->requireFixture ('models/comment.php ' );
94
+ $ this ->requireFixture ('models/custom-models-namespace.php ' );
95
+
96
+ $ expectedBlueprint = Yaml::dump ([
97
+ 'models ' => [
98
+ 'Comment ' => [],
99
+ 'Models\Tag ' => [],
100
+ ],
101
+ ]);
102
+
103
+ $ this ->filesystem ->shouldReceive ('exists ' )
104
+ ->with ('app ' )
105
+ ->andReturnTrue ();
106
+
107
+ $ this ->filesystem ->shouldReceive ('allFiles ' )
108
+ ->with ('app ' )
109
+ ->andReturn ([
110
+ new \SplFileInfo ('Comment.php ' ),
111
+ new \SplFileInfo ('Models\Tag.php ' ),
112
+ new \SplFileInfo ('OtherFile.ext ' ),
113
+ ]);
114
+
115
+ $ this ->filesystem ->shouldReceive ('get ' )
116
+ ->with ('Comment.php ' )
117
+ ->andReturn ($ this ->fixture ('models/comment.php ' ));
118
+
119
+ $ this ->filesystem ->shouldReceive ('get ' )
120
+ ->with ('Models\Tag.php ' )
121
+ ->andReturn ($ this ->fixture ('models/custom-models-namespace.php ' ));
122
+
123
+ $ this ->filesystem ->shouldReceive ('exists ' )
124
+ ->with ('.blueprint ' )
125
+ ->andReturnFalse ();
126
+
127
+ $ this ->filesystem ->shouldReceive ('put ' )
128
+ ->with ('.blueprint ' , $ expectedBlueprint )
129
+ ->andReturnTrue ();
130
+
131
+ $ this ->artisan ('blueprint:trace ' )
132
+ ->assertExitCode (0 )
133
+ ->expectsOutput ('Traced 2 models ' );
134
+ }
88
135
}
0 commit comments