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.
90 lines
2.7 KiB
90 lines
2.7 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()
|
|
{
|
|
$singleMstr1 = factory(Master::class)->create(['name' => 'Testing name', 'description' => 'Testing 123']);
|
|
$singleMstr2 = factory(Master::class)->create(['name' => 'Testing name', 'description' => 'Testing 456']);
|
|
|
|
$this->loginAsUser();
|
|
$this->visit(route('masters.index'));
|
|
$this->see($singleMstr1->name);
|
|
$this->see($singleMstr2->name);
|
|
}
|
|
|
|
/** @test */
|
|
public function user_can_create_a_master()
|
|
{
|
|
$this->loginAsUser();
|
|
$this->visit(route('masters.index'));
|
|
|
|
$this->click(trans('master.create'));
|
|
$this->seePageIs(route('masters.index', ['action' => 'create']));
|
|
|
|
$this->submitForm(trans('master.create'), [
|
|
'name' => 'Master 1 name',
|
|
'description' => 'Master 1 description',
|
|
]);
|
|
|
|
$this->seePageIs(route('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->visit(route('masters.index', ['q' => '123']));
|
|
$this->click('edit-master-'.$singleMstr->id);
|
|
$this->seePageIs(route('masters.index', ['action' => 'edit', 'id' => $singleMstr->id, 'q' => '123']));
|
|
|
|
$this->submitForm(trans('master.update'), [
|
|
'name' => 'Master 1 name',
|
|
'description' => 'Master 1 description',
|
|
]);
|
|
|
|
$this->seePageIs(route('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();
|
|
|
|
$this->visit(route('masters.index', [$singleMstr->id]));
|
|
$this->click('del-master-'.$singleMstr->id);
|
|
$this->seePageIs(route('masters.index', ['action' => 'delete', 'id' => $singleMstr->id]));
|
|
|
|
$this->seeInDatabase('masters', [
|
|
'id' => $singleMstr->id,
|
|
]);
|
|
|
|
$this->press(trans('app.delete_confirm_button'));
|
|
|
|
$this->dontSeeInDatabase('masters', [
|
|
'id' => $singleMstr->id,
|
|
]);
|
|
}
|
|
}
|