Skip to content

Commit

Permalink
Доработан тест проверки доступа к страницам для управления юзерами
Browse files Browse the repository at this point in the history
  • Loading branch information
simba77 committed Jun 27, 2024
1 parent 8e11c5a commit a470e40
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions tests/Feature/Users/AdminUsersTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,29 @@

use Illuminate\Foundation\Testing\RefreshDatabase;
use Modules\Users\Models\User;
use PHPUnit\Framework\Attributes\TestWith;
use Tests\TestCase;

class AdminUsersTest extends TestCase
{
use RefreshDatabase;

public function testAccessToPages(): void
#[TestWith(['admin.users.index'], 'index')]
#[TestWith(['admin.users.list-filters'], 'list-filters')]
#[TestWith(['admin.users.create', 'POST'], 'create')]
#[TestWith(['admin.users.update', 'POST'], 'update')]
#[TestWith(['admin.users.edit-user-form', 'GET', ['id' => 1]], 'edit-user-form')]
#[TestWith(['admin.users.get-form-params'], 'get-form-params')]
#[TestWith(['admin.users.delete', 'POST', ['id' => 1]], 'delete')]
public function testAccessToPages(string $routeName, string $method = 'GET', array $params = []): void
{
$response = $this->get(route('admin.users.index'));
$response->assertRedirect('/');
if ($method === 'GET') {
$response = $this->get(route($routeName, $params));
$response->assertRedirect('/');
} elseif ($method === 'POST') {
$response = $this->post(route($routeName, $params));
$response->assertRedirect('/');
}
}

public function testIndexPage(): void
Expand Down

0 comments on commit a470e40

Please sign in to comment.