mirror of
https://github.com/kevin-DL/LaravelShoppingcart.git
synced 2026-01-23 23:51:25 +00:00
Mod test,
Document ServiceProvider,
This commit is contained in:
@@ -15,13 +15,19 @@ class ShoppingcartServiceProvider extends ServiceProvider
|
|||||||
*/
|
*/
|
||||||
public function register()
|
public function register()
|
||||||
{
|
{
|
||||||
|
/* Bind Cart class to cart for Facade usage */
|
||||||
$this->app->bind('cart', 'Gloudemans\Shoppingcart\Cart');
|
$this->app->bind('cart', 'Gloudemans\Shoppingcart\Cart');
|
||||||
|
|
||||||
|
/* Determine where the config file is located */
|
||||||
$config = __DIR__.'/Config/cart.php';
|
$config = __DIR__.'/Config/cart.php';
|
||||||
|
|
||||||
|
/* Use local config */
|
||||||
$this->mergeConfigFrom($config, 'cart');
|
$this->mergeConfigFrom($config, 'cart');
|
||||||
|
|
||||||
$this->publishes([__DIR__.'/Config/cart.php' => config_path('cart.php')], 'config');
|
/* Also allow publishing to overwrite local config */
|
||||||
|
$this->publishes([$config => config_path('cart.php')], 'config');
|
||||||
|
|
||||||
|
/* Publish included migrations */
|
||||||
$this->publishes([
|
$this->publishes([
|
||||||
realpath(__DIR__.'/Database/migrations') => $this->app->databasePath().'/migrations',
|
realpath(__DIR__.'/Database/migrations') => $this->app->databasePath().'/migrations',
|
||||||
], 'migrations');
|
], 'migrations');
|
||||||
|
|||||||
@@ -30,7 +30,9 @@ class CartTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
protected function getPackageProviders($app)
|
protected function getPackageProviders($app)
|
||||||
{
|
{
|
||||||
return [ShoppingcartServiceProvider::class];
|
return [
|
||||||
|
ShoppingcartServiceProvider::class
|
||||||
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -522,6 +524,9 @@ class CartTest extends TestCase
|
|||||||
'id' => 2,
|
'id' => 2,
|
||||||
]));
|
]));
|
||||||
|
|
||||||
|
$cartItem = $cart->get('027c91341fd5cf4d2579b49c4b6a90da');
|
||||||
|
$this->assertEquals(config('cart.tax'), $cartItem->taxRate);
|
||||||
|
|
||||||
$content = $cart->content();
|
$content = $cart->content();
|
||||||
|
|
||||||
$this->assertInstanceOf(Collection::class, $content);
|
$this->assertInstanceOf(Collection::class, $content);
|
||||||
@@ -1120,7 +1125,7 @@ class CartTest extends TestCase
|
|||||||
'name' => 'First item',
|
'name' => 'First item',
|
||||||
]), 1);
|
]), 1);
|
||||||
$cartItem = $cart->get('027c91341fd5cf4d2579b49c4b6a90da');
|
$cartItem = $cart->get('027c91341fd5cf4d2579b49c4b6a90da');
|
||||||
|
|
||||||
$cart->setDiscount('027c91341fd5cf4d2579b49c4b6a90da', 0.5);
|
$cart->setDiscount('027c91341fd5cf4d2579b49c4b6a90da', 0.5);
|
||||||
|
|
||||||
$this->assertEquals(0.5, $cartItem->discount);
|
$this->assertEquals(0.5, $cartItem->discount);
|
||||||
|
|||||||
Reference in New Issue
Block a user