Skip to content

Commit

Permalink
Optimize test with mocked app
Browse files Browse the repository at this point in the history
  • Loading branch information
caendesilva committed Dec 22, 2024
1 parent 2438471 commit 204ab8a
Showing 1 changed file with 17 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,16 @@
*/
class InteractivePublishCommandHelperTest extends UnitTestCase
{
use CreatesApplication;

protected static bool $needsKernel = true;

protected Filesystem|Mockery\MockInterface $filesystem;

protected $originalApp;

protected function setUp(): void
{
$app = $this->createApplication();
$app = $this->setupMockApplication();

Container::setInstance($app);

$this->filesystem = $this->mockFilesystemStrict();
Expand All @@ -50,6 +51,7 @@ protected function tearDown(): void

Container::setInstance();
Facade::clearResolvedInstances();
Facade::setFacadeApplication(null);
}

public function testGetFileChoices()
Expand Down Expand Up @@ -114,4 +116,16 @@ public function testFormatOutput()

$this->assertSame('Published files [app.blade.php, page.blade.php, post.blade.php]', $output);
}

protected function setupMockApplication(): Container
{
$this->originalApp = Container::getInstance();

$app = Mockery::mock(app())->makePartial();
$app->shouldReceive('resourcePath')->andReturnUsing(fn (string $path) => "resources/$path");

Container::setInstance($app);

return $app;
}
}

0 comments on commit 204ab8a

Please sign in to comment.