mirror of
https://github.com/kevin-DL/LaravelShoppingcart.git
synced 2026-01-23 23:51:25 +00:00
Large update for version 2.0
This commit is contained in:
35
tests/CartAssertions.php
Normal file
35
tests/CartAssertions.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
use Gloudemans\Shoppingcart\Cart;
|
||||
use PHPUnit_Framework_Assert as PHPUnit;
|
||||
|
||||
trait CartAssertions
|
||||
{
|
||||
|
||||
/**
|
||||
* Assert that the cart contains the given number of items.
|
||||
*
|
||||
* @param int|float $items
|
||||
* @param \Gloudemans\Shoppingcart\Cart $cart
|
||||
*/
|
||||
public function assertItemsInCart($items, Cart $cart)
|
||||
{
|
||||
$actual = $cart->count();
|
||||
|
||||
PHPUnit::assertEquals($items, $cart->count(), "Expected the cart to contain {$items} items, but got {$actual}.");
|
||||
}
|
||||
|
||||
/**
|
||||
* Assert that the cart contains the given number of rows.
|
||||
*
|
||||
* @param int $rows
|
||||
* @param \Gloudemans\Shoppingcart\Cart $cart
|
||||
*/
|
||||
public function assertRowsInCart($rows, Cart $cart)
|
||||
{
|
||||
$actual = $cart->content()->count();
|
||||
|
||||
PHPUnit::assertCount($rows, $cart->content(), "Expected the cart to contain {$rows} rows, but got {$actual}.");
|
||||
}
|
||||
|
||||
}
|
||||
1194
tests/CartTest.php
1194
tests/CartTest.php
File diff suppressed because it is too large
Load Diff
@@ -1,5 +0,0 @@
|
||||
<?php namespace Acme\Test\Models;
|
||||
class TestProduct {
|
||||
public $description = 'This is the description of the namespaced test model';
|
||||
public function find($id) { return $this; }
|
||||
}
|
||||
@@ -1,6 +0,0 @@
|
||||
<?php
|
||||
|
||||
class TestProduct {
|
||||
public $description = 'This is the description of the test model';
|
||||
public function find($id) { return $this; }
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
<?php
|
||||
|
||||
class SessionMock {
|
||||
protected $session;
|
||||
public function has($key)
|
||||
{
|
||||
return isset($this->session[$key]);
|
||||
}
|
||||
public function get($key)
|
||||
{
|
||||
return $this->session[$key];
|
||||
}
|
||||
public function put($key, $value)
|
||||
{
|
||||
$this->session[$key] = $value;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user