Skip to content
This repository has been archived by the owner on Oct 12, 2020. It is now read-only.

Commit

Permalink
laravel 6.0 support
Browse files Browse the repository at this point in the history
  • Loading branch information
melihovv committed Sep 7, 2019
1 parent ba31257 commit 0ba3a5f
Show file tree
Hide file tree
Showing 14 changed files with 53 additions and 107 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
/.idea/
/node_modules
/composer.lock
/.phpunit.result.cache
3 changes: 0 additions & 3 deletions .sensiolabs.yml

This file was deleted.

38 changes: 25 additions & 13 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
cache:
directories:
- $HOME/.composer/cache

language: php

sudo: false
Expand All @@ -9,29 +13,37 @@ notifications:
email:
on_success: never
on_failure: always
php:
- 7.0
- 7.1
- 7.2

env:
matrix:
- COMPOSER_FLAGS="--prefer-lowest"
- COMPOSER_FLAGS=""
matrix:
include:
- php: 7.2
env: LARAVEL='6.*' TESTBENCH='4.*' COMPOSER_FLAGS='--prefer-lowest'
- php: 7.2
env: LARAVEL='6.*' TESTBENCH='4.*' COMPOSER_FLAGS='--prefer-stable'
- php: 7.3
env: LARAVEL='6.*' TESTBENCH='4.*' COMPOSER_FLAGS='--prefer-lowest'
- php: 7.3
env: LARAVEL='6.*' TESTBENCH='4.*' COMPOSER_FLAGS='--prefer-stable'
- php: 7.4snapshot
env: LARAVEL='6.*' TESTBENCH='4.*' COMPOSER_FLAGS='--prefer-lowest'
- php: 7.4snapshot
env: LARAVEL='6.*' TESTBENCH='4.*' COMPOSER_FLAGS='--prefer-stable'
fast_finish: true
allow_failures:
- php: 7.4snapshot

before_install:
- travis_retry composer self-update --stable -n
- composer config discard-changes true
- composer validate --no-check-all --strict
- travis_retry composer self-update
- travis_retry composer require "laravel/framework:${LARAVEL}" "orchestra/testbench:${TESTBENCH}" --no-interaction --no-update

install:
- travis_retry composer update --prefer-source $COMPOSER_FLAGS
- travis_retry composer update ${COMPOSER_FLAGS} --prefer-dist --no-interaction --no-suggest
- composer require satooshi/php-coveralls --dev

script:
- composer run phpunit -- --coverage-clover ./tests/logs/clover.xml
- composer run phpcs
- composer run phpmd
- composer run phpcpd

after_script:
- php vendor/bin/php-coveralls -v
18 changes: 0 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ Laravel Shopping Cart

