diff --git a/bin/codecept b/bin/codecept new file mode 120000 index 000000000..a43e3ac1e --- /dev/null +++ b/bin/codecept @@ -0,0 +1 @@ +../vendor/bin/codecept \ No newline at end of file diff --git a/bin/test.sh b/bin/test.sh new file mode 100755 index 000000000..499caa45d --- /dev/null +++ b/bin/test.sh @@ -0,0 +1,59 @@ +#!/bin/bash + +PROGRESS_REPORTER="--ext Codeception\\ProgressReporter\\ProgressReporter" + + while getopts ":c" arg; do + case $arg in + # c)lassic reporter + c) PROGRESS_REPORTER="";; + esac + done + +printf "### start preparation ###\n" + + WORKPATH=$(dirname ${0}) + printf ">> workpath is %s\n" ${WORKPATH} + + LOG_DIR="${WORKPATH}/../storage/logs/tests" + printf ">> log-dir is %s\n" ${LOG_DIR} + + printf ">> create and truncate log dir\n" + mkdir -p ${LOG_DIR} + rm -rf ${LOG_DIR}/* + + printf ">> truncate and migrate database\n" + php artisan migrate:fresh --env=testing --quiet + +printf "### finish preparation ###\n" + +printf "### start tests ###\n" + + SUCCESS=1 + execSuite() { + ${WORKPATH}/../vendor/bin/codecept run ${1} \ + ${PROGRESS_REPORTER} \ + --xml report_${1}.xml ${CODECEPT_OPTIONS} | tee ${LOG_DIR}/tests_${1}.log + if [[ ${PIPESTATUS[0]} -ne 0 ]] + then + SUCCESS=0 + fi + } + + execSuite unit + execSuite functional + + if [[ ${?} -ne 0 ]] + then + SUCCESS=0 + fi + +printf "### finish tests ###\n" + +if [[ ${SUCCESS} -eq 1 ]] +then + printf ">> all tests are \e[01;32mgreen\e[0m\n" + exit 0 +else + printf ">> at least one test is \e[01;31mred\e[0m\n" + exit 1 +fi diff --git a/composer.json b/composer.json index 31c9ed9d6..ca0b9f071 100755 --- a/composer.json +++ b/composer.json @@ -19,6 +19,7 @@ "ext-tokenizer": "*", "astrotomic/laravel-translatable": "^11.0.0", "barryvdh/laravel-dompdf": "0.8.3", + "codeception/codeception-progress-reporter": "^1.0", "doctrine/dbal": "2.9.2", "fideloper/proxy": "^4.0", "flynsarmy/db-blade-compiler": "*", diff --git a/tests/functional/Customer/CustomerCest.php b/tests/functional/Customer/CustomerCest.php new file mode 100644 index 000000000..f6b77dd56 --- /dev/null +++ b/tests/functional/Customer/CustomerCest.php @@ -0,0 +1,112 @@ +loginAsCustomer(); + + $I->amOnPage('/'); + + $I->click('Profile'); + + $I->click('Edit'); + + $I->selectOption('gender', 'Other'); + + $I->click('Update Profile'); + + $I->dontSeeInSource('The old password does not match.'); + + $I->seeInSource('Profile updated successfully.'); + + $I->seeRecord(Customer::class, [ + 'id' => $customer->id, + 'gender' => 'Other', + ]); + } + + public function updateCustomerAddress(FunctionalTester $I) + { + $faker = Faker\Factory::create(); + + $formCssSelector = '.account-layout > form:nth-child(2)'; + + $customer = $I->loginAsCustomer(); + + $I->amOnPage('/'); + + $I->click('Profile'); + + $I->click('Address'); + + $I->click('Add Address'); + + $fields = [ + 'company_name' => $faker->company, + 'address1[]' => $faker->streetAddress, + 'country' => $faker->countryCode, + 'state' => $faker->state, + 'city' => $faker->city, + 'postcode' => $faker->postcode, + 'phone' => $faker->phoneNumber, + ]; + + foreach ($fields as $key => $value) { + // the following fields are being rendered via javascript so we ignore them: + if (! in_array($key, [ + 'country', + 'state', + ])) { + $selector = 'input[name="' . $key . '"]'; + $I->fillField($selector, $value); + } + } + + $I->wantTo('Ensure that the company_name field is being displayed'); + $I->seeElement('.account-table-content > div:nth-child(2) > input:nth-child(2)'); + + // we need to use this css selector to hit the correct