test: Add item create test (#1058)
This commit is contained in:
parent
8f9b2959b2
commit
6b93f8ed5c
4 changed files with 78 additions and 7 deletions
|
@ -1,7 +1,7 @@
|
|||
APP_NAME=Heimdall
|
||||
APP_ENV=local
|
||||
APP_KEY=
|
||||
APP_DEBUG=false
|
||||
APP_DEBUG=true
|
||||
APP_URL=http://localhost
|
||||
|
||||
LOG_CHANNEL=daily
|
||||
|
|
|
@ -18,9 +18,6 @@ class ItemCreateTest extends TestCase
|
|||
$response->assertStatus(200);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function test_display_the_home_dashboard_tag()
|
||||
{
|
||||
$this->seed();
|
||||
|
@ -29,4 +26,42 @@ class ItemCreateTest extends TestCase
|
|||
|
||||
$response->assertSee('Home dashboard');
|
||||
}
|
||||
|
||||
public function test_creates_a_new_item()
|
||||
{
|
||||
$this->seed();
|
||||
$item = [
|
||||
'pinned' => 1,
|
||||
'appid' => 'null',
|
||||
'website' => null,
|
||||
'title' => 'Item A',
|
||||
'colour' => '#00f',
|
||||
'url' => 'http://10.0.1.1',
|
||||
'tags' => [0],
|
||||
];
|
||||
|
||||
$response = $this->post('/items', $item);
|
||||
|
||||
$response->assertStatus(302);
|
||||
$response->assertSee('Redirecting to');
|
||||
}
|
||||
|
||||
public function test_redirects_to_dash_when_adding_a_new_item()
|
||||
{
|
||||
$this->seed();
|
||||
$item = [
|
||||
'pinned' => 1,
|
||||
'appid' => 'null',
|
||||
'website' => null,
|
||||
'title' => 'Item A',
|
||||
'colour' => '#00f',
|
||||
'url' => 'http://10.0.1.1',
|
||||
'tags' => [0],
|
||||
];
|
||||
|
||||
$response = $this->post('/items', $item);
|
||||
|
||||
$response->assertStatus(302);
|
||||
$response->assertSee('Redirecting to http://localhost');
|
||||
}
|
||||
}
|
||||
|
|
39
tests/Feature/ItemDeleteTest.php
Normal file
39
tests/Feature/ItemDeleteTest.php
Normal file
|
@ -0,0 +1,39 @@
|
|||
<?php
|
||||
|
||||
namespace Tests\Feature;
|
||||
|
||||
use App\Item;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Tests\TestCase;
|
||||
|
||||
class ItemDeleteTest extends TestCase
|
||||
{
|
||||
use RefreshDatabase;
|
||||
|
||||
public function test_deletes_an_item()
|
||||
{
|
||||
$this->seed();
|
||||
$item = Item::factory()
|
||||
->create([
|
||||
'title' => 'Item A',
|
||||
]);
|
||||
|
||||
$response = $this->post('/items/'.$item->id, ['_method' => 'DELETE']);
|
||||
|
||||
$response->assertStatus(302);
|
||||
}
|
||||
|
||||
public function test_redirects_to_item_list_page_when_deleting_an_item()
|
||||
{
|
||||
$this->seed();
|
||||
$item = Item::factory()
|
||||
->create([
|
||||
'title' => 'Item A',
|
||||
]);
|
||||
|
||||
$response = $this->post('/items/'.$item->id, ['_method' => 'DELETE']);
|
||||
|
||||
$response->assertStatus(302);
|
||||
$response->assertSee('Redirecting to http://localhost/items');
|
||||
}
|
||||
}
|
|
@ -29,7 +29,6 @@ class ItemExportTest extends TestCase
|
|||
"title" => "Item Title",
|
||||
"url" => "http://gorczany.com/nihil-rerum-distinctio-voluptate-assumenda-accusantium-exercitationem"
|
||||
];
|
||||
|
||||
Item::factory()
|
||||
->create($exampleItem);
|
||||
|
||||
|
@ -55,7 +54,6 @@ class ItemExportTest extends TestCase
|
|||
->create([
|
||||
'deleted_at' => Date::create('1970')
|
||||
]);
|
||||
|
||||
Item::factory()
|
||||
->create();
|
||||
|
||||
|
@ -70,7 +68,6 @@ class ItemExportTest extends TestCase
|
|||
->create([
|
||||
'type' => 1
|
||||
]);
|
||||
|
||||
Item::factory()
|
||||
->create();
|
||||
|
||||
|
|
Loading…
Reference in a new issue