Skip to content

Instantly share code, notes, and snippets.

@ferdousulhaque
Created March 11, 2018 13:31
Show Gist options
  • Save ferdousulhaque/09aea4b54d96db3db308429707d4373d to your computer and use it in GitHub Desktop.
Save ferdousulhaque/09aea4b54d96db3db308429707d4373d to your computer and use it in GitHub Desktop.
Testing Login Create Logout in Laravel
<?php
namespace Tests\Browser;
use Tests\DuskTestCase;
use Laravel\Dusk\Browser;
use Illuminate\Foundation\Testing\DatabaseMigrations;
class CSPanelTest extends DuskTestCase
{
// Test 01
// Login Check
public function testLogin()
{
$this->browse(function ($browser) {
$browser->visit('/login')
->type('email', 'client@app.com')
->type('password', 'password')
->press('Login')
->assertPathIs('/dashboard');
});
}
// Test 02
// Ticket Creation
public function testTicketCreation()
{
$this->browse(function ($browser) {
$browser->visit('/dashboard')
->clickLink('My Tickets')
->clickLink('Create New Support')
->select('category_id', 'Software Bug')
->type('title', 'Test Ticket')
->type('message', 'Test Ticket')
->select('priority', 'P1')
->press('Create Support')
->assertPathIs('/support');
});
}
// Test 03
// Logout Check
public function testLogout()
{
$this->browse(function ($browser) {
$browser->visit('/dashboard')
->clickLink('Log Out')
->assertPathIs('/');
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment