test: Add item create test (#1058)

This commit is contained in:
Attila Kerekes 2022-12-05 15:28:18 +00:00 committed by GitHub
parent 8f9b2959b2
commit 6b93f8ed5c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 78 additions and 7 deletions

View file

@ -1,7 +1,7 @@
APP_NAME=Heimdall APP_NAME=Heimdall
APP_ENV=local APP_ENV=local
APP_KEY= APP_KEY=
APP_DEBUG=false APP_DEBUG=true
APP_URL=http://localhost APP_URL=http://localhost
LOG_CHANNEL=daily LOG_CHANNEL=daily

View file

@ -18,9 +18,6 @@ class ItemCreateTest extends TestCase
$response->assertStatus(200); $response->assertStatus(200);
} }
/**
* @return void
*/
public function test_display_the_home_dashboard_tag() public function test_display_the_home_dashboard_tag()
{ {
$this->seed(); $this->seed();
@ -29,4 +26,42 @@ class ItemCreateTest extends TestCase
$response->assertSee('Home dashboard'); $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');
}
} }

View 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');
}
}

View file

@ -29,7 +29,6 @@ class ItemExportTest extends TestCase
"title" => "Item Title", "title" => "Item Title",
"url" => "http://gorczany.com/nihil-rerum-distinctio-voluptate-assumenda-accusantium-exercitationem" "url" => "http://gorczany.com/nihil-rerum-distinctio-voluptate-assumenda-accusantium-exercitationem"
]; ];
Item::factory() Item::factory()
->create($exampleItem); ->create($exampleItem);
@ -55,7 +54,6 @@ class ItemExportTest extends TestCase
->create([ ->create([
'deleted_at' => Date::create('1970') 'deleted_at' => Date::create('1970')
]); ]);
Item::factory() Item::factory()
->create(); ->create();
@ -70,7 +68,6 @@ class ItemExportTest extends TestCase
->create([ ->create([
'type' => 1 'type' => 1
]); ]);
Item::factory() Item::factory()
->create(); ->create();