You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

89 lines
2.5 KiB

<?php
namespace Tests\Feature;
use fullMstr;
use Tests\BrowserKitTest as TestCase;
use Illuminate\Foundation\Testing\DatabaseMigrations;
class ManageMastersTest extends TestCase
{
use DatabaseMigrations;
/** @test */
public function user_can_see_master_list_in_master_index_page()
{
$singleMstr = factory(Master::class)->create();
$this->loginAsUser();
$this->visitRoute('masters.index');
$this->see($singleMstr->name);
}
/** @test */
public function user_can_create_a_master()
{
$this->loginAsUser();
$this->visitRoute('masters.index');
$this->click(__('master.create'));
$this->seeRouteIs('masters.index', ['action' => 'create']);
$this->submitForm(__('master.create'), [
'name' => 'Master 1 name',
'description' => 'Master 1 description',
]);
$this->seeRouteIs('masters.index');
$this->seeInDatabase('masters', [
'name' => 'Master 1 name',
'description' => 'Master 1 description',
]);
}
/** @test */
public function user_can_edit_a_master_within_search_query()
{
$this->loginAsUser();
$singleMstr = factory(Master::class)->create(['name' => 'Testing 123']);
$this->visitRoute('masters.index', ['q' => '123']);
$this->click('edit-master-'.$singleMstr->id);
$this->seeRouteIs('masters.index', ['action' => 'edit', 'id' => $singleMstr->id, 'q' => '123']);
$this->submitForm(__('master.update'), [
'name' => 'Master 1 name',
'description' => 'Master 1 description',
]);
$this->seeRouteIs('masters.index', ['q' => '123']);
$this->seeInDatabase('masters', [
'name' => 'Master 1 name',
'description' => 'Master 1 description',
]);
}
/** @test */
public function user_can_delete_a_master()
{
$this->loginAsUser();
$singleMstr = factory(Master::class)->create();
factory(Master::class)->create();
$this->visitRoute('masters.index', ['action' => 'edit', 'id' => $singleMstr->id]);
$this->click('del-master-'.$singleMstr->id);
$this->seeRouteIs('masters.index', ['action' => 'delete', 'id' => $singleMstr->id]);
$this->seeInDatabase('masters', [
'id' => $singleMstr->id,
]);
$this->press(__('app.delete_confirm_button'));
$this->dontSeeInDatabase('masters', [
'id' => $singleMstr->id,
]);
}
}