Skip to content

Commit

Permalink
Add unit tests, fixed some bugs (#16)
Browse files Browse the repository at this point in the history
* Added more unit tests

* Removed older php version support

* fix composer command

* removed trailing spaces

* Replaced tabs with spaces

* fix move items

* Added codecov badge

fixes #14 #15
  • Loading branch information
hassansin authored Dec 24, 2018
1 parent cb37117 commit eb44d6a
Show file tree
Hide file tree
Showing 17 changed files with 3,181 additions and 1,325 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
/vendor
error_log
coverage
17 changes: 10 additions & 7 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
language: php

php:
- 5.5
- 5.6
- hhvm
- '7.1'
- '7.2'
- '7.3'
- nightly

sudo: false
before_script:
- composer install --prefer-dist --no-interaction --no-suggest

install: travis_retry composer install --no-interaction --prefer-dist
script:
- vendor/bin/phpunit --coverage-clover=coverage.xml

script: vendor/bin/phpunit --verbose
after_success:
- bash <(curl -s https://codecov.io/bash)
13 changes: 13 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
ARG VERSION
FROM php:${VERSION}
RUN curl -O https://getcomposer.org/composer.phar
RUN mv composer.phar /usr/local/bin/composer
RUN chmod a+x /usr/local/bin/composer
RUN apt-get update && apt-get install -y git unzip
ARG VERSION
RUN if [ "$VERSION" = "7.2" ]; then \
composer global require phpunit/phpunit:^7 && pecl install xdebug-2.7.0alpha1; else \
composer global require phpunit/phpunit:^4 && pecl install xdebug-2.5.5; fi
RUN docker-php-ext-enable xdebug
ENV PATH="${PATH}:/root/.composer/vendor/bin"
COPY php.ini /usr/local/etc/php/
16 changes: 16 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
RUNNER=docker run -it --rm --workdir "/src" -v "$(PWD):/src" -v "$(HOME)/.composer/cache:/root/.composer/cache" dbcartphp /bin/bash -c

.PHONY: build composer php test

build:
@docker build --build-arg VERSION=7.2 --tag=dbcartphp .
composer:
@$(RUNNER) "composer $(filter-out $@,$(MAKECMDGOALS))"
dependencies:
make -s composer update -- --prefer-dist
test:
$(RUNNER) "phpunit --coverage-text --coverage-html ./coverage $(filter-out $@,$(MAKECMDGOALS))"
php:
$(RUNNER) "php $(filter-out $@,$(MAKECMDGOALS))"
%:
@:
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# DBCart [![Build Status](https://travis-ci.org/hassansin/dbcart.svg?branch=master)](https://travis-ci.org/hassansin/dbcart) [![SensioLabsInsight](https://insight.sensiolabs.com/projects/97876df8-6a51-4da1-92f3-14ebe544c4d9/mini.png?v=1)](https://insight.sensiolabs.com/projects/97876df8-6a51-4da1-92f3-14ebe544c4d9)
# DBCart [![Build Status](https://travis-ci.org/hassansin/dbcart.svg?branch=master)](https://travis-ci.org/hassansin/dbcart) [![SensioLabsInsight](https://insight.sensiolabs.com/projects/97876df8-6a51-4da1-92f3-14ebe544c4d9/mini.png?v=1)](https://insight.sensiolabs.com/projects/97876df8-6a51-4da1-92f3-14ebe544c4d9) [![codecov](https://codecov.io/gh/hassansin/dbcart/branch/master/graph/badge.svg)](https://codecov.io/gh/hassansin/dbcart)

Shopping Cart library for Laravel 5 that uses database instead of sessions to store carts.

Expand Down Expand Up @@ -94,7 +94,7 @@ Since `$cart` is eloquent model instance, you can use any of the eloquent method
```php
$items = $cart->items // by dynamic property access
$items = $cart->items()->get()
$items = $cart->items()->where('quantity', '=>', 2)->get()
$items = $cart->items()->where('quantity', '>=', 2)->get()
```

#### Update an Item: `$cart->updateItem($where, $attributes)`
Expand Down
5 changes: 2 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,12 @@
}
],
"require": {
"php": ">=5.4.0",
"illuminate/support": "~5.0"
"php": ">=7.1.3",
"illuminate/support": "~5.0"
},
"require-dev": {
"fzaninotto/faker": "~1.4",
"mockery/mockery": "~0.9",
"phpunit/phpunit": "~4.0",
"orchestra/testbench": "~3.0"
},
"autoload": {
Expand Down
Loading

0 comments on commit eb44d6a

Please sign in to comment.