/pgphptest

Pictureworks Laravel Coding Test

Primary LanguagePHP

Pictureworks Laravel Coding Test


Build Status Total Downloads License

Introduction

Pictureworks Laravel Coding Test: Migration of non-oo legacy application into the Laravel/Eloquent framework.

Table of Contents

  1. Requirements
  2. Features
  3. Installation
  4. Usage
  5. Testing

Requirements

Make sure your server meets the following requirements.

  • PostgreSQL server
  • Composer installed 1.9+
  • PHP Version 7.4.x+

Features:

  • Show user detail
  • Update existing comments field of user with identifier id provided
  • A command line executions to update comments of specific user such as php controller.php ID COMMENTS where ID is user identifier and COMMENTS is some amount of comments, potentially with spaces.

Installation

Install composer with the help of the instructions given here

$ wget https://getcomposer.org/composer.phar
$ chmod +x composer.phar
$ mv composer.phar /usr/local/bin/composer

Fork and/or clone this project by running the following command

 git clone  https://github.com/umagloire99/pgphptest.git

Navigate into the project's directory

 cd pgphptest 

Copy .env.example for .env and modify according to your credentials

 cp .env.example .env

Run this command to install dependencies

 composer insatall --prefer-dist

This command will install all dependencies needed by the Pictureworks Laravel Coding Test to run successfully!

Generate application key

 php artisan key:generate

This command will help migrate the database and populate the database!

 php artisan migrate --seed

Usage

Specify your static user password in your .env that would be used to identify you

STATIC_USER_PASSWORD=''

Run the default laravel server

php artisan serve

Show User detail

  • Request: GET
  • Url http://localhost:8000/user/{id} where id is the unique user identifier

Update existing comments field of user

  • Request POST
  • Url http://localhost:8000/user/update-comments
  • Parameters: id(unique user identifier type integer), comments(type string) and password(type string)

By default, we have created 10 fake user data.

Testing

Run this command to test the different endpoints

vendor/bin/phpunit tests/UserControllerTests.php