This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
use App\Models\Book; | |
const API_ENDPOINT = '/api/books'; | |
uses()->group('books'); // Assign 'books' group to all tests (whole file) | |
beforeEach(function () { | |
$this->mockBooksCollection = Book::factory(5)->create(); // Generate mock database entries for testing |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
use App\Models\Book; | |
use App\Repositories\BookRepository; | |
beforeEach(function () { | |
$this->mockParameters = ['author' => 'Max Minimal']; | |
$this->mockBooksCollection = Book::factory(5)->create($this->mockParameters); | |
$this->bookRepository = new BookRepository(); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
uses( | |
Tests\TestCase::class, | |
Illuminate\Foundation\Testing\RefreshDatabase::class, | |
)->in('Unit', 'Feature'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
use App\Http\Controllers\GetBookByIsbnController; | |
use App\Http\Controllers\GetBooksController; | |
use Illuminate\Support\Facades\Route; | |
Route::get('/books', GetBooksController::class); | |
Route::get('/books/{isbn}', GetBookByIsbnController::class)->where('isbn', '[0-9]{10,13}'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace App\Http\Controllers; | |
use App\Repositories\BookRepository; | |
use Illuminate\Http\Request; | |
use Symfony\Component\HttpFoundation\JsonResponse; | |
class GetBookByIsbnController extends Controller | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace App\Http\Controllers; | |
use App\Repositories\BookRepository; | |
use Illuminate\Http\Request; | |
use Symfony\Component\HttpFoundation\JsonResponse; | |
class GetBooksController extends Controller | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
declare(strict_types=1); | |
namespace App\Repositories; | |
use App\Models\Book; | |
use Illuminate\Database\Eloquent\Builder; | |
use Illuminate\Database\Eloquent\Collection; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace Database\Factories; | |
use App\Models\Book; | |
use Illuminate\Database\Eloquent\Factories\Factory; | |
/** | |
* @extends Factory<Book> | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace App\Models; | |
use DateTimeInterface; | |
use Illuminate\Database\Eloquent\Factories\HasFactory; | |
use Illuminate\Database\Eloquent\Model; | |
/** | |
* App\Models\Book |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
use Illuminate\Database\Migrations\Migration; | |
use Illuminate\Database\Schema\Blueprint; | |
use Illuminate\Support\Facades\Schema; | |
return new class extends Migration { | |
/** | |
* Run the migrations. | |
*/ |
NewerOlder