[![Build Status](https://travis-ci.org/melihovv/laravel-shopping-cart.svg?branch=master)](https://travis-ci.org/melihovv/laravel-shopping-cart)
[![styleci](https://styleci.io/repos/95455977/shield)](https://styleci.io/repos/95455977)
[![SensioLabsInsight](https://insight.sensiolabs.com/projects/b244d9ba-7db5-4452-a97f-3032e40c999c/mini.png)](https://insight.sensiolabs.com/projects/b244d9ba-7db5-4452-a97f-3032e40c999c)
[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/melihovv/laravel-shopping-cart/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/melihovv/laravel-shopping-cart/?branch=master)
[![Coverage Status](https://coveralls.io/repos/github/melihovv/laravel-shopping-cart/badge.svg?branch=master)](https://coveralls.io/github/melihovv/laravel-shopping-cart?branch=master)

[![Packagist](https://img.shields.io/packagist/v/melihovv/laravel-shopping-cart.svg)](https://packagist.org/packages/melihovv/laravel-shopping-cart)
Expand All @@ -18,22 +16,6 @@ Install via composer
composer require melihovv/laravel-shopping-cart
```


### Add service provider

Add Service Provider to `config/app.php` in `providers` section (this and next
step are optional step if you use laravel>=5.5 with package auto discovery
feature)
```php
Melihovv\ShoppingCart\ServiceProvider::class,
```

### Register facade
In the same file in `aliases` section add the following line
```php
'Cart' => Melihovv\ShoppingCart\Facades\ShoppingCart::class,
```

### Publish configuration file and migrations

```
Expand Down
28 changes: 9 additions & 19 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,31 +22,21 @@
"autoload-dev": {
"psr-4": {
"Melihovv\\ShoppingCart\\Tests\\": "tests/"
},
"files": [
"vendor/phpunit/phpunit/src/Framework/Assert/Functions.php"
]
}
},
"require": {
"illuminate/container": "~5.5.0|~5.6.0|~5.7.0|~5.8.0",
"illuminate/database": "~5.5.0|~5.6.0|~5.7.0|~5.8.0",
"illuminate/redis": "~5.5.0|~5.6.0|~5.7.0|~5.8.0",
"illuminate/support": "~5.5.0|~5.6.0|~5.7.0|~5.8.0"
"illuminate/container": "^6.0",
"illuminate/database": "^6.0",
"illuminate/redis": "^6.0",
"illuminate/support": "^6.0"
},
"require-dev": {
"orchestra/testbench": "~3.5.0|~3.6.0|~3.7.0|~3.8.0",
"phpmd/phpmd": "^2.6",
"phpunit/phpunit": "~6.0|~7.0",
"predis/predis": "^1.1",
"sebastian/phpcpd": "^3.0",
"squizlabs/php_codesniffer": "^2.7"
"orchestra/testbench": "^4.0",
"phpunit/phpunit": "^8.0",
"predis/predis": "^1.1"
},
"scripts": {
"phpunit": "phpunit",
"phpmd": "phpmd src/ShoppingCart text ./phpmd-rules.xml",
"phpcs": "phpcs --standard=./phpcs-rules.xml --encoding=utf-8 src/ShoppingCart",
"phpcbf": "phpcbf --standard=./phpcs-rules.xml --encoding=utf-8 src/ShoppingCart",
"phpcpd": "phpcpd src/ShoppingCart"
"phpunit": "phpunit"
},
"extra": {
"laravel": {
Expand Down
6 changes: 0 additions & 6 deletions phpcs-rules.xml

This file was deleted.

28 changes: 0 additions & 28 deletions phpmd-rules.xml

This file was deleted.

1 change: 0 additions & 1 deletion src/ShoppingCart/Coupons/FixedDiscountCoupon.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ public function __construct($name, $discount)
* @param $total
*
* @return float Discount.
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function apply($total)
{
Expand Down
3 changes: 0 additions & 3 deletions src/ShoppingCart/ShoppingCart.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@
use Melihovv\ShoppingCart\Coupons\Coupon;
use Melihovv\ShoppingCart\Repositories\ShoppingCartRepositoryInterface;

/**
* @SuppressWarnings(PHPMD.TooManyPublicMethods)
*/
class ShoppingCart
{
/**
Expand Down
2 changes: 1 addition & 1 deletion tests/CartItemTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ public function testTotal()
{
$cartItem = new CartItem(1, 'iPhone', 100, 10);

assertEquals($cartItem->getTotal(), 1000);
$this->assertEquals($cartItem->getTotal(), 1000);
}
}
2 changes: 1 addition & 1 deletion tests/ShoppingCartDatabaseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ protected function getEnvironmentSetUp($app)
]);
}

protected function setUp()
protected function setUp() : void
{
parent::setUp();

Expand Down
4 changes: 3 additions & 1 deletion tests/ShoppingCartRedisTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,11 @@ protected function getEnvironmentSetUp($app)
'laravel-shopping-cart.repository',
ShoppingCartRedisRepository::class
);

$config->set('database.redis.client', 'predis');
}

protected function tearDown()
protected function tearDown() : void
{
Redis::flushAll();

Expand Down
8 changes: 4 additions & 4 deletions tests/ShoppingCartRepositoryTester.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ public function testStoreAndRestore()
\Cart::store(1);
\Cart::clear();

assertEquals(0, \Cart::count());
$this->assertEquals(0, \Cart::count());

\Cart::restore(1);

assertEquals(5, \Cart::count());
assertEquals(2, \Cart::coupons()->count());
assertEquals('shopping-cart.default', \Cart::currentInstance());
$this->assertEquals(5, \Cart::count());
$this->assertEquals(2, \Cart::coupons()->count());
$this->assertEquals('shopping-cart.default', \Cart::currentInstance());
}
}
18 changes: 9 additions & 9 deletions tests/ShoppingCartTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ public function testAddItemToCart()
{
$this->addItemToCart();

assertEquals(1, \Cart::count());
$this->assertEquals(1, \Cart::count());

$this->addItemToCart(2);

assertEquals(2, \Cart::count());
$this->assertEquals(2, \Cart::count());
}

public function testRemoveItemFromCart()
Expand All @@ -28,15 +28,15 @@ public function testRemoveItemFromCart()

\Cart::remove($items[2]->getUniqueId());

assertEquals(4, \Cart::count());
$this->assertEquals(4, \Cart::count());
}

public function testUpdateQuantity()
{
$cartItem = $this->addItemToCart(1, 'iPhone 7', 100, 5);
\Cart::setQuantity($cartItem->getUniqueId(), 10);

assertEquals(10, \Cart::get($cartItem->getUniqueId())->quantity);
$this->assertEquals(10, \Cart::get($cartItem->getUniqueId())->quantity);
}

public function testClearCart()
Expand All @@ -45,14 +45,14 @@ public function testClearCart()

\Cart::clear();

assertEquals(0, \Cart::count());
$this->assertEquals(0, \Cart::count());
}

public function testGetTotal()
{
$this->addItemsToCart();

assertEquals(5000, \Cart::getTotal());
$this->assertEquals(5000, \Cart::getTotal());
}

public function testGetTotalWithCoupons()
Expand All @@ -62,7 +62,7 @@ public function testGetTotalWithCoupons()
\Cart::addCoupon(new FixedDiscountCoupon('fixed coupon', 300));
\Cart::addCoupon(new PercentDiscountCoupon('percent coupon', 0.05));

assertEquals(1000 - 300 - 1000 * 0.05, \Cart::getTotalWithCoupons());
$this->assertEquals(1000 - 300 - 1000 * 0.05, \Cart::getTotalWithCoupons());
}

public function testContent()
Expand All @@ -71,7 +71,7 @@ public function testContent()

$content = \Cart::content();

assertEquals(5, $content->count());
assertInstanceOf(Collection::class, $content);
$this->assertEquals(5, $content->count());
$this->assertInstanceOf(Collection::class, $content);
}
}

0 comments on commit 0ba3a5f

Please sign in to comment.