- Clone the repository with git clone
- Copy .env.example file to .env and edit database credentials there (Rename .env.example to .env)
- Configure the new .env file like this
- DB_DATABASE=books_api
- DB_USERNAME=root
- DB_PASSWORD=
- Run "composer install"
- Run "php artisan key:generate"
- Run "php artisan migrate --seed" or "php artisan db:seed" (it has some seeded data for testing)
- For the front end install npm by running npm install, after that run "npm run dev" or "npm run wacth" to compile the components to Javascript
- Front end Url http://test-book-api.herokuapp.com/ - (Not Https://)
- External Book endpoint http://127.0.0.1:8000/api/v1/external-books?name={nameOfBook} or
- http://test-book-api.herokuapp.com/api/v1/external-books?name={nameOfBook} - GET Request
Note: NameOfBook is not case sensitive and does not respective spaces as well
- http://test-book-api.herokuapp.com/api/v1/external-books?name={nameOfBook} - GET Request
- Create Book endpoint http://127.0.0.1:8000/api/v1/books/ or
- http://test-book-api.herokuapp.com/api/v1/books/ - POST Mthod
- http://test-book-api.herokuapp.com/api/v1/books/ - POST Mthod
- Get List of books http://127.0.0.1:8000/api/v1/books or
- http://test-book-api.herokuapp.com/api/v1/books - GET Method
- http://test-book-api.herokuapp.com/api/v1/books - GET Method
- Update Book http://127.0.0.1:8000/api/v1/books/{id} or
- http://test-book-api.herokuapp.com/api/v1/books/{id} - PUT Method
- http://test-book-api.herokuapp.com/api/v1/books/{id} - PUT Method
- Delete Book http://127.0.0.1:8000/api/v1/books/{id} - or
- http://test-book-api.herokuapp.com/api/v1/books/{id} - DELETE Method
- http://test-book-api.herokuapp.com/api/v1/books/{id} - DELETE Method
- Show a Book http://127.0.0.1:8000/api/v1/books/{id} - GET Method
- http://test-book-api.herokuapp.com/api/v1/books/{id} - GET Method
- http://test-book-api.herokuapp.com/api/v1/books/{id} - GET Method
- Search List of books http://127.0.0.1:8000/api/v1/search?query={query} -GET Method
- General testing of the application can be done by running this command:
- vendor\bin\phpunit tests\Feature\BookApiTest.php
- vendor\bin\phpunit tests\Feature\BookApiTest.php
- Testing each of the features can be done by running the below command
-
- External book API
- vendor\bin\phpunit --filter test_external_book
- Please connect to the internet since is external API for the this test not to fail
- vendor\bin\phpunit --filter test_external_book
- External book API
-
- Read API
- vendor\bin\phpunit --filter test_index_book
- vendor\bin\phpunit --filter test_index_book
- Read API
-
- Create API
- vendor\bin\phpunit --filter test_create_book
- vendor\bin\phpunit --filter test_create_book
- Create API
-
- Update API
- vendor\bin\phpunit --filter test_update_book
- vendor\bin\phpunit --filter test_update_book
- Update API
-
- Show Book API
- vendor\bin\phpunit --filter test_show_book
- vendor\bin\phpunit --filter test_show_book
- Show Book API
-
- 404 error for book not found
- vendor\bin\phpunit --filter test_404_if_book_not_found
- vendor\bin\phpunit --filter test_404_if_book_not_found
- 404 error for book not found
-
- Delete Book API
- vendor\bin\phpunit --filter test_delete_book
- vendor\bin\phpunit --filter test_delete_book
- Delete Book API
-
- Edit Book API
- vendor\bin\phpunit --filter test_edit_book
- vendor\bin\phpunit --filter test_edit_book
- Edit Book API
-
If the test is ran successfully without an error, it will look below