Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
timacdonald committed Sep 10, 2024
1 parent d556b8a commit 86a26d9
Showing 1 changed file with 14 additions and 11 deletions.
25 changes: 14 additions & 11 deletions tests/Feature/DatabaseDriverTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1637,7 +1637,7 @@ public function testCanRetrieveSpecificFeaturesForDifferingScopeTypes(): void
$this->assertCount(4, DB::table('features')->get());
}

public function testCanCheckSomeAreActiveForScopeIncorrectScopeType(): void
public function testCanCheckSomeAreActiveForIncorrectScopeType(): void
{
Feature::define('team', fn (Team $team) => true);
Feature::define('user', fn (User $user) => false);
Expand All @@ -1650,7 +1650,7 @@ public function testCanCheckSomeAreActiveForScopeIncorrectScopeType(): void
$this->assertCount(2, DB::table('features')->get());
}

public function testCanCheckAllAreActiveForScopeIncorrectScopeType(): void
public function testCanCheckAllAreActiveForIncorrectScopeType(): void
{
Feature::define('team', fn (Team $team) => true);
Feature::define('user', fn (User $user) => true);
Expand All @@ -1663,7 +1663,7 @@ public function testCanCheckAllAreActiveForScopeIncorrectScopeType(): void
$this->assertCount(2, DB::table('features')->get());
}

public function testCanCheckSomeAreActiveForScopeIncorrectScopeTypeAndReturnsFalse(): void
public function testCanCheckSomeAreActiveForIncorrectScopeTypeAndReturnsFalse(): void
{
Feature::define('team', fn (Team $team) => true);
Feature::define('user', fn (User $user) => true);
Expand All @@ -1682,18 +1682,21 @@ public function testCanCheckSomeAreActiveForScopeIncorrectScopeTypeAndReturnsFal
$this->assertCount(1, DB::table('features')->get());
}

public function test_featuresNotBelongingToScope_allAreInactive_treatsScopesAsFalse(): void
public function testCanCheckAllAreInactiveForIncorrectScopeTypeAndReturnsTrue(): void
{
// Given features with varying scopes
Feature::define('for-teams', fn (Team $team) => true);
Feature::define('for-user', fn (User $user) => false);
Feature::define('for-null-scope', fn () => false);
Feature::define('team', fn (Team $team) => true);
Feature::define('user', fn (User $user) => false);
Feature::define('none', fn () => false);

// When
$result = Feature::for(new User)->allAreInactive(['for-teams', 'for-user', 'for-null-scope']);
$result = Feature::for(new User)->allAreInactive([
'team',
'user',
'none',
]);

// Then
$this->assertTrue($result);
$this->assertCount(2, DB::getQueryLog());
$this->assertCount(1, DB::table('features')->get());
}

public function test_featuresNotBelongingToScope_eagerLoaded_returnsFalseThatScopeIsActive(): void
Expand Down

0 comments on commit 86a26d9

Please sign in to comment.