2021-06-15 12:19:14 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Tests\Feature;
|
|
|
|
|
|
|
|
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
|
|
|
use Illuminate\Support\Facades\Auth;
|
|
|
|
use Tests\TestCase;
|
|
|
|
|
|
|
|
use App\Models\User;
|
|
|
|
use App\Models\Domain;
|
|
|
|
|
|
|
|
class SiteAdminTest extends TestCase
|
|
|
|
{
|
|
|
|
use DatabaseTransactions;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Testing a unauthenticated visitor to the site.
|
|
|
|
*/
|
|
|
|
public function test_guestuser()
|
|
|
|
{
|
|
|
|
$this->get('about')
|
|
|
|
->assertOk();
|
|
|
|
|
2023-10-05 11:42:41 +00:00
|
|
|
$this->get('domain')
|
2021-06-15 12:19:14 +00:00
|
|
|
->assertRedirect('login');
|
2023-10-05 11:27:25 +00:00
|
|
|
$this->get('zone')
|
2021-06-15 12:19:14 +00:00
|
|
|
->assertRedirect('login');
|
|
|
|
|
2021-07-15 14:54:23 +00:00
|
|
|
$this->get('network/999')
|
2021-06-15 12:19:14 +00:00
|
|
|
->assertNotFound();
|
|
|
|
|
|
|
|
Domain::factory()->create([
|
2021-07-15 14:54:23 +00:00
|
|
|
'id'=>999,
|
2021-06-15 12:19:14 +00:00
|
|
|
'name'=>'test',
|
2021-08-19 13:42:39 +00:00
|
|
|
'public'=>TRUE,
|
2021-06-15 12:19:14 +00:00
|
|
|
]);
|
|
|
|
|
2021-07-15 14:54:23 +00:00
|
|
|
$this->get('network/999')
|
2021-06-15 12:19:14 +00:00
|
|
|
->assertOK();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Verify user who has registered by not verified their email
|
|
|
|
*/
|
|
|
|
public function test_unverified_user()
|
|
|
|
{
|
|
|
|
$user = User::factory()->make([
|
|
|
|
'name'=>'Site Visitor',
|
|
|
|
'email_verified_at'=>NULL,
|
|
|
|
]);
|
|
|
|
|
|
|
|
// Use model in tests...
|
|
|
|
$this->actingAs($user);
|
|
|
|
|
2023-10-05 11:42:41 +00:00
|
|
|
$this->get('domain')
|
2021-06-15 12:19:14 +00:00
|
|
|
->assertRedirect('email/verify');
|
2023-10-05 11:27:25 +00:00
|
|
|
$this->get('zone')
|
2021-06-15 12:19:14 +00:00
|
|
|
->assertRedirect('email/verify');
|
|
|
|
|
|
|
|
Auth::logout();
|
|
|
|
}
|
|
|
|
|
|
|
|
public function test_site_admin()
|
|
|
|
{
|
|
|
|
// Site Visitor
|
|
|
|
$this->get('setup')
|
|
|
|
->assertRedirect('login');
|
|
|
|
|
|
|
|
// Valid User
|
|
|
|
$user = User::factory()->make([
|
|
|
|
'name'=>'Site User',
|
|
|
|
]);
|
|
|
|
$this->actingAs($user);
|
|
|
|
|
|
|
|
$this->get('setup')
|
|
|
|
->assertForbidden();
|
|
|
|
|
|
|
|
// Admin User
|
|
|
|
$user = User::factory()->admin()->make([
|
|
|
|
'name'=>'Site User',
|
|
|
|
]);
|
|
|
|
$this->actingAs($user);
|
|
|
|
|
|
|
|
$this->get('setup')
|
|
|
|
->assertOK();
|
|
|
|
}
|
|
|
|
}
|