feat: Add export import

This commit is contained in:
Attila Kerekes
2022-11-26 14:35:36 +01:00
committed by Attila Kerekes
parent 2ee5d07e48
commit bb5a078f35
20 changed files with 505 additions and 21 deletions

View File

@@ -7,12 +7,14 @@ use Tests\TestCase;
class ExampleTest extends TestCase
{
use RefreshDatabase;
/**
* A basic test example.
*
* @return void
*/
public function testBasicTest()
public function test_app_loads()
{
$response = $this->get('/');

View File

@@ -0,0 +1,81 @@
<?php
namespace Tests\Feature;
use App\Item;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Support\Facades\Date;
use Tests\TestCase;
class ItemExportTest extends TestCase
{
use RefreshDatabase;
public function test_returns_empty_jsonarray_when_there_are_no_items_in_the_db()
{
$response = $this->get('api/item');
$response->assertJsonCount(0);
}
public function test_returns_exactly_the_defined_fields()
{
$exampleItem = [
"appdescription" => "Description",
"appid" => "123",
"colour" => "#000",
"description" => "Description",
"title" => "Item Title",
"url" => "http://gorczany.com/nihil-rerum-distinctio-voluptate-assumenda-accusantium-exercitationem"
];
Item::factory()
->create($exampleItem);
$response = $this->get('api/item');
$response->assertExactJson([(object)$exampleItem]);
}
public function test_returns_all_items()
{
Item::factory()
->count(3)
->create();
$response = $this->get('api/item');
$response->assertJsonCount(3);
}
public function test_does_not_return_deleted_item()
{
Item::factory()
->create([
'deleted_at' => Date::create('1970')
]);
Item::factory()
->create();
$response = $this->get('api/item');
$response->assertJsonCount(1);
}
public function test_does_not_return_tags()
{
Item::factory()
->create([
'type' => 1
]);
Item::factory()
->create();
$response = $this->get('api/item');
$response->assertJsonCount(1);
}
}

View File

@@ -12,7 +12,7 @@ class SettingsSeederTest extends TestCase
*
* @return void
*/
public function testReturnsAJSONMapWithSameAmountOfItemsAsLanguageDirectoriesPresent()
public function test_returns_a_jsonmap_with_same_amount_of_items_as_language_directories_present()
{
$languageDirectories = array_filter(glob(resource_path().'/lang/*'), 'is_dir');

View File

@@ -11,7 +11,7 @@ class LangTest extends TestCase
*
* @return void
*/
public function testAllLanguageKeysAreDefined()
public function test_all_language_keys_are_defined()
{
$this->markTestSkipped('2022-11-14 Lot of keys missing. Enable this test to see them all.');
$languageDirectories = array_filter(glob(resource_path().'/lang/*'), 'is_dir');