Browse Source

Apply fixes from StyleCI

pull/3/head
Nafies Luthfi 9 years ago
committed by StyleCI Bot
parent
commit
84cbf90573
  1. 1
      app/Cart/TransactionDraft.php
  2. 1
      app/Helpers/helpers.php
  3. 5
      app/Http/Controllers/CartController.php
  4. 6
      tests/Feature/TransactionEntryTest.php
  5. 4
      tests/Unit/Integration/TransactionDraftTest.php

1
app/Cart/TransactionDraft.php

@ -156,6 +156,7 @@ abstract class TransactionDraft
public function destroy() public function destroy()
{ {
$cart = app(CartCollection::class); $cart = app(CartCollection::class);
return $cart->removeDraft($this->draftKey); return $cart->removeDraft($this->draftKey);
} }
} }

1
app/Helpers/helpers.php

@ -29,5 +29,4 @@ function html_link_to_route($name, $title = null, $parameters = [], $attributes
} }
return app('html')->decode(link_to_route($name, $title, $parameters, $attributes)); return app('html')->decode(link_to_route($name, $title, $parameters, $attributes));
} }

5
app/Http/Controllers/CartController.php

@ -31,6 +31,7 @@ class CartController extends Controller
$draft = $this->cart->get($draftKey); $draft = $this->cart->get($draftKey);
if (is_null($draft)) { if (is_null($draft)) {
flash(trans('transaction.draft_not_found'), 'danger'); flash(trans('transaction.draft_not_found'), 'danger');
return redirect()->route('cart.index'); return redirect()->route('cart.index');
} }
@ -94,6 +95,7 @@ class CartController extends Controller
} }
$lastDraft = $this->cart->content()->last(); $lastDraft = $this->cart->content()->last();
return redirect()->route('cart.show', $lastDraft->draftKey); return redirect()->route('cart.show', $lastDraft->draftKey);
} }
@ -117,10 +119,12 @@ class CartController extends Controller
if ($draft->getItemsCount() == 0) { if ($draft->getItemsCount() == 0) {
flash(trans('transaction.item_list_empty'), 'warning')->important(); flash(trans('transaction.item_list_empty'), 'warning')->important();
return redirect()->route('cart.show', [$draftKey]); return redirect()->route('cart.show', [$draftKey]);
} }
flash(trans('transaction.confirm_instruction', ['back_link' => link_to_route('cart.show', trans('app.back'), $draftKey)]), 'warning')->important(); flash(trans('transaction.confirm_instruction', ['back_link' => link_to_route('cart.show', trans('app.back'), $draftKey)]), 'warning')->important();
return redirect()->route('cart.show', [$draftKey, 'action' => 'confirm']); return redirect()->route('cart.show', [$draftKey, 'action' => 'confirm']);
} }
@ -134,6 +138,7 @@ class CartController extends Controller
$transaction = $draft->store(); $transaction = $draft->store();
$draft->destroy(); $draft->destroy();
flash(trans('transaction.created', ['invoice_no' => $transaction->invoice_no]), 'success')->important(); flash(trans('transaction.created', ['invoice_no' => $transaction->invoice_no]), 'success')->important();
return redirect()->route('cart.index'); return redirect()->route('cart.index');
} }
} }

6
tests/Feature/TransactionEntryTest.php

@ -235,11 +235,11 @@ class TransactionEntryTest extends BrowserKitTestCase
$this->press(trans('transaction.save')); $this->press(trans('transaction.save'));
$this->seePageIs(route('cart.index')); $this->seePageIs(route('cart.index'));
$this->see(trans('transaction.created', ['invoice_no' => date('ym') . '0001']));
$this->see(trans('transaction.created', ['invoice_no' => date('ym').'0001']));
$this->seeInDatabase('transactions', [ $this->seeInDatabase('transactions', [
'invoice_no' => date('ym') . '0001',
'items' => '[{"id":' . $product1->id . ',"name":"' . $product1->name . '","price":1000,"qty":1,"item_discount":0,"item_discount_subtotal":0,"subtotal":1000},{"id":' . $product2->id . ',"name":"' . $product2->name . '","price":2000,"qty":3,"item_discount":0,"item_discount_subtotal":0,"subtotal":6000}]',
'invoice_no' => date('ym').'0001',
'items' => '[{"id":'.$product1->id.',"name":"'.$product1->name.'","price":1000,"qty":1,"item_discount":0,"item_discount_subtotal":0,"subtotal":1000},{"id":'.$product2->id.',"name":"'.$product2->name.'","price":2000,"qty":3,"item_discount":0,"item_discount_subtotal":0,"subtotal":6000}]',
'customer' => '{"name":"Nafies","phone":"081234567890"}', 'customer' => '{"name":"Nafies","phone":"081234567890"}',
'payment' => 10000, 'payment' => 10000,
'total' => 7000, 'total' => 7000,

4
tests/Unit/Integration/TransactionDraftTest.php

@ -214,8 +214,8 @@ class TransactionDraftTest extends TestCase
$draft->store(); $draft->store();
$this->assertDatabaseHas('transactions', [ $this->assertDatabaseHas('transactions', [
'invoice_no' => date('ym') . '0001',
'items' => '[{"id":' . $product1->id . ',"name":"' . $product1->name . '","price":1000,"qty":1,"item_discount":0,"item_discount_subtotal":0,"subtotal":1000},{"id":' . $product2->id . ',"name":"' . $product2->name . '","price":2000,"qty":3,"item_discount":0,"item_discount_subtotal":0,"subtotal":6000}]',
'invoice_no' => date('ym').'0001',
'items' => '[{"id":'.$product1->id.',"name":"'.$product1->name.'","price":1000,"qty":1,"item_discount":0,"item_discount_subtotal":0,"subtotal":1000},{"id":'.$product2->id.',"name":"'.$product2->name.'","price":2000,"qty":3,"item_discount":0,"item_discount_subtotal":0,"subtotal":6000}]',
'customer' => '{"name":"Nafies","phone":"081234567890"}', 'customer' => '{"name":"Nafies","phone":"081234567890"}',
'payment' => 10000, 'payment' => 10000,
'total' => 7000, 'total' => 7000,

Loading…
Cancel
Save