Skip to content

Commit

Permalink
feat: stubs were added to define the structure of the tests and more …
Browse files Browse the repository at this point in the history
…environment variables were added.
  • Loading branch information
Josemprog committed Nov 2, 2020
1 parent 4faa4b1 commit 703206b
Show file tree
Hide file tree
Showing 43 changed files with 1,087 additions and 127 deletions.
2 changes: 1 addition & 1 deletion .env.testing
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=db_evertec_project_test
DB_USERNAME=root
DB_PASSWORD=
DB_PASSWORD=password

BROADCAST_DRIVER=log
CACHE_DRIVER=file
Expand Down
13 changes: 6 additions & 7 deletions app/Http/Controllers/OrderController.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ public function index(): \Illuminate\View\View

return view('orders.index')->with([
'orders' => $orders,
'user' => $user
]);
}

Expand All @@ -64,12 +63,14 @@ public function show(Order $order): \Illuminate\View\View
{

$payment = $this->p2p->getInformation($order->requestId);

if ($order->status == 'PENDING') {

$order->status = $payment['status']['status'];
$order->save();

}


return view('orders.show')
->with([
Expand Down Expand Up @@ -98,9 +99,7 @@ public function store(Request $request): \Illuminate\Http\RedirectResponse
$user = $request->user();

if (!isset($order) || $user->orders->isEmpty()) {
$order = $user->orders()->create([
'status' => 'PENDING',
]);
$order = $user->orders()->create();

$cartProductsWithQuantity = $cart
->products
Expand All @@ -114,7 +113,7 @@ public function store(Request $request): \Illuminate\Http\RedirectResponse
->attach($cartProductsWithQuantity->toArray());
}

$this->cartService->getCartFromUser()->products()->detach();
$cart->products()->detach();

$payment = $this->p2p->createRequest($order, $request);

Expand Down
6 changes: 6 additions & 0 deletions app/Order.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@

class Order extends Model
{

public const APPROVED = 'approved';
public const REJECTED = 'rejected';
public const PENDING = 'pending';
public const IN_PROCESS = 'in_process';

/**
* The attributes that are mass assignable.
*
Expand Down
12 changes: 9 additions & 3 deletions app/services/PlaceToPayService.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,21 @@

class PlaceToPayService
{

public const P2P_APPROVED = 'approved';
public const P2P_REJECTED = 'rejected';
public const P2P_PENDING = 'pending';
public const P2P_IN_PROCESS = 'in_process';

protected $endponitBase;
protected $login;
protected $secretKey;

public function __construct()
{
$this->endponitBase = env('P2P_ENDPOINT_BASE');
$this->login = env('P2P_LOGIN');
$this->secretKey = env('P2P_SECRET_KEY');
$this->endponitBase = config('services.p2p.endpoint_base');
$this->login = config('services.p2p.login');
$this->secretKey = config('services.p2p.secret_key');
}

/**
Expand Down
6 changes: 6 additions & 0 deletions config/services.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,10 @@
'region' => env('AWS_DEFAULT_REGION', 'us-east-1'),
],

'p2p' => [
'endpoint_base' => env('P2P_ENDPOINT_BASE'),
'login' => env('P2P_LOGIN'),
'secret_key' => env('P2P_SECRET_KEY')
]

];
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?php

use App\Order;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
Expand All @@ -16,7 +17,7 @@ public function up()
Schema::create('orders', function (Blueprint $table) {
$table->id();
$table->string('processUrl')->nullable();
$table->string('status')->default('pending');
$table->string('status')->default(Order::IN_PROCESS);
$table->unsignedInteger('requestId')->nullable();
$table->bigInteger('customer_id')->unsigned();
$table->timestamps();
Expand Down
16 changes: 11 additions & 5 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"laravel-mix": "^5.0.1",
"lodash": "^4.17.13",
"popper.js": "^1.12",
"prettier": "2.1.2",
"resolve-url-loader": "^2.3.1",
"sass": "^1.20.1",
"sass-loader": "^8.0.0",
Expand Down
4 changes: 4 additions & 0 deletions public/css/app.css
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,10 @@ body {
background-image: src("/img/frontend/shelving1.jpeg");
}

body {
color: black;
}

/*!
* Bootstrap v4.5.0 (https://getbootstrap.com/)
* Copyright 2011-2020 The Bootstrap Authors
Expand Down
3 changes: 3 additions & 0 deletions resources/sass/app.scss
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
// Variables
@import "variables";
@import "styles";
body {
color: black;
}

// Bootstrap
@import "~bootstrap/scss/bootstrap";
3 changes: 1 addition & 2 deletions resources/views/layouts/app.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@
<nav class="navbar navbar-expand-md navbar-light bg-dark shadow-sm fixed-top">
<div class="container">
<a class="navbar-brand text-white" href="{{ url('/') }}">
{{-- {{ config('app.name', 'Laravel') }} --}}
Evertec Project
Online shoe store
</a>
<button class="navbar-toggler" type="button" data-toggle="collapse"
data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false"
Expand Down
9 changes: 3 additions & 6 deletions resources/views/orders/index.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@
<thead>
<tr class="text-muted">
<th>requestId</th>
<th>state</th>
<th>Order id</th>
<th>User</th>
<th>created at</th>
<th>view orders</th>
</tr>
Expand All @@ -43,8 +43,8 @@
@foreach ($orders as $order)
<tr scope="row">
<td>{{$order->requestId}}</td>
<td>{{$order->state}}</td>
<td>{{$order->id}}</td>
<td>{{$user->name}}</td>
<td>{{$order->created_at}}</td>
<td>
<a href="{{ route('orders.show', $order) }}" class="btn btn-dark text-white"
Expand All @@ -56,10 +56,7 @@
</table>
@endif
</div>
{{-- Pagination --}}
{{-- <div class=" d-flex justify-content-center">{{ $products->render()}}
</div> --}}
</div>
</div>
</div>
</div>
@endsection
1 change: 1 addition & 0 deletions resources/views/orders/show.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
</tr>
</tbody>
</table>
{{-- {{ dd($order->products[0]['brand']) }} --}}
</div>
</div>
</div>
Expand Down
3 changes: 2 additions & 1 deletion resources/views/payments/pay.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@
@csrf

<div class="d-flex flex-column w-50">
<textarea name="textArea" cols="40" rows="6" required></textarea>
<textarea name="textArea" cols="40" rows="6" disabled> Agregar una descripción basada en la orden.
</textarea>
<button class="btn btn-success btn-lg mb-3 w-auto" type="submit"> Pay </button>

</div>
Expand Down
97 changes: 0 additions & 97 deletions resources/views/welcome.blade.php

This file was deleted.

5 changes: 2 additions & 3 deletions routes/web.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
use Illuminate\Support\Facades\Route;

Auth::routes(['verify' => true]);
Route::view('/', 'welcome')->name('welcome');
Route::view('/', 'home')->name('home');


Route::get('/home', 'HomeController@index')->name('home')->middleware('verified');
Expand All @@ -22,5 +22,4 @@

// Orders routes
Route::resource('orders', 'OrderController')->middleware('verified');
Route::post('orders/{order}', 'OrderController@retry')->name('orders.retry')->middleware('verified');
// Route::resource('orders.payments', 'OrderPaymentController')->only(['create', 'store']);
Route::post('orders/{order}', 'OrderController@retry')->name('orders.retry')->middleware('verified');
42 changes: 42 additions & 0 deletions stubs/console.stub
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?php

namespace {{ namespace }};

use Illuminate\Console\Command;

class {{ class }} extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = '{{ command }}';

/**
* The console command description.
*
* @var string
*/
protected $description = 'Command description';

/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}

/**
* Execute the console command.
*
* @return int
*/
public function handle()
{
//
}
}
Loading

0 comments on commit 703206b

Please sign in to comment.