Skip to content

Commit

Permalink
creating tests to validate authenticated users
Browse files Browse the repository at this point in the history
  • Loading branch information
devajmeireles committed Sep 18, 2024
1 parent 9fa1a07 commit 9fd650c
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
2 changes: 2 additions & 0 deletions phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,5 @@ parameters:
paths:
- src/
level: 5
excludePaths:
- *Test.php
31 changes: 31 additions & 0 deletions tests/Browser/EnvBar/IndexTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Tests\Browser\EnvBar;

use Illuminate\Config\Repository;
use Illuminate\Support\Facades\Gate;
use Laravel\Dusk\Browser;
use PHPUnit\Framework\Attributes\Test;
use Tests\Browser\BrowserTestCase;
Expand All @@ -20,6 +21,36 @@ public function is_visible(): void
});
}

#[Test]
public function is_visible_for_authenticated_user_only(): void
{
$this->beforeServingApplication(function ($app, Repository $config) {
$config->set('envbar.for_authenticated_users.enabled', true);

Gate::shouldReceive('allows')->withSomeOfArgs('envbar::view')->andReturnFalse();
});

$this->browse(function (Browser $browser): void {
$browser->visit('/')
->waitUntilMissingText('Environment')
->assertDontSee('Environment')
->assertDontSee('testing');
});

$this->beforeServingApplication(function ($app, Repository $config) {
$config->set('envbar.for_authenticated_users.enabled', true);

Gate::shouldReceive('allows')->withSomeOfArgs('envbar::view')->andReturnTrue();
});

$this->browse(function (Browser $browser): void {
$browser->visit('/')
->waitForText('Environment')
->assertSee('Environment')
->assertSee('testing');
});
}

#[Test]
public function warning_visible(): void
{
Expand Down

0 comments on commit 9fd650c

Please sign in to comment.