Browse Source

Apply fixes from StyleCI

pull/1/head
Nafies Luthfi 9 years ago
committed by StyleCI Bot
parent
commit
75a73dfe02
  1. 10
      app/Cart/CartCollection.php
  2. 2
      app/Cart/CashDraft.php
  3. 2
      app/Cart/CreditDraft.php
  4. 2
      app/Cart/Item.php
  5. 9
      app/Cart/TransactionDraft.php
  6. 1
      app/Console/Kernel.php
  7. 3
      app/Exceptions/Handler.php
  8. 6
      app/Http/Controllers/Auth/RegisterController.php
  9. 16
      app/Http/Controllers/CartController.php
  10. 4
      app/Http/Controllers/Controller.php
  11. 2
      app/Http/Controllers/HomeController.php
  12. 1
      app/Http/Middleware/RedirectIfAuthenticated.php
  13. 3
      app/Product.php
  14. 1
      app/Providers/AuthServiceProvider.php
  15. 2
      app/Providers/BroadcastServiceProvider.php
  16. 2
      app/Providers/EventServiceProvider.php
  17. 2
      app/Providers/RouteServiceProvider.php
  18. 2
      app/User.php
  19. 4
      database/factories/ModelFactory.php
  20. 4
      database/migrations/2014_10_12_000000_create_users_table.php
  21. 4
      database/migrations/2017_04_09_013901_create_products_table.php
  22. 3
      public/index.php
  23. 4
      server.php
  24. 32
      tests/Feature/Cart/CartControllerTest.php
  25. 12
      tests/Feature/TransactionEntryTest.php
  26. 53
      tests/Unit/CartCollectionTest.php
  27. 2
      tests/Unit/Integration/ProductTest.php

10
app/Cart/CartCollection.php

@ -2,11 +2,10 @@
namespace App\Cart; namespace App\Cart;
use App\Product;
use Illuminate\Support\Collection; use Illuminate\Support\Collection;
/** /**
* Cart Collection Class
* Cart Collection Class.
*/ */
class CartCollection class CartCollection
{ {
@ -47,10 +46,9 @@ class CartCollection
public function get($draftKey) public function get($draftKey)
{ {
$content = $this->getContent(); $content = $this->getContent();
if (isset($content[$draftKey]))
if (isset($content[$draftKey])) {
return $content[$draftKey]; return $content[$draftKey];
return null;
}
} }
public function updateDraftAttributes($draftKey, $draftAttributes) public function updateDraftAttributes($draftKey, $draftAttributes)
@ -112,6 +110,7 @@ class CartCollection
$content[$draftKey]->addItem($item); $content[$draftKey]->addItem($item);
$this->session->put($this->instance, $content); $this->session->put($this->instance, $content);
return $item->product; return $item->product;
} }
@ -145,5 +144,4 @@ class CartCollection
{ {
return !$this->isEmpty(); return !$this->isEmpty();
} }
} }

2
app/Cart/CashDraft.php

