44
55namespace Hyde \Framework \Testing \Unit ;
66
7- use Hyde \Console \Helpers \InteractivePublishCommandHelper ;
8- use Hyde \Foundation \Providers \ViewServiceProvider ;
7+ use Hyde \Testing \CreatesApplication ;
8+ use Illuminate \Filesystem \Filesystem ;
9+ use Mockery ;
910use Hyde \Hyde ;
1011use Hyde \Testing \UnitTestCase ;
12+ use Hyde \Foundation \Providers \ViewServiceProvider ;
13+ use Hyde \Console \Helpers \InteractivePublishCommandHelper ;
1114use Illuminate \Container \Container ;
1215use Illuminate \Support \Facades \Blade ;
1316use Illuminate \Support \Facades \Facade ;
1417use Illuminate \Support \Facades \File ;
15- use Mockery ;
1618use Symfony \Component \Finder \SplFileInfo ;
1719
1820/**
2224 */
2325class InteractivePublishCommandHelperTest extends UnitTestCase
2426{
25- protected static bool $ needsKernel = true ;
27+ use CreatesApplication ;
2628
27- /** @var \Illuminate\Filesystem\Filesystem&\Mockery\MockInterface */
28- protected $ filesystem ;
29+ protected static bool $ needsKernel = true ;
2930
30- protected $ originalApp ;
31+ protected Filesystem | Mockery \ MockInterface $ filesystem ;
3132
3233 protected function setUp (): void
3334 {
35+ $ app = $ this ->createApplication ();
36+ Container::setInstance ($ app );
37+
3438 $ this ->filesystem = $ this ->mockFilesystemStrict ();
3539
3640 File::swap ($ this ->filesystem );
3741 Blade::partialMock ()->shouldReceive ('component ' );
3842
39- $ app = $ this ->setupMockApplication ();
40-
4143 (new ViewServiceProvider ($ app ))->boot ();
4244 }
4345
4446 protected function tearDown (): void
4547 {
4648 $ this ->verifyMockeryExpectations ();
4749
48- Container::setInstance ($ this -> originalApp );
50+ Container::setInstance ();
4951 Facade::clearResolvedInstances ();
5052 }
5153
@@ -80,8 +82,8 @@ public function testHandle()
8082 $ this ->filesystem ->shouldReceive ('copy ' )->twice ();
8183
8284 $ helper ->handle ([
83- " resources/views/vendor/hyde/layouts/app.blade.php " ,
84- " resources/views/vendor/hyde/layouts/page.blade.php " ,
85+ ' resources/views/vendor/hyde/layouts/app.blade.php ' ,
86+ ' resources/views/vendor/hyde/layouts/page.blade.php ' ,
8587 ]);
8688
8789 $ this ->filesystem ->shouldHaveReceived ('ensureDirectoryExists ' )
@@ -98,16 +100,4 @@ public function testHandle()
98100 Hyde::path ('resources/views/vendor/hyde/layouts/page.blade.php ' )
99101 )->once ();
100102 }
101-
102- protected function setupMockApplication (): Container
103- {
104- $ this ->originalApp = Container::getInstance ();
105-
106- $ app = Mockery::mock (app ())->makePartial ();
107- $ app ->shouldReceive ('resourcePath ' )->andReturnUsing (fn (string $ path ) => "resources/ $ path " );
108-
109- Container::setInstance ($ app );
110-
111- return $ app ;
112- }
113103}
0 commit comments