Create CI testing

This commit is contained in:
Deon George
2021-06-15 22:19:14 +10:00
parent 4011b2a82d
commit 292040cef7
14 changed files with 356 additions and 44 deletions

View File

@@ -14,7 +14,7 @@ class ExampleTest extends TestCase
*/
public function testBasicTest()
{
$response = $this->get('/');
$response = $this->get('/about');
$response->assertStatus(200);
}

View File

@@ -0,0 +1,90 @@
<?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();
$this->get('ftn/domain')
->assertRedirect('login');
$this->get('ftn/node')
->assertRedirect('login');
$this->get('ftn/zone')
->assertRedirect('login');
$this->get('network/1')
->assertNotFound();
Domain::factory()->create([
'id'=>1,
'name'=>'test',
]);
$this->get('network/1')
->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);
$this->get('ftn/domain')
->assertRedirect('email/verify');
$this->get('ftn/node')
->assertRedirect('email/verify');
$this->get('ftn/zone')
->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();
}
}