From cb67e0528b977e9921dce771493a0c3231d44977 Mon Sep 17 00:00:00 2001 From: Nafies Luthfi Date: Thu, 27 Apr 2017 14:34:59 +0700 Subject: [PATCH] Added Transaction Entry functional test and added flash & debugbar package --- composer.json | 4 +- composer.lock | 174 +++++++++++++++++++++++++++++++-- config/app.php | 2 + storage/debugbar/.gitignore | 2 + tests/Feature/TransactionEntryTest.php | 47 +++++++++ 5 files changed, 220 insertions(+), 9 deletions(-) create mode 100644 storage/debugbar/.gitignore diff --git a/composer.json b/composer.json index 7202b25..f1bc99f 100644 --- a/composer.json +++ b/composer.json @@ -8,7 +8,9 @@ "php": ">=5.6.4", "laravel/browser-kit-testing": "^1.0", "laravel/framework": "5.4.*", - "luthfi/formfield": "^0.1.3" + "luthfi/formfield": "^0.1.3", + "barryvdh/laravel-debugbar": "^2.0", + "laracasts/flash": "~2" }, "require-dev": { "fzaninotto/faker": "~1.4", diff --git a/composer.lock b/composer.lock index 9075e59..36ed478 100644 --- a/composer.lock +++ b/composer.lock @@ -4,9 +4,63 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "content-hash": "360ad09108ebcf2e18cdc61e59e298d9", + "content-hash": "4dea6286629956973e12d8ccba163b46", "packages": [ { + "name": "barryvdh/laravel-debugbar", + "version": "v2.3.2", + "source": { + "type": "git", + "url": "https://github.com/barryvdh/laravel-debugbar.git", + "reference": "24e4f0261e352d3fd86d0447791b56ae49398674" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/barryvdh/laravel-debugbar/zipball/24e4f0261e352d3fd86d0447791b56ae49398674", + "reference": "24e4f0261e352d3fd86d0447791b56ae49398674", + "shasum": "" + }, + "require": { + "illuminate/support": "5.1.*|5.2.*|5.3.*|5.4.*", + "maximebf/debugbar": "~1.13.0", + "php": ">=5.5.9", + "symfony/finder": "~2.7|~3.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.3-dev" + } + }, + "autoload": { + "psr-4": { + "Barryvdh\\Debugbar\\": "src/" + }, + "files": [ + "src/helpers.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Barry vd. Heuvel", + "email": "barryvdh@gmail.com" + } + ], + "description": "PHP Debugbar integration for Laravel", + "keywords": [ + "debug", + "debugbar", + "laravel", + "profiler", + "webprofiler" + ], + "time": "2017-01-19T08:19:49+00:00" + }, + { "name": "doctrine/inflector", "version": "v1.1.0", "source": { @@ -116,6 +170,49 @@ "time": "2017-03-29T16:04:15+00:00" }, { + "name": "laracasts/flash", + "version": "2.0.1", + "source": { + "type": "git", + "url": "https://github.com/laracasts/flash.git", + "reference": "03eec812fd6ae948664ff51b4320785f6d15ee5d" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/laracasts/flash/zipball/03eec812fd6ae948664ff51b4320785f6d15ee5d", + "reference": "03eec812fd6ae948664ff51b4320785f6d15ee5d", + "shasum": "" + }, + "require": { + "illuminate/support": "~5.0", + "php": ">=5.4.0" + }, + "require-dev": { + "mockery/mockery": "dev-master" + }, + "type": "library", + "autoload": { + "psr-0": { + "Laracasts\\Flash": "src/" + }, + "files": [ + "src/Laracasts/Flash/functions.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Jeffrey Way", + "email": "jeffrey@laracasts.com" + } + ], + "description": "Easy flash notifications", + "time": "2016-07-11T20:46:02+00:00" + }, + { "name": "laravel/browser-kit-testing", "version": "v1.0.3", "source": { @@ -347,16 +444,16 @@ }, { "name": "league/flysystem", - "version": "1.0.37", + "version": "1.0.39", "source": { "type": "git", "url": "https://github.com/thephpleague/flysystem.git", - "reference": "78b5cc4feb61a882302df4fbaf63b7662e5e4ccd" + "reference": "2474325ee924134bb05848663b12531f6f2e9fbe" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/thephpleague/flysystem/zipball/78b5cc4feb61a882302df4fbaf63b7662e5e4ccd", - "reference": "78b5cc4feb61a882302df4fbaf63b7662e5e4ccd", + "url": "https://api.github.com/repos/thephpleague/flysystem/zipball/2474325ee924134bb05848663b12531f6f2e9fbe", + "reference": "2474325ee924134bb05848663b12531f6f2e9fbe", "shasum": "" }, "require": { @@ -378,12 +475,12 @@ "league/flysystem-azure": "Allows you to use Windows Azure Blob storage", "league/flysystem-cached-adapter": "Flysystem adapter decorator for metadata caching", "league/flysystem-copy": "Allows you to use Copy.com storage", - "league/flysystem-dropbox": "Allows you to use Dropbox storage", "league/flysystem-eventable-filesystem": "Allows you to use EventableFilesystem", "league/flysystem-rackspace": "Allows you to use Rackspace Cloud Files", "league/flysystem-sftp": "Allows you to use SFTP server storage via phpseclib", "league/flysystem-webdav": "Allows you to use WebDAV storage", - "league/flysystem-ziparchive": "Allows you to use ZipArchive adapter" + "league/flysystem-ziparchive": "Allows you to use ZipArchive adapter", + "spatie/flysystem-dropbox": "Allows you to use Dropbox storage" }, "type": "library", "extra": { @@ -426,7 +523,7 @@ "sftp", "storage" ], - "time": "2017-03-22T15:43:14+00:00" + "time": "2017-04-25T15:24:43+00:00" }, { "name": "luthfi/formfield", @@ -469,6 +566,67 @@ "time": "2017-04-22T13:49:25+00:00" }, { + "name": "maximebf/debugbar", + "version": "1.13.1", + "source": { + "type": "git", + "url": "https://github.com/maximebf/php-debugbar.git", + "reference": "afee79a236348e39a44cb837106b7c5b4897ac2a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/maximebf/php-debugbar/zipball/afee79a236348e39a44cb837106b7c5b4897ac2a", + "reference": "afee79a236348e39a44cb837106b7c5b4897ac2a", + "shasum": "" + }, + "require": { + "php": ">=5.3.0", + "psr/log": "^1.0", + "symfony/var-dumper": "^2.6|^3.0" + }, + "require-dev": { + "phpunit/phpunit": "^4.0|^5.0" + }, + "suggest": { + "kriswallsmith/assetic": "The best way to manage assets", + "monolog/monolog": "Log using Monolog", + "predis/predis": "Redis storage" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.13-dev" + } + }, + "autoload": { + "psr-4": { + "DebugBar\\": "src/DebugBar/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Maxime Bouroumeau-Fuseau", + "email": "maxime.bouroumeau@gmail.com", + "homepage": "http://maximebf.com" + }, + { + "name": "Barry vd. Heuvel", + "email": "barryvdh@gmail.com" + } + ], + "description": "Debug bar in the browser for php application", + "homepage": "https://github.com/maximebf/php-debugbar", + "keywords": [ + "debug", + "debugbar" + ], + "time": "2017-01-05T08:46:19+00:00" + }, + { "name": "monolog/monolog", "version": "1.22.1", "source": { diff --git a/config/app.php b/config/app.php index 448b4e6..64cd1bc 100644 --- a/config/app.php +++ b/config/app.php @@ -167,6 +167,8 @@ return [ * Package Service Providers... */ Luthfi\FormField\FormFieldServiceProvider::class, + Barryvdh\Debugbar\ServiceProvider::class, + Laracasts\Flash\FlashServiceProvider::class, /* * Application Service Providers... diff --git a/storage/debugbar/.gitignore b/storage/debugbar/.gitignore new file mode 100644 index 0000000..c96a04f --- /dev/null +++ b/storage/debugbar/.gitignore @@ -0,0 +1,2 @@ +* +!.gitignore \ No newline at end of file diff --git a/tests/Feature/TransactionEntryTest.php b/tests/Feature/TransactionEntryTest.php index d9f27a2..69d602b 100644 --- a/tests/Feature/TransactionEntryTest.php +++ b/tests/Feature/TransactionEntryTest.php @@ -195,8 +195,55 @@ class TransactionEntryTest extends BrowserKitTestCase $this->seePageIs(route('cart.show', [$draft->draftKey, 'action' => 'confirm'])); $this->see(trans('transaction.confirm')); + $this->see($draft->customer['name']); + $this->see($draft->customer['phone']); + $this->see($draft->notes); $this->see(formatRp(10000)); $this->see(formatRp(3000)); $this->seeElement('input', ['id' => 'save-transaction-draft']); } + + /** @test */ + public function user_can_save_transaction_if_draft_is_completed() + { + $cart = new CartCollection(); + + $draft = $cart->add(new CashDraft()); + + $product1 = factory(Product::class)->create(['cash_price' => 1000]); + $product2 = factory(Product::class)->create(['cash_price' => 2000]); + $item1 = new Item($product1, 1); + $item2 = new Item($product2, 3); + + // Add items to draft + $cart->addItemToDraft($draft->draftKey, $item1); + $cart->addItemToDraft($draft->draftKey, $item2); + + $draftAttributes = [ + 'customer' => [ + 'name' => 'Nafies', + 'phone' => '081234567890', + ], + 'payment' => 10000, + 'notes' => 'Catatan', + ]; + $cart->updateDraftAttributes($draft->draftKey, $draftAttributes); + + $user = $this->loginAsUser(); + $this->visit(route('cart.show', [$draft->draftKey, 'action' => 'confirm'])); + + $this->press(trans('transaction.save')); + + $this->seePageIs(route('cart.index')); + + $this->seeInDatabase('transactions', [ + 'invoice_no' => date('ym') . '0001', + 'items' => '[{"id":' . $product1->id . ',"name":"' . $product1->name . '","price":1000,"qty":1,"item_discount":0,"item_discount_subtotal":0,"subtotal":1000},{"id":' . $product2->id . ',"name":"' . $product2->name . '","price":2000,"qty":3,"item_discount":0,"item_discount_subtotal":0,"subtotal":6000}]', + 'customer' => '{"name":"Nafies","phone":"081234567890"}', + 'payment' => 10000, + 'total' => 7000, + 'notes' => 'Catatan', + 'user_id' => $user->id, + ]); + } }