Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 66 additions & 1 deletion app/Http/Controllers/ItemController.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,74 @@

namespace App\Http\Controllers;

use App\Item;
use Illuminate\Http\Request;

class ItemController extends Controller
{
//
/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public function index(Request $request)
{
//
return Item::paginate($request->per_page);
}

/**
* Show the form for creating a new resource.
*
* @return \Illuminate\Http\Response
*/
public function create()
{
//
}

/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function store(Request $request)
{
//
}

/**
* Display the specified resource.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function show($id)
{
//
}

/**
* Update the specified resource in storage.
*
* @param \Illuminate\Http\Request $request
* @param int $id
* @return \Illuminate\Http\Response
*/
public function update(Request $request, $id)
{
//
}

/**
* Remove the specified resource from storage.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function destroy($id)
{
//
}
}
23 changes: 23 additions & 0 deletions database/factories/ItemFactory.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php

use Faker\Generator as Faker;

/*
|--------------------------------------------------------------------------
| Model Factories
|--------------------------------------------------------------------------
|
| This directory should contain each of the model factory definitions for
| your application. Factories provide a convenient way to generate new
| model instances for testing / seeding your application's database.
|
*/

$faker->define(\App\Item::class, function (Faker $faker) {
return [
'item_name' => $faker->sentence(2),
'value' => $faker->sentences,
'type_id' => \App\Type::query()->inRandomOrder()->first()->id,
'user_id' => 1,
];
});
9 changes: 9 additions & 0 deletions database/factories/TypeFactory.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php

Use Faker\Generator as Faker;

$faker->define(\App\Type::class, function (Faker $faker) {
return [
'type_name' => $faker->word
];
});
58 changes: 58 additions & 0 deletions tests/Feature/ItemTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
<?php

namespace Tests\Feature;

use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Foundation\Testing\WithFaker;
use Tests\TestCase;

class ItemTest extends TestCase
{
/**
* A basic feature test example.
*
* @return void
*/
public function testIndex()
{
$response = $this->get('/items');

$response->assertStatus(200);
}

/**
* A basic feature test example.
*
* @return void
*/
public function testStore()
{
$response = $this->get('/items');

$response->assertStatus(200);
}

/**
* A basic feature test example.
*
* @return void
*/
public function testUpdate()
{
$response = $this->get('/items');

$response->assertStatus(200);
}

/**
* A basic feature test example.
*
* @return void
*/
public function testDelete()
{
$response = $this->get('/items');

$response->assertStatus(200);
}
}