Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
Took 12 minutes
  • Loading branch information
fabio-ivona committed Apr 24, 2024
1 parent f7db302 commit 8d6b897
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 22 deletions.
40 changes: 20 additions & 20 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.2/phpunit.xsd" backupGlobals="false" bootstrap="vendor/autoload.php" colors="true" processIsolation="false" stopOnFailure="false" executionOrder="random" failOnWarning="true" failOnRisky="true" failOnEmptyTestSuite="true" beStrictAboutOutputDuringTests="true" cacheDirectory=".phpunit.cache" backupStaticProperties="false">
<testsuites>
<testsuite name="DefStudio Test Suite">
<directory>tests</directory>
</testsuite>
</testsuites>
<coverage>
<report>
<html outputDirectory="build/coverage"/>
<text outputFile="build/coverage.txt"/>
<clover outputFile="build/logs/clover.xml"/>
</report>
</coverage>
<logging>
<junit outputFile="build/report.junit.xml"/>
</logging>
<source>
<include>
<directory suffix=".php">./src</directory>
</include>
</source>
<testsuites>
<testsuite name="DefStudio Test Suite">
<directory>tests</directory>
</testsuite>
</testsuites>
<coverage>
<report>
<html outputDirectory="build/coverage"/>
<text outputFile="build/coverage.txt"/>
<clover outputFile="build/logs/clover.xml"/>
</report>
</coverage>
<logging>
<junit outputFile="build/report.junit.xml"/>
</logging>
<source>
<include>
<directory suffix=".php">./src</directory>
</include>
</source>
</phpunit>
20 changes: 20 additions & 0 deletions tests/Fixtures/Feature.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php

namespace DefStudio\EnumFeatures\Tests\Fixtures;

use DefStudio\EnumFeatures\Concerns\DefinesFeatures;
use Illuminate\Contracts\Auth\Authenticatable;

enum Feature
{
use DefinesFeatures;

case feature_1;
case feature_2;
case feature_3;

protected function resolve(?Authenticatable $scope = null): bool
{
return $scope->name === 'enabled_user';
}
}
3 changes: 2 additions & 1 deletion tests/Pest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@

use DefStudio\EnumFeatures\Tests\TestCase;

uses(TestCase::class)->in(__DIR__);
uses(TestCase::class)
->in(__DIR__);
7 changes: 7 additions & 0 deletions tests/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,11 @@ protected function getPackageProviders($app): array
PennantServiceProvider::class,
];
}

protected function getEnvironmentSetUp($app): void
{
config()->set('pennant.default', 'array');
}


}
10 changes: 9 additions & 1 deletion tests/Unit/DefinesFeaturesTest.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
<?php

use DefStudio\EnumFeatures\Tests\Fixtures\Feature;
use Workbench\App\Models\User;

test('defines_feature', function () {
expect(true)->toBeTrue();
$enabled = new User([
'id' => 1,
'name' => 'enabled_user',
]);

expect(Feature::feature_1->enabled($enabled))->toBeTrue();
});

0 comments on commit 8d6b897

Please sign in to comment.