Skip to content

Commit

Permalink
Cleanup code and use real app
Browse files Browse the repository at this point in the history
  • Loading branch information
caendesilva committed Dec 22, 2024
1 parent 0651fef commit 8ab499e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ protected function findAllFilesForTag(): array
}

/**
* @param \Symfony\Component\Finder\SplFileInfo[] $search
* @param \Symfony\Component\Finder\SplFileInfo[] $search
* @return array<string, string>
*/
protected function mapPublishableFiles(array $search): array
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,17 @@

namespace Hyde\Framework\Testing\Unit;

use Hyde\Console\Helpers\InteractivePublishCommandHelper;
use Hyde\Foundation\Providers\ViewServiceProvider;
use Hyde\Testing\CreatesApplication;
use Illuminate\Filesystem\Filesystem;
use Mockery;
use Hyde\Hyde;
use Hyde\Testing\UnitTestCase;
use Hyde\Foundation\Providers\ViewServiceProvider;
use Hyde\Console\Helpers\InteractivePublishCommandHelper;
use Illuminate\Container\Container;
use Illuminate\Support\Facades\Blade;
use Illuminate\Support\Facades\Facade;
use Illuminate\Support\Facades\File;
use Mockery;
use Symfony\Component\Finder\SplFileInfo;

/**
Expand All @@ -22,30 +24,30 @@
*/
class InteractivePublishCommandHelperTest extends UnitTestCase
{
protected static bool $needsKernel = true;
use CreatesApplication;

/** @var \Illuminate\Filesystem\Filesystem&\Mockery\MockInterface */
protected $filesystem;
protected static bool $needsKernel = true;

protected $originalApp;
protected Filesystem|Mockery\MockInterface $filesystem;

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

$this->filesystem = $this->mockFilesystemStrict();

File::swap($this->filesystem);
Blade::partialMock()->shouldReceive('component');

$app = $this->setupMockApplication();

(new ViewServiceProvider($app))->boot();
}

protected function tearDown(): void
{
$this->verifyMockeryExpectations();

Container::setInstance($this->originalApp);
Container::setInstance();
Facade::clearResolvedInstances();
}

Expand Down Expand Up @@ -80,8 +82,8 @@ public function testHandle()
$this->filesystem->shouldReceive('copy')->twice();

$helper->handle([
"resources/views/vendor/hyde/layouts/app.blade.php",
"resources/views/vendor/hyde/layouts/page.blade.php",
'resources/views/vendor/hyde/layouts/app.blade.php',
'resources/views/vendor/hyde/layouts/page.blade.php',
]);

$this->filesystem->shouldHaveReceived('ensureDirectoryExists')
Expand All @@ -98,16 +100,4 @@ public function testHandle()
Hyde::path('resources/views/vendor/hyde/layouts/page.blade.php')
)->once();
}

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 8ab499e

Please sign in to comment.