From 8b5def97563b142c4139d9c736fb20f73abcdc5e Mon Sep 17 00:00:00 2001 From: Herbert Maschke Date: Thu, 20 Feb 2020 11:56:07 +0100 Subject: [PATCH] introduce CartRuleCest.php --- .env.example | 2 +- bin/test.sh | 8 ++++ tests/functional/CartRule/CartRuleCest.php | 49 ++++++++++++++++++++++ 3 files changed, 58 insertions(+), 1 deletion(-) create mode 100644 tests/functional/CartRule/CartRuleCest.php diff --git a/.env.example b/.env.example index d09d2b8fd..e710496ca 100644 --- a/.env.example +++ b/.env.example @@ -19,7 +19,7 @@ DB_PREFIX= BROADCAST_DRIVER=log CACHE_DRIVER=file SESSION_DRIVER=file -SESSION_LIFETIME=20 +SESSION_LIFETIME=120 QUEUE_DRIVER=sync REDIS_HOST=127.0.0.1 diff --git a/bin/test.sh b/bin/test.sh index 6f82ff04a..bf7c9962d 100755 --- a/bin/test.sh +++ b/bin/test.sh @@ -15,6 +15,14 @@ printf "### start preparation ###\n" printf ">> truncate and migrate database\n" php artisan migrate:fresh --env=testing --quiet + printf ">> cleaning laravel caches ###\n" + ${WORKPATH}/../php artisan view:clear + ${WORKPATH}/../php artisan route:clear + ${WORKPATH}/../php artisan cache:clear + ${WORKPATH}/../php artisan config:clear + + printf ">> cleaning previous tests ###\n" + ${WORKPATH}/../vendor/bin/codecept clean printf "### finish preparation ###\n" printf "### start tests ###\n" diff --git a/tests/functional/CartRule/CartRuleCest.php b/tests/functional/CartRule/CartRuleCest.php new file mode 100644 index 000000000..18191ff9b --- /dev/null +++ b/tests/functional/CartRule/CartRuleCest.php @@ -0,0 +1,49 @@ +loginAsAdmin(); + + $I->amOnAdminRoute('admin.cart-rules.index'); + + // we are dealing with vue.js so we can not do classical form filling + $I->sendAjaxPostRequest(route('admin.cart-rules.store'), [ + '_token' => csrf_token(), + 'name' => 'Demo Cart Rule', + + // the following fields are important to send with the POST request: + 'starts_from' => '', + 'ends_till' => '', + + 'use_auto_generation' => 0, + 'coupon_type' => 0, // no coupon + 'action_type' => 'by_percent', + 'coupon_code' => 'coupon', + 'discount_amount' => '10', + + 'channels' => [ + 'default', + ], + + 'customer_groups' => [ + 'guest', + ], + ]); + + $cartRule = $I->grabRecord(CartRule::class, [ + 'name' => 'Demo Cart Rule', + ]); + + $I->seeResponseCodeIsSuccessful(); + + } +}