Skip to content

Commit

Permalink
Merge pull request #1570 from hydephp/refactor-test-to-not-use-comple…
Browse files Browse the repository at this point in the history
…x-mocks

Refactor unit test to replace complex mock with inlined build loop
  • Loading branch information
caendesilva authored Feb 13, 2024
2 parents 7901a69 + 24452ec commit a6bcd95
Showing 1 changed file with 6 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,10 @@
namespace Hyde\Framework\Testing\Unit;

use Hyde\Facades\Filesystem;
use Hyde\Support\Models\Route;
use Hyde\Foundation\Facades\Routes;
use Hyde\Framework\Actions\StaticPageBuilder;
use Hyde\Framework\Actions\CreatesNewMarkdownPostFile;
use Hyde\Framework\Services\BuildService;
use Illuminate\Console\OutputStyle;
use Mockery;
use Symfony\Component\Console\Formatter\OutputFormatterInterface;
use Symfony\Component\Console\Helper\ProgressBar;

use function config;

Expand Down Expand Up @@ -70,30 +68,9 @@ protected function assertSee(string $page, string|array $text): void

public function testRelativeLinksAcrossPagesRetainsIntegrity()
{
$service = new BuildService(Mockery::mock(OutputStyle::class, [
'getFormatter' => Mockery::mock(OutputFormatterInterface::class, [
'hasStyle' => false,
'setStyle' => null,
]),
'createProgressBar' => new ProgressBar(Mockery::mock(OutputStyle::class, [
'isDecorated' => false,
'getVerbosity' => 0,
'write' => null,
'getFormatter' => Mockery::mock(OutputFormatterInterface::class, [
'hasStyle' => false,
'setStyle' => null,
'isDecorated' => false,
'setDecorated' => null,
'format' => null,
]),
])),
'writeln' => null,
'newLine' => null,
'write' => null,
]));

$service->transferMediaAssets();
$service->compileStaticPages();
Routes::getRoutes()->each(function (Route $route): void {
StaticPageBuilder::handle($route->getPage());
});

$this->assertSee('root', [
'<link rel="stylesheet" href="media/app.css">',
Expand Down

0 comments on commit a6bcd95

Please sign in to comment.