Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Natue Challenge Pull Request - Murilo Contreira #2

Open
wants to merge 55 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
633dac9
First Commit
mca-digital Dec 20, 2017
6a02efb
ajustes e correçoes, model e view
mca-digital Dec 21, 2017
60a704e
button color blue
mca-digital Dec 21, 2017
0567243
Info orientations to run the test
mca-digital Dec 21, 2017
3280ab4
Models folder created, comments cleared, README updated
mca-digital Dec 21, 2017
56e7628
README updated
mca-digital Dec 21, 2017
398eb00
README updated
mca-digital Dec 21, 2017
9037758
README updated
mca-digital Dec 21, 2017
bba5414
README updated
mca-digital Dec 21, 2017
2fdd59a
README updated
mca-digital Dec 21, 2017
e9c01fb
README updated
mca-digital Dec 21, 2017
cd0599d
README updated
mca-digital Dec 21, 2017
62b71b3
README updated
mca-digital Dec 21, 2017
921bb6b
README updated
mca-digital Dec 21, 2017
0aae528
README updated
mca-digital Dec 21, 2017
27f171d
README updated
mca-digital Dec 21, 2017
b841078
README updated
mca-digital Dec 21, 2017
d6a18fb
README updated
mca-digital Dec 21, 2017
f0df85e
README updated
mca-digital Dec 21, 2017
368849d
README updated
mca-digital Dec 21, 2017
2c9c115
README updated
mca-digital Dec 21, 2017
85d4951
README updated
mca-digital Dec 21, 2017
a141d08
README updated
mca-digital Dec 21, 2017
28aef0a
README updated
mca-digital Dec 21, 2017
ffdabb4
README updated
mca-digital Dec 21, 2017
2bbf72b
README updated
mca-digital Dec 21, 2017
84b8bd5
README updated
mca-digital Dec 21, 2017
0c55a50
README updated
mca-digital Dec 21, 2017
d22f939
README updated
mca-digital Dec 21, 2017
3d3f78f
README updated
mca-digital Dec 21, 2017
bf4d231
README updated
mca-digital Dec 21, 2017
d265e15
README updated
mca-digital Dec 21, 2017
a3f2e67
README updated
mca-digital Dec 21, 2017
d0101f4
README updated
mca-digital Dec 21, 2017
baacafb
Tests inited, TestExamples deleted, README updated
mca-digital Dec 22, 2017
61b5091
README updated
mca-digital Dec 22, 2017
893886c
README updated
mca-digital Dec 22, 2017
45fe909
Tests Assert JSON
mca-digital Dec 22, 2017
95d6be2
README updated
mca-digital Dec 22, 2017
ce5f2a6
README updated
mca-digital Dec 22, 2017
4addcec
comments removed
mca-digital Dec 22, 2017
7524a86
Browser Tests
mca-digital Dec 22, 2017
b9e533d
README updated
mca-digital Dec 22, 2017
63909a0
ids adicionados
mca-digital Dec 22, 2017
2b230e2
enable browser open to execution
mca-digital Dec 22, 2017
20a7196
Browser tests add
mca-digital Dec 22, 2017
d8941a0
README updated
mca-digital Dec 22, 2017
bb38cf0
Browser tests
mca-digital Dec 23, 2017
961626f
README updated
mca-digital Dec 23, 2017
c257565
README updated
mca-digital Dec 23, 2017
f4ed9f5
README updated
mca-digital Dec 23, 2017
9554535
README updated
mca-digital Dec 23, 2017
1f8eddc
README updated
mca-digital Dec 23, 2017
366d127
README updated
mca-digital Dec 23, 2017
f1cf22e
README updated
mca-digital Dec 23, 2017
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
34 changes: 34 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
APP_NAME=Laravel
APP_ENV=local
APP_KEY=
APP_DEBUG=true
APP_LOG_LEVEL=debug
APP_URL=http://localhost

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=homestead
DB_USERNAME=homestead
DB_PASSWORD=secret