@ -3,7 +3,7 @@
namespace App\Cart; namespace App\Cart;
/** /**
* Cash Draft
* Cash Draft.
*/ */
class CashDraft extends TransactionDraft class CashDraft extends TransactionDraft
{ {

2
app/Cart/CreditDraft.php

@ -3,7 +3,7 @@
namespace App\Cart; namespace App\Cart;
/** /**
* Credit Draft
* Credit Draft.
*/ */
class CreditDraft extends TransactionDraft class CreditDraft extends TransactionDraft
{ {

2
app/Cart/Item.php

@ -5,7 +5,7 @@ namespace App\Cart;
use App\Product; use App\Product;
/** /**
* Draft Item class
* Draft Item class.
*/ */
class Item class Item
{ {

9
app/Cart/TransactionDraft.php

@ -2,10 +2,8 @@
namespace App\Cart; namespace App\Cart;
use App\Product;
/** /**
* Transaction Draft Interface
* Transaction Draft Interface.
*/ */
abstract class TransactionDraft abstract class TransactionDraft
{ {
@ -65,8 +63,9 @@ abstract class TransactionDraft
public function updateItem($itemKey, $newItemData) public function updateItem($itemKey, $newItemData)
{ {
if (!isset($this->items[$itemKey]))
return null;
if (!isset($this->items[$itemKey])) {
return;
}
$item = $this->items[$itemKey]; $item = $this->items[$itemKey];

1
app/Console/Kernel.php

@ -20,6 +20,7 @@ class Kernel extends ConsoleKernel
* Define the application's command schedule. * Define the application's command schedule.
* *
* @param \Illuminate\Console\Scheduling\Schedule $schedule * @param \Illuminate\Console\Scheduling\Schedule $schedule
*
* @return void * @return void
*/ */
protected function schedule(Schedule $schedule) protected function schedule(Schedule $schedule)

3
app/Exceptions/Handler.php

@ -28,6 +28,7 @@ class Handler extends ExceptionHandler
* This is a great spot to send exceptions to Sentry, Bugsnag, etc. * This is a great spot to send exceptions to Sentry, Bugsnag, etc.
* *
* @param \Exception $exception * @param \Exception $exception
*
* @return void * @return void
*/ */
public function report(Exception $exception) public function report(Exception $exception)
@ -40,6 +41,7 @@ class Handler extends ExceptionHandler
* *
* @param \Illuminate\Http\Request $request * @param \Illuminate\Http\Request $request
* @param \Exception $exception * @param \Exception $exception
*
* @return \Illuminate\Http\Response * @return \Illuminate\Http\Response
*/ */
public function render($request, Exception $exception) public function render($request, Exception $exception)
@ -52,6 +54,7 @@ class Handler extends ExceptionHandler
* *
* @param \Illuminate\Http\Request $request * @param \Illuminate\Http\Request $request
* @param \Illuminate\Auth\AuthenticationException $exception * @param \Illuminate\Auth\AuthenticationException $exception
*
* @return \Illuminate\Http\Response * @return \Illuminate\Http\Response
*/ */
protected function unauthenticated($request, AuthenticationException $exception) protected function unauthenticated($request, AuthenticationException $exception)

6
app/Http/Controllers/Auth/RegisterController.php

@ -2,10 +2,10 @@
namespace App\Http\Controllers\Auth; namespace App\Http\Controllers\Auth;
use App\User;
use App\Http\Controllers\Controller; use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\Validator;
use App\User;
use Illuminate\Foundation\Auth\RegistersUsers; use Illuminate\Foundation\Auth\RegistersUsers;
use Illuminate\Support\Facades\Validator;
class RegisterController extends Controller class RegisterController extends Controller
{ {
@ -43,6 +43,7 @@ class RegisterController extends Controller
* Get a validator for an incoming registration request. * Get a validator for an incoming registration request.
* *
* @param array $data * @param array $data
*
* @return \Illuminate\Contracts\Validation\Validator * @return \Illuminate\Contracts\Validation\Validator
*/ */
protected function validator(array $data) protected function validator(array $data)
@ -58,6 +59,7 @@ class RegisterController extends Controller
* Create a new user instance after a valid registration. * Create a new user instance after a valid registration.
* *
* @param array $data * @param array $data
*
* @return User * @return User
*/ */
protected function create(array $data) protected function create(array $data)

16
app/Http/Controllers/CartController.php

@ -15,7 +15,7 @@ class CartController extends Controller
public function __construct() public function __construct()
{ {
$this->cart = new CartCollection;
$this->cart = new CartCollection();
} }
public function index(Request $request) public function index(Request $request)
@ -38,10 +38,11 @@ class CartController extends Controller
public function add(Request $request) public function add(Request $request)
{ {
if ($request->has('create-cash-draft'))
$this->cart->add(new CashDraft);
else
$this->cart->add(new CreditDraft);
if ($request->has('create-cash-draft')) {
$this->cart->add(new CashDraft());
} else {
$this->cart->add(new CreditDraft());
}
return redirect()->route('cart.show', $this->cart->content()->last()->draftKey); return redirect()->route('cart.show', $this->cart->content()->last()->draftKey);
} }
@ -57,30 +58,35 @@ class CartController extends Controller
public function updateDraftItem(Request $request, $draftKey) public function updateDraftItem(Request $request, $draftKey)
{ {
$this->cart->updateDraftItem($draftKey, $request->item_key, $request->only('qty', 'item_discount')); $this->cart->updateDraftItem($draftKey, $request->item_key, $request->only('qty', 'item_discount'));
return redirect()->route('cart.index', $draftKey); return redirect()->route('cart.index', $draftKey);
} }
public function removeDraftItem(Request $request, $draftKey) public function removeDraftItem(Request $request, $draftKey)
{ {
$this->cart->removeItemFromDraft($draftKey, $request->item_index); $this->cart->removeItemFromDraft($draftKey, $request->item_index);
return redirect()->route('cart.index', $draftKey); return redirect()->route('cart.index', $draftKey);
} }
public function empty($draftKey) public function empty($draftKey)
{ {
$this->cart->emptyDraft($draftKey); $this->cart->emptyDraft($draftKey);
return redirect()->route('cart.index', $draftKey); return redirect()->route('cart.index', $draftKey);
} }
public function remove(Request $request) public function remove(Request $request)
{ {
$this->cart->removeDraft($request->draft_key); $this->cart->removeDraft($request->draft_key);
return redirect()->route('cart.index'); return redirect()->route('cart.index');
} }
public function destroy() public function destroy()
{ {
$this->cart->destroy(); $this->cart->destroy();
return redirect()->route('cart.index'); return redirect()->route('cart.index');
} }
} }

4
app/Http/Controllers/Controller.php

@ -2,10 +2,10 @@
namespace App\Http\Controllers; namespace App\Http\Controllers;
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
use Illuminate\Foundation\Bus\DispatchesJobs; use Illuminate\Foundation\Bus\DispatchesJobs;
use Illuminate\Routing\Controller as BaseController;
use Illuminate\Foundation\Validation\ValidatesRequests; use Illuminate\Foundation\Validation\ValidatesRequests;
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
use Illuminate\Routing\Controller as BaseController;
class Controller extends BaseController class Controller extends BaseController
{ {

2
app/Http/Controllers/HomeController.php

@ -2,8 +2,6 @@
namespace App\Http\Controllers; namespace App\Http\Controllers;
use Illuminate\Http\Request;
class HomeController extends Controller class HomeController extends Controller
{ {
/** /**

1
app/Http/Middleware/RedirectIfAuthenticated.php

@ -13,6 +13,7 @@ class RedirectIfAuthenticated
* @param \Illuminate\Http\Request $request * @param \Illuminate\Http\Request $request
* @param \Closure $next * @param \Closure $next
* @param string|null $guard * @param string|null $guard
*
* @return mixed * @return mixed
*/ */
public function handle($request, Closure $next, $guard = null) public function handle($request, Closure $next, $guard = null)

3
app/Product.php

@ -10,8 +10,9 @@ class Product extends Model
public function getPrice($type = 'cash') public function getPrice($type = 'cash')
{ {
if ($type == 'credit')
if ($type == 'credit') {
return $this->credit_price; return $this->credit_price;
}
return $this->cash_price; return $this->cash_price;
} }

1
app/Providers/AuthServiceProvider.php

@ -2,7 +2,6 @@
namespace App\Providers; namespace App\Providers;
use Illuminate\Support\Facades\Gate;
use Illuminate\Foundation\Support\Providers\AuthServiceProvider as ServiceProvider; use Illuminate\Foundation\Support\Providers\AuthServiceProvider as ServiceProvider;
class AuthServiceProvider extends ServiceProvider class AuthServiceProvider extends ServiceProvider

2
app/Providers/BroadcastServiceProvider.php

@ -2,8 +2,8 @@
namespace App\Providers; namespace App\Providers;
use Illuminate\Support\ServiceProvider;
use Illuminate\Support\Facades\Broadcast; use Illuminate\Support\Facades\Broadcast;
use Illuminate\Support\ServiceProvider;
class BroadcastServiceProvider extends ServiceProvider class BroadcastServiceProvider extends ServiceProvider
{ {

2
app/Providers/EventServiceProvider.php

@ -2,8 +2,8 @@
namespace App\Providers; namespace App\Providers;
use Illuminate\Support\Facades\Event;
use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider; use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider;
use Illuminate\Support\Facades\Event;
class EventServiceProvider extends ServiceProvider class EventServiceProvider extends ServiceProvider
{ {

2
app/Providers/RouteServiceProvider.php

@ -2,8 +2,8 @@
namespace App\Providers; namespace App\Providers;
use Illuminate\Support\Facades\Route;
use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider; use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider;
use Illuminate\Support\Facades\Route;
class RouteServiceProvider extends ServiceProvider class RouteServiceProvider extends ServiceProvider
{ {

2
app/User.php

@ -2,8 +2,8 @@
namespace App; namespace App;
use Illuminate\Notifications\Notifiable;
use Illuminate\Foundation\Auth\User as Authenticatable; use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;
class User extends Authenticatable class User extends Authenticatable
{ {

4
database/factories/ModelFactory.php

@ -13,7 +13,6 @@
/** @var \Illuminate\Database\Eloquent\Factory $factory */ /** @var \Illuminate\Database\Eloquent\Factory $factory */
$factory->define(App\User::class, function (Faker\Generator $faker) { $factory->define(App\User::class, function (Faker\Generator $faker) {
return [ return [
'name' => $faker->name, 'name' => $faker->name,
'username' => $faker->unique()->username, 'username' => $faker->unique()->username,
@ -22,9 +21,8 @@ $factory->define(App\User::class, function (Faker\Generator $faker) {
]; ];
}); });
/** @var \Illuminate\Database\Eloquent\Factory $factory */
/* @var \Illuminate\Database\Eloquent\Factory $factory */
$factory->define(App\Product::class, function (Faker\Generator $faker) { $factory->define(App\Product::class, function (Faker\Generator $faker) {
return [ return [
'name' => $faker->name, 'name' => $faker->name,
'cash_price' => 2000, 'cash_price' => 2000,

4
database/migrations/2014_10_12_000000_create_users_table.php

@ -1,8 +1,8 @@
<?php <?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateUsersTable extends Migration class CreateUsersTable extends Migration
{ {

4
database/migrations/2017_04_09_013901_create_products_table.php

@ -1,8 +1,8 @@
<?php <?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateProductsTable extends Migration class CreateProductsTable extends Migration
{ {

3
public/index.php

@ -1,9 +1,8 @@
<?php <?php
/** /**
* Laravel - A PHP Framework For Web Artisans
* Laravel - A PHP Framework For Web Artisans.
* *
* @package Laravel
* @author Taylor Otwell <taylor@laravel.com> * @author Taylor Otwell <taylor@laravel.com>
*/ */

4
server.php

@ -1,12 +1,10 @@
<?php <?php
/** /**
* Laravel - A PHP Framework For Web Artisans
* Laravel - A PHP Framework For Web Artisans.
* *
* @package Laravel
* @author Taylor Otwell <taylor@laravel.com> * @author Taylor Otwell <taylor@laravel.com>
*/ */
$uri = urldecode( $uri = urldecode(
parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH) parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH)
); );

32
tests/Feature/Cart/CartControllerTest.php

@ -19,7 +19,7 @@ class CartControllerTest extends TestCase
{ {
$this->loginAsUser(); $this->loginAsUser();
$cart = new CartCollection;
$cart = new CartCollection();
$response = $this->post(route('cart.add'), ['create-cash-draft'=> trans('transaction.create')]); $response = $this->post(route('cart.add'), ['create-cash-draft'=> trans('transaction.create')]);
$response = $this->post(route('cart.add'), ['create-credit-draft'=> trans('transaction.create_credit')]); $response = $this->post(route('cart.add'), ['create-credit-draft'=> trans('transaction.create_credit')]);
@ -37,8 +37,8 @@ class CartControllerTest extends TestCase
{ {
$this->loginAsUser(); $this->loginAsUser();
$cart = new CartCollection;
$draft = new CashDraft;
$cart = new CartCollection();
$draft = new CashDraft();
$cart->add($draft); $cart->add($draft);
// Add Product to database // Add Product to database
@ -47,7 +47,7 @@ class CartControllerTest extends TestCase
// Add Product as CashDraft item // Add Product as CashDraft item
$response = $this->post(route('cart.add-draft-item', [$draft->draftKey, $product->id]), [ $response = $this->post(route('cart.add-draft-item', [$draft->draftKey, $product->id]), [
'qty' => $itemQty
'qty' => $itemQty,
]); ]);
$cashDraft = $cart->content()->first(); $cashDraft = $cart->content()->first();
@ -60,8 +60,8 @@ class CartControllerTest extends TestCase
{ {
$this->loginAsUser(); $this->loginAsUser();
$cart = new CartCollection;
$cashDraft = new CashDraft;
$cart = new CartCollection();
$cashDraft = new CashDraft();
$product = factory(Product::class)->create(['cash_price' => 1100], ['credit_price' => 1000]); $product = factory(Product::class)->create(['cash_price' => 1100], ['credit_price' => 1000]);
$item = new Item($product, 2); $item = new Item($product, 2);
@ -73,7 +73,7 @@ class CartControllerTest extends TestCase
// Remove Item Product from CashDraft // Remove Item Product from CashDraft
$response = $this->delete(route('cart.remove-draft-item', [$cashDraft->draftKey]), [ $response = $this->delete(route('cart.remove-draft-item', [$cashDraft->draftKey]), [
'item_index' => 0
'item_index' => 0,
]); ]);
$this->assertEquals(0, $cashDraft->getTotalQty()); $this->assertEquals(0, $cashDraft->getTotalQty());
@ -86,8 +86,8 @@ class CartControllerTest extends TestCase
{ {
$this->loginAsUser(); $this->loginAsUser();
$cart = new CartCollection;
$cashDraft = new CashDraft;
$cart = new CartCollection();
$cashDraft = new CashDraft();
$cart->add($cashDraft); $cart->add($cashDraft);
$this->assertFalse($cart->isEmpty()); $this->assertFalse($cart->isEmpty());
@ -95,7 +95,7 @@ class CartControllerTest extends TestCase
// Remove a transaction draft // Remove a transaction draft
$response = $this->delete(route('cart.remove'), [ $response = $this->delete(route('cart.remove'), [
'draft_key' => $cashDraft->draftKey
'draft_key' => $cashDraft->draftKey,
]); ]);
$this->assertTrue($cart->isEmpty()); $this->assertTrue($cart->isEmpty());
@ -106,8 +106,8 @@ class CartControllerTest extends TestCase
{ {
$this->loginAsUser(); $this->loginAsUser();
$cart = new CartCollection;
$cashDraft = new CashDraft;
$cart = new CartCollection();
$cashDraft = new CashDraft();
$cart->add($cashDraft); $cart->add($cashDraft);
$cart->add($cashDraft); $cart->add($cashDraft);
@ -125,8 +125,8 @@ class CartControllerTest extends TestCase
{ {
$this->loginAsUser(); $this->loginAsUser();
$cart = new CartCollection;
$cashDraft = new CashDraft;
$cart = new CartCollection();
$cashDraft = new CashDraft();
$product = factory(Product::class)->create(['cash_price' => 1100], ['credit_price' => 1000]); $product = factory(Product::class)->create(['cash_price' => 1100], ['credit_price' => 1000]);
$item = new Item($product, 2); $item = new Item($product, 2);
@ -149,8 +149,8 @@ class CartControllerTest extends TestCase
{ {
$this->loginAsUser(); $this->loginAsUser();
$cart = new CartCollection;
$cashDraft = new CashDraft;
$cart = new CartCollection();
$cashDraft = new CashDraft();
$product = factory(Product::class)->create(['cash_price' => 1100], ['credit_price' => 1000]); $product = factory(Product::class)->create(['cash_price' => 1100], ['credit_price' => 1000]);
$item = new Item($product, 2); $item = new Item($product, 2);

12
tests/Feature/TransactionEntryTest.php

@ -19,8 +19,8 @@ class TransactionEntryTest extends BrowserKitTestCase
$this->loginAsUser(); $this->loginAsUser();
// Add new draft to collection // Add new draft to collection
$cart = new CartCollection;
$draft = $cart->add(new CashDraft);
$cart = new CartCollection();
$draft = $cart->add(new CashDraft());
$this->visit(route('cart.index')); $this->visit(route('cart.index'));
@ -35,12 +35,12 @@ class TransactionEntryTest extends BrowserKitTestCase
$this->visit(route('home')); $this->visit(route('home'));
$this->press(trans('transaction.create')); $this->press(trans('transaction.create'));
$cart = new CartCollection;
$cart = new CartCollection();
$draft = $cart->content()->last(); $draft = $cart->content()->last();
$this->seePageIs(route('cart.show', $draft->draftKey)); $this->seePageIs(route('cart.show', $draft->draftKey));
$this->press(trans('transaction.create_credit')); $this->press(trans('transaction.create_credit'));
$cart = new CartCollection;
$cart = new CartCollection();
$draft = $cart->content()->last(); $draft = $cart->content()->last();
$this->seePageIs(route('cart.show', $draft->draftKey)); $this->seePageIs(route('cart.show', $draft->draftKey));
} }
@ -51,8 +51,8 @@ class TransactionEntryTest extends BrowserKitTestCase
$product = factory(Product::class)->create(['name' => 'Testing Produk 1']); $product = factory(Product::class)->create(['name' => 'Testing Produk 1']);
$this->loginAsUser(); $this->loginAsUser();
$cart = new CartCollection;
$draft = new CreditDraft;
$cart = new CartCollection();
$draft = new CreditDraft();
$cart->add($draft); $cart->add($draft);
// Visit cart index page // Visit cart index page

53
tests/Unit/CartCollectionTest.php

@ -14,17 +14,17 @@ class CartCollectionTest extends TestCase
/** @test */ /** @test */
public function it_has_a_default_instance() public function it_has_a_default_instance()
{ {
$cart = new CartCollection;
$cart = new CartCollection();
$this->assertEquals('drafts', $cart->currentInstance()); $this->assertEquals('drafts', $cart->currentInstance());
} }
/** @test */ /** @test */
public function it_can_have_multiple_instances() public function it_can_have_multiple_instances()
{ {
$cart = new CartCollection;
$cart = new CartCollection();
$cashDraft = new CashDraft;
$creditDraft = new CreditDraft;
$cashDraft = new CashDraft();
$creditDraft = new CreditDraft();
$cart->add($cashDraft); $cart->add($cashDraft);
$cart->add($creditDraft); $cart->add($creditDraft);
@ -39,9 +39,9 @@ class CartCollectionTest extends TestCase
/** @test */ /** @test */
public function cart_collection_consist_of_transacion_draft() public function cart_collection_consist_of_transacion_draft()
{ {
$cart = new CartCollection;
$cashDraft = new CashDraft;
$creditDraft = new CreditDraft;
$cart = new CartCollection();
$cashDraft = new CashDraft();
$creditDraft = new CreditDraft();
$cart->add($cashDraft); $cart->add($cashDraft);
$cart->add($creditDraft); $cart->add($creditDraft);
@ -53,8 +53,8 @@ class CartCollectionTest extends TestCase
/** @test */ /** @test */
public function it_can_get_a_draft_by_key() public function it_can_get_a_draft_by_key()
{ {
$draft = new CashDraft;
$cart = new CartCollection;
$draft = new CashDraft();
$cart = new CartCollection();
$cart->add($draft); $cart->add($draft);
$gottenDraft = $cart->get($draft->draftKey); $gottenDraft = $cart->get($draft->draftKey);
@ -67,9 +67,9 @@ class CartCollectionTest extends TestCase
/** @test */ /** @test */
public function it_can_remove_draft_from_draft_collection() public function it_can_remove_draft_from_draft_collection()
{ {
$cart = new CartCollection;
$cashDraft = new CashDraft;
$creditDraft = new CreditDraft;
$cart = new CartCollection();
$cashDraft = new CashDraft();
$creditDraft = new CreditDraft();
$cart->add($cashDraft); $cart->add($cashDraft);
$cart->add($creditDraft); $cart->add($creditDraft);
@ -82,10 +82,10 @@ class CartCollectionTest extends TestCase
/** @test */ /** @test */
public function it_can_be_empty_out() public function it_can_be_empty_out()
{ {
$cart = new CartCollection;
$cart = new CartCollection();
$cashDraft = new CashDraft;
$creditDraft = new CreditDraft;
$cashDraft = new CashDraft();
$creditDraft = new CreditDraft();
$cart->add($cashDraft); $cart->add($cashDraft);
$cart->add($cashDraft); $cart->add($cashDraft);
@ -103,10 +103,10 @@ class CartCollectionTest extends TestCase
/** @test */ /** @test */
public function it_has_content_keys() public function it_has_content_keys()
{ {
$cart = new CartCollection;
$cart = new CartCollection();
$cashDraft = new CashDraft;
$creditDraft = new CreditDraft;
$cashDraft = new CashDraft();
$creditDraft = new CreditDraft();
$cart->add($cashDraft); $cart->add($cashDraft);
$cart->add($creditDraft); $cart->add($creditDraft);
@ -119,9 +119,9 @@ class CartCollectionTest extends TestCase
/** @test */ /** @test */
public function it_can_update_a_draft_attributes() public function it_can_update_a_draft_attributes()
{ {
$cart = new CartCollection;
$cart = new CartCollection();
$draft = $cart->add(new CashDraft);
$draft = $cart->add(new CashDraft());
$this->assertCount(1, $cart->content()); $this->assertCount(1, $cart->content());
$newDraftAttribute = [ $newDraftAttribute = [
@ -151,9 +151,9 @@ class CartCollectionTest extends TestCase
/** @test */ /** @test */
public function it_can_add_product_to_draft() public function it_can_add_product_to_draft()
{ {
$cart = new CartCollection;
$cart = new CartCollection();
$draft = $cart->add(new CashDraft);
$draft = $cart->add(new CashDraft());
$count = 2; $count = 2;
$item = new Item(new Product(['cash_price' => 1000]), $count); $item = new Item(new Product(['cash_price' => 1000]), $count);
@ -164,9 +164,9 @@ class CartCollectionTest extends TestCase
/** @test */ /** @test */
public function it_can_remove_item_from_draft() public function it_can_remove_item_from_draft()
{ {
$cart = new CartCollection;
$cart = new CartCollection();
$draft = $cart->add(new CashDraft);
$draft = $cart->add(new CashDraft());
$item = new Item(new Product(['cash_price' => 1000]), 3); $item = new Item(new Product(['cash_price' => 1000]), 3);
$cart->addItemToDraft($draft->draftKey, $item); $cart->addItemToDraft($draft->draftKey, $item);
@ -179,9 +179,9 @@ class CartCollectionTest extends TestCase
/** @test */ /** @test */
public function it_can_update_an_item_of_draft() public function it_can_update_an_item_of_draft()
{ {
$cart = new CartCollection;
$cart = new CartCollection();
$draft = $cart->add(new CashDraft);
$draft = $cart->add(new CashDraft());
$item = new Item(new Product(['cash_price' => 1100]), 3); $item = new Item(new Product(['cash_price' => 1100]), 3);
$cart->addItemToDraft($draft->draftKey, $item); $cart->addItemToDraft($draft->draftKey, $item);
@ -196,5 +196,4 @@ class CartCollectionTest extends TestCase
$cart->updateDraftItem($draft->draftKey, 0, $newItemData); $cart->updateDraftItem($draft->draftKey, 0, $newItemData);
$this->assertEquals(2000, $draft->getTotal()); $this->assertEquals(2000, $draft->getTotal());
} }
} }

2
tests/Unit/Integration/ProductTest.php

@ -3,8 +3,6 @@
namespace Tests\Unit\Integration; namespace Tests\Unit\Integration;
use App\Product; use App\Product;
use Illuminate\Foundation\Testing\DatabaseMigrations;
use Illuminate\Foundation\Testing\DatabaseTransactions;
use Tests\TestCase; use Tests\TestCase;
class ProductTest extends TestCase class ProductTest extends TestCase

Loading…
Cancel
Save