Skip to content

Commit

Permalink
Extract Pest unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
caendesilva committed Apr 8, 2024
1 parent 9690071 commit 8ec51c7
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 50 deletions.
50 changes: 0 additions & 50 deletions packages/framework/tests/Feature/ConfigurableFeaturesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,31 +14,6 @@
*/
class ConfigurableFeaturesTest extends TestCase
{
public function testHasHtmlPagesReturnsFalseWhenFeatureIsNotEnabled()
{
$this->expectMethodReturnsFalse('hasHtmlPages');
}

public function testHasBladePagesReturnsFalseWhenFeatureIsNotEnabled()
{
$this->expectMethodReturnsFalse('hasBladePages');
}

public function testHasMarkdownPagesReturnsFalseWhenFeatureIsNotEnabled()
{
$this->expectMethodReturnsFalse('hasMarkdownPages');
}

public function testHasMarkdownPostsReturnsFalseWhenFeatureIsNotEnabled()
{
$this->expectMethodReturnsFalse('hasMarkdownPosts');
}

public function testHasDocumentationPagesReturnsFalseWhenFeatureIsNotEnabled()
{
$this->expectMethodReturnsFalse('hasDocumentationPages');
}

public function testHasDocumentationSearchReturnsFalseWhenFeatureIsNotEnabled()
{
$this->expectMethodReturnsFalse('hasDocumentationSearch');
Expand All @@ -59,31 +34,6 @@ public function testHasRssReturnsFalseWhenFeatureIsNotEnabled()
$this->expectMethodReturnsFalse('hasRss');
}

public function testHasHtmlPagesReturnsTrueWhenFeatureIsEnabled()
{
$this->expectMethodReturnsTrue('hasHtmlPages');
}

public function testHasBladePagesReturnsTrueWhenFeatureIsEnabled()
{
$this->expectMethodReturnsTrue('hasBladePages');
}

public function testHasMarkdownPagesReturnsTrueWhenFeatureIsEnabled()
{
$this->expectMethodReturnsTrue('hasMarkdownPages');
}

public function testHasMarkdownPostsReturnsTrueWhenFeatureIsEnabled()
{
$this->expectMethodReturnsTrue('hasMarkdownPosts');
}

public function testHasDocumentationPagesReturnsTrueWhenFeatureIsEnabled()
{
$this->expectMethodReturnsTrue('hasDocumentationPages');
}

public function testHasDarkmodeReturnsTrueWhenFeatureIsEnabled()
{
$this->expectMethodReturnsTrue('hasDarkmode');
Expand Down
37 changes: 37 additions & 0 deletions packages/framework/tests/Unit/ConfigurableFeaturesUnitTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?php

declare(strict_types=1);

use Hyde\Facades\Features;
use Illuminate\Support\Facades\Config;

beforeEach(function () {
$this->mockConfig();
$this->needsKernel();
});

test('expect has method returns false when feature is disabled', function (string $method) {
Config::set('hyde.features', []);

$this->assertFalse(Features::$method(), "Method '$method' should return false when feature is not enabled");
})->with([
'hasHtmlPages',
'hasBladePages',
'hasMarkdownPages',
'hasMarkdownPosts',
'hasDocumentationPages',
])->covers(Hyde\Facades\Features::class);


test('expect has method returns true when feature is enabled', function (string $method) {
Config::set('hyde.features', [str($method)->kebab()->replace('has-', '')->toString()]);
\Hyde\Foundation\HydeKernel::setInstance(new \Hyde\Foundation\HydeKernel());

$this->assertTrue(Features::$method(), "Method '$method' should return true when feature is enabled");
})->with([
'hasHtmlPages',
'hasBladePages',
'hasMarkdownPages',
'hasMarkdownPosts',
'hasDocumentationPages',
])->covers(Hyde\Facades\Features::class);

0 comments on commit 8ec51c7

Please sign in to comment.