BROADCAST_DRIVER=log
CACHE_DRIVER=file
SESSION_DRIVER=file
SESSION_LIFETIME=120
QUEUE_DRIVER=sync

REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379

MAIL_DRIVER=smtp
MAIL_HOST=smtp.mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null

PUSHER_APP_ID=
PUSHER_APP_KEY=
PUSHER_APP_SECRET=
5 changes: 5 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
* text=auto
*.css linguist-vendored
*.scss linguist-vendored
*.js linguist-vendored
CHANGELOG.md export-ignore
12 changes: 12 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/node_modules
/public/hot
/public/storage
/storage/*.key
/vendor
/.idea
/.vagrant
Homestead.json
Homestead.yaml
npm-debug.log
yarn-error.log
.env
176 changes: 174 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,188 @@ Based on this you will need to develop:
- it must be possible to order the result by price (asc and desc);

The test should be done in PHP. We expect at the end of the test, outside the API running, the following items:

- an explanation of what is needed to make your project work;
- an explanation of how to perform the tests;

Remember that at the time of the evaluation we will look at:

- Code organization;
- Object-Oriented Principles;
- Maintenance;

To send us your code, you must:

Make a fork of this repository, and send us a pull-request.
## #
## Natue Challenge
## This test was develop with Windows 7, Apache, Laravel Framework 5.5, MySql, AJAX, jQuery, Javascript and Bootstrap.
- API Server was made with Laravel;
- The .json data is provided by Laravel brought from the MySql database.
- API Client was made with AJAX,jQuery and Bootstrap.
- Tests was applied with PHPUnit and Laravel Dusk.

## Project Structure
/database/migrations/ to create the database structure;
create_products_table.php
create_specifications_table.php
create_products_specifications_table.php

/database/seeds/ to populate the database:
DatabaseSeeder.php
ProductsSpecificationsTableSeeder.php
ProductsTableSeeder.php
SpecificationsTableSeeder.php

/routes to define requests:
api.php
web.php

/app/Http/Controllers
CatalogController.php
Specifications.php
Products.php

/app/Models
Product.php
Specification.php
ProductSpecification.php

/resources/views
catalog.blade.php

/public
/css/catalog.css
/js/catalog.js

/tests/
/Browser/
CatalogTest.php
/Feature/
ProductTest.php
SpecificationTest.php


## Softwares dependencies:
#1. Install Composer to download the libs dependencies:

https://getcomposer.org/download/

#3. Install Xampp Stack to run a local server:

https://www.apachefriends.org/pt_br/download.html

#3. Install Cmder or use Cmd to run commands in terminal on Windows:

http://cmder.net/

## Follow the above steps to make the test work:

- Clone the project to your machine:

git clone https://github.com/mca-digital/challenge.git local.natuechallenge

- Access the project root folder:

cd local.natuechallenge

- Run command on Cmder or Cmd to install dependencies:

composer install

- Create a Database named:

natuechallenge

- Run command on Cmder or Cmd to make a copy of .env.exemple to .env:

cp .env.example .env

- Edit .env file to connect the database:

APP_URL=http://127.0.0.1:8000
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=natuechallenge
DB_USERNAME=root
DB_PASSWORD=

- Run command on Cmder or Cmd to create encryption key:

php artisan key:generate

- Run command on Cmder or Cmd to create database tables and seeds:

php artisan migrate --seed

- To refresh database structure if needed:

php artisan migrate:refresh --seed

- Run command on Cmder or Cmd to run the project:

php artisan serve

- Access the project on browser:

http://127.0.0.1:8000/catalog

## An explanation of how to perform the tests;

- Above we have some tests that will be executed:

HTTP Tests wit PHPunit
- API_HTTPStatus_Specification;
- API_HTTPStatus_ProductList;
- API_HTTPStatus_ProductListWithFilter;
- API_AssertJSON_Specification;
- API_AssertJSON_Product;
- API_AssertJSON_ProductWithFilter;

Browser Tests with Laravel Dusk
- CatalogTest
- VerifyProductListAndFilter

- Open another Cmder or Cmd instance to run the HTTP tests without stop the previous service in http://127.0.0.1:8000/catalog:

phpunit --debug

- The final of execution tests you must have:

PHPUnit 5.7.0 by Sebastian Bergmann and contributors.


Starting test 'Tests\Feature\ProductTest::API_HTTPStatus_ProductList'.
.
Starting test 'Tests\Feature\ProductTest::API_HTTPStatus_ProductListWithFilter'.
.
Starting test 'Tests\Feature\ProductTest::API_AssertJSON_Product'.
.
Starting test 'Tests\Feature\ProductTest::API_AssertJSON_ProductWithFilter'.
.
Starting test 'Tests\Feature\SpecificationTest::API_HTTPStatus_Specification'.
.
Starting test 'Tests\Feature\SpecificationTest::API_AssertJSON_Specification'.
. 6 / 6 (100%)

Time: 311 ms, Memory: 12.00MB

OK (6 tests, 6 assertions)

- Run command on Cmder or Cmd to run the Browser automated tests:

php artisan dusk --debug

- The final of execution tests you must have:

Warning: TTY mode is not supported on Windows platform.
PHPUnit 5.7.0 by Sebastian Bergmann and contributors.


Starting test 'Tests\Browser\CatalogTest::VerifyProductListItensFilter'.

DevTools listening on ws://127.0.0.1:12018/devtools/browser/4ff9da70-68dd-4c8c-a9fb-3e427d1552c3
. 1 / 1 (100%)

Time: 38.82 seconds, Memory: 10.00MB

OK (1 test, 5 assertions)
42 changes: 42 additions & 0 deletions app/Console/Kernel.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?php

namespace App\Console;

use Illuminate\Console\Scheduling\Schedule;
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;

class Kernel extends ConsoleKernel
{
/**
* The Artisan commands provided by your application.
*
* @var array
*/
protected $commands = [
//
];

/**
* Define the application's command schedule.
*
* @param \Illuminate\Console\Scheduling\Schedule $schedule
* @return void
*/
protected function schedule(Schedule $schedule)
{
// $schedule->command('inspire')
// ->hourly();
}

/**
* Register the commands for the application.
*
* @return void
*/
protected function commands()
{
$this->load(__DIR__.'/Commands');

require base_path('routes/console.php');
}
}
53 changes: 53 additions & 0 deletions app/Exceptions/Handler.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<?php

namespace App\Exceptions;

use Exception;
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;

class Handler extends ExceptionHandler
{
/**
* A list of the exception types that are not reported.
*
* @var array
*/
protected $dontReport = [
//
];

/**
* A list of the inputs that are never flashed for validation exceptions.
*
* @var array
*/
protected $dontFlash = [
'password',
'password_confirmation',
];

/**
* Report or log an exception.
*
* This is a great spot to send exceptions to Sentry, Bugsnag, etc.
*
* @param \Exception $exception
* @return void
*/
public function report(Exception $exception)
{
parent::report($exception);
}

/**
* Render an exception into an HTTP response.
*
* @param \Illuminate\Http\Request $request
* @param \Exception $exception
* @return \Illuminate\Http\Response
*/
public function render($request, Exception $exception)
{
return parent::render($request, $exception);
}
}
32 changes: 32 additions & 0 deletions app/Http/Controllers/Auth/ForgotPasswordController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php

namespace App\Http\Controllers\Auth;

use App\Http\Controllers\Controller;
use Illuminate\Foundation\Auth\SendsPasswordResetEmails;

class ForgotPasswordController extends Controller
{
/*
|--------------------------------------------------------------------------
| Password Reset Controller
|--------------------------------------------------------------------------
|
| This controller is responsible for handling password reset emails and
| includes a trait which assists in sending these notifications from
| your application to your users. Feel free to explore this trait.
|
*/

use SendsPasswordResetEmails;

/**
* Create a new controller instance.
*
* @return void
*/
public function __construct()
{
$this->middleware('guest');
}
}
Loading