src/Templates/CRUD/Tests/Feature/AcceptanceTest.txt
<?php
use Tests\TestCase;
use Illuminate\Foundation\Testing\WithoutMiddleware;
use Illuminate\Foundation\Testing\DatabaseMigrations;
class _camel_case_AcceptanceTest extends TestCase
{
use DatabaseMigrations;
use WithoutMiddleware;
public function setUp()
{
parent::setUp();
$this->_camel_case_ = factory(_namespace_model_\_camel_case_::class)->make([
// _camel_case_ table data
]);
$this->_camel_case_Edited = factory(_namespace_model_\_camel_case_::class)->make([
// _camel_case_ table data
]);
$user = factory(_app_namespace_Models\User::class)->make();
$this->actor = $this->actingAs($user);
}
public function testIndex()
{
$response = $this->actor->call('GET', '_sectionRoutePrefix__lower_casePlural_');
$this->assertEquals(200, $response->getStatusCode());
$this->assertViewHas('_lower_casePlural_');
}
public function testCreate()
{
$response = $this->actor->call('GET', '_sectionRoutePrefix__lower_casePlural_/create');
$this->assertEquals(200, $response->getStatusCode());
}
public function testStore()
{
$response = $this->actor->call('POST', '_sectionRoutePrefix__lower_casePlural_', $this->_camel_case_->toArray());
$this->assertEquals(302, $response->getStatusCode());
$this->assertRedirectedTo('_sectionRoutePrefix__lower_casePlural_/'.$this->_camel_case_->id.'/edit');
}
public function testEdit()
{
$this->actor->call('POST', '_sectionRoutePrefix__lower_casePlural_', $this->_camel_case_->toArray());
$response = $this->actor->call('GET', '/_sectionRoutePrefix__lower_casePlural_/'.$this->_camel_case_->id.'/edit');
$this->assertEquals(200, $response->getStatusCode());
$this->assertViewHas('_lower_case_');
}
public function testUpdate()
{
$this->actor->call('POST', '_sectionRoutePrefix__lower_casePlural_', $this->_camel_case_->toArray());
$response = $this->actor->call('PATCH', '_sectionRoutePrefix__lower_casePlural_/1', $this->_camel_case_Edited->toArray());
$this->assertEquals(302, $response->getStatusCode());
$this->assertDatabaseHas('_table_name_', $this->_camel_case_Edited->toArray());
$this->assertRedirectedTo('/');
}
public function testDelete()
{
$this->actor->call('POST', '_sectionRoutePrefix__lower_casePlural_', $this->_camel_case_->toArray());
$response = $this->call('DELETE', '_sectionRoutePrefix__lower_casePlural_/'.$this->_camel_case_->id);
$this->assertEquals(302, $response->getStatusCode());
$this->assertRedirectedTo('_sectionRoutePrefix__lower_casePlural_');
}
}