fixed #452
This commit is contained in:
@ -10,8 +10,7 @@ class ItemsTest extends FeatureTestCase
|
||||
{
|
||||
public function testItShouldBeShowTheItemsPage()
|
||||
{
|
||||
$this
|
||||
->loginAs()
|
||||
$this->loginAs()
|
||||
->get(route('items.index'))
|
||||
->assertStatus(200)
|
||||
->assertSee('Items');
|
||||
@ -19,8 +18,7 @@ class ItemsTest extends FeatureTestCase
|
||||
|
||||
public function testItShouldBeShowCreateItemPage()
|
||||
{
|
||||
$this
|
||||
->loginAs()
|
||||
$this->loginAs()
|
||||
->get(route('items.create'))
|
||||
->assertStatus(200)
|
||||
->assertSee('New Item');
|
||||
@ -28,36 +26,20 @@ class ItemsTest extends FeatureTestCase
|
||||
|
||||
public function testItShouldStoreAnItem()
|
||||
{
|
||||
$picture = UploadedFile::fake()->create('image.jpg');
|
||||
|
||||
$item = [
|
||||
'name' => $this->faker->title,
|
||||
'sku' => $this->faker->languageCode,
|
||||
'picture' => $picture,
|
||||
'description' => $this->faker->text(100),
|
||||
'purchase_price' => $this->faker->randomFloat(2,10,20),
|
||||
'sale_price' => $this->faker->randomFloat(2,10,20),
|
||||
'quantity' => $this->faker->randomNumber(2),
|
||||
'category_id' => $this->company->categories()->first()->id,
|
||||
'tax_id' => $this->company->taxes()->first()->id,
|
||||
'enabled' => $this->faker->boolean ? 1 : 0
|
||||
];
|
||||
|
||||
$this
|
||||
->loginAs()
|
||||
->post(route('items.store'), $item)
|
||||
$this->loginAs()
|
||||
->post(route('items.store'), $this->getItemRequest())
|
||||
->assertStatus(302)
|
||||
->assertRedirect(route('items.index'));
|
||||
|
||||
$this->assertFlashLevel('success');
|
||||
}
|
||||
|
||||
public function testItShouldEditItem()
|
||||
{
|
||||
$item = factory(Item::class)->create();
|
||||
$item = Item::create($this->getItemRequest());
|
||||
|
||||
$this
|
||||
->loginAs()
|
||||
->get(route('items.edit', ['item' => $item]))
|
||||
$this->loginAs()
|
||||
->get(route('items.edit', ['item' => $item->id]))
|
||||
->assertStatus(200)
|
||||
->assertSee($item->name);
|
||||
}
|
||||
@ -66,12 +48,30 @@ class ItemsTest extends FeatureTestCase
|
||||
{
|
||||
$item = factory(Item::class)->create();
|
||||
|
||||
$this
|
||||
->loginAs()
|
||||
$this->loginAs()
|
||||
->delete(route('items.destroy', ['item' => $item]))
|
||||
->assertStatus(302)
|
||||
->assertRedirect(route('items.index'));
|
||||
|
||||
$this->assertFlashLevel('success');
|
||||
}
|
||||
|
||||
private function getItemRequest()
|
||||
{
|
||||
$picture = UploadedFile::fake()->create('image.jpg');
|
||||
|
||||
return [
|
||||
'company_id' => $this->company->id,
|
||||
'name' => $this->faker->title,
|
||||
'sku' => $this->faker->languageCode,
|
||||
'picture' => $picture,
|
||||
'description' => $this->faker->text(100),
|
||||
'purchase_price' => $this->faker->randomFloat(2,10,20),
|
||||
'sale_price' => $this->faker->randomFloat(2,10,20),
|
||||
'quantity' => $this->faker->randomNumber(2),
|
||||
'category_id' => $this->company->categories()->first()->id,
|
||||
'tax_id' => $this->company->taxes()->first()->id,
|
||||
'enabled' => $this->faker->boolean ? 1 : 0
|
||||
];
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user