diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index cebb06e16..e9812567b 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -58,4 +58,4 @@ Below is an example of a valid Bagisto doc block. Note that the @param attribute protected function registerFacades($loader, $concrete = null, $shared = false) { // - } \ No newline at end of file + } diff --git a/composer.json b/composer.json index 436cc38bd..ae4374109 100755 --- a/composer.json +++ b/composer.json @@ -21,7 +21,7 @@ "barryvdh/laravel-dompdf": "0.8.5", "doctrine/dbal": "2.9.2", "fideloper/proxy": "^4.0", - "flynsarmy/db-blade-compiler": "*", + "flynsarmy/db-blade-compiler": "^5.5", "guzzlehttp/guzzle": "~6.0", "intervention/image": "^2.4", "intervention/imagecache": "^2.3", @@ -33,21 +33,20 @@ "maatwebsite/excel": "3.1.18", "nwidart/laravel-modules": "^3.2", "prettus/l5-repository": "^2.6", - "tymon/jwt-auth": "^1.0.0", - "barryvdh/laravel-debugbar": "^3.1", - "fzaninotto/faker": "^1.4" + "tymon/jwt-auth": "^1.0.0" }, "require-dev": { - "codeception/codeception": "^4.0", + "codeception/codeception": "4.1.1", "codeception/module-asserts": "^1.1", "codeception/module-filesystem": "^1.0", "codeception/module-laravel5": "^1.0", "filp/whoops": "^2.0", - "laravel/dusk": "^5.7.0", "mockery/mockery": "^1.0", "nunomaduro/collision": "^2.0", - "phpunit/phpunit": "^7.0" + "phpunit/phpunit": "^7.0", + "barryvdh/laravel-debugbar": "^3.1", + "fzaninotto/faker": "^1.4" }, "replace": { diff --git a/composer.lock b/composer.lock index ba873b5cd..fbf4257d3 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "2e158f9cd141beb41f6bc0dd7ee82767", + "content-hash": "dca322023597f38ef7991bc9d9bdc50f", "packages": [ { "name": "astrotomic/laravel-translatable", @@ -71,74 +71,6 @@ ], "time": "2020-03-03T10:43:26+00:00" }, - { - "name": "barryvdh/laravel-debugbar", - "version": "v3.2.9", - "source": { - "type": "git", - "url": "https://github.com/barryvdh/laravel-debugbar.git", - "reference": "42d5da5379a7860093f8e4032167e4cb5ebec180" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/barryvdh/laravel-debugbar/zipball/42d5da5379a7860093f8e4032167e4cb5ebec180", - "reference": "42d5da5379a7860093f8e4032167e4cb5ebec180", - "shasum": "" - }, - "require": { - "illuminate/routing": "^5.5|^6|^7", - "illuminate/session": "^5.5|^6|^7", - "illuminate/support": "^5.5|^6|^7", - "maximebf/debugbar": "^1.15.1", - "php": ">=7.0", - "symfony/debug": "^3|^4|^5", - "symfony/finder": "^3|^4|^5" - }, - "require-dev": { - "laravel/framework": "5.5.x" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "3.2-dev" - }, - "laravel": { - "providers": [ - "Barryvdh\\Debugbar\\ServiceProvider" - ], - "aliases": { - "Debugbar": "Barryvdh\\Debugbar\\Facade" - } - } - }, - "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": "2020-02-25T20:42:23+00:00" - }, { "name": "barryvdh/laravel-dompdf", "version": "v0.8.5", @@ -887,56 +819,6 @@ ], "time": "2019-07-28T22:19:29+00:00" }, - { - "name": "fzaninotto/faker", - "version": "v1.9.1", - "source": { - "type": "git", - "url": "https://github.com/fzaninotto/Faker.git", - "reference": "fc10d778e4b84d5bd315dad194661e091d307c6f" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/fzaninotto/Faker/zipball/fc10d778e4b84d5bd315dad194661e091d307c6f", - "reference": "fc10d778e4b84d5bd315dad194661e091d307c6f", - "shasum": "" - }, - "require": { - "php": "^5.3.3 || ^7.0" - }, - "require-dev": { - "ext-intl": "*", - "phpunit/phpunit": "^4.8.35 || ^5.7", - "squizlabs/php_codesniffer": "^2.9.2" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.9-dev" - } - }, - "autoload": { - "psr-4": { - "Faker\\": "src/Faker/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "François Zaninotto" - } - ], - "description": "Faker is a PHP library that generates fake data for you.", - "keywords": [ - "data", - "faker", - "fixtures" - ], - "time": "2019-12-12T13:22:17+00:00" - }, { "name": "guzzlehttp/guzzle", "version": "6.5.2", @@ -1457,33 +1339,33 @@ }, { "name": "konekt/concord", - "version": "1.4.0", + "version": "1.5.0", "source": { "type": "git", "url": "https://github.com/artkonekt/concord.git", - "reference": "3d13628d45253e1fafe3567729338545a10da047" + "reference": "2d9f7080c35636c0c7b94bb614d1e50942088061" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/artkonekt/concord/zipball/3d13628d45253e1fafe3567729338545a10da047", - "reference": "3d13628d45253e1fafe3567729338545a10da047", + "url": "https://api.github.com/repos/artkonekt/concord/zipball/2d9f7080c35636c0c7b94bb614d1e50942088061", + "reference": "2d9f7080c35636c0c7b94bb614d1e50942088061", "shasum": "" }, "require": { - "illuminate/console": "~5.5|~6.0", - "illuminate/support": "~5.5|~6.0", + "illuminate/console": "~5.5|~6.0|~7.0", + "illuminate/support": "~5.5|~6.0|~7.0", "konekt/enum": "~2.1", "konekt/enum-eloquent": "^1.3.1", - "php": "^7.1.3" + "php": "^7.2" }, "require-dev": { - "orchestra/testbench": "^3.4.2|~4.9", - "phpunit/phpunit": "6.0 - 7.5|~8.0" + "orchestra/testbench": "~3.5|~4.0|~5.0", + "phpunit/phpunit": "6.0 - 7.5|~8.0|~9.0" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.4-dev" + "dev-master": "1.5-dev" }, "laravel": { "providers": [ @@ -1514,7 +1396,7 @@ } ], "description": "Concord is a Laravel Extension for building modular Laravel Applications", - "time": "2019-11-17T10:30:36+00:00" + "time": "2020-03-13T16:50:52+00:00" }, { "name": "konekt/enum", @@ -2021,16 +1903,16 @@ }, { "name": "league/flysystem", - "version": "1.0.63", + "version": "1.0.65", "source": { "type": "git", "url": "https://github.com/thephpleague/flysystem.git", - "reference": "8132daec326565036bc8e8d1876f77ec183a7bd6" + "reference": "8f17b3ba67097aafb8318cd5c553b1acf7c891c8" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/thephpleague/flysystem/zipball/8132daec326565036bc8e8d1876f77ec183a7bd6", - "reference": "8132daec326565036bc8e8d1876f77ec183a7bd6", + "url": "https://api.github.com/repos/thephpleague/flysystem/zipball/8f17b3ba67097aafb8318cd5c553b1acf7c891c8", + "reference": "8f17b3ba67097aafb8318cd5c553b1acf7c891c8", "shasum": "" }, "require": { @@ -2042,7 +1924,7 @@ }, "require-dev": { "phpspec/phpspec": "^3.4", - "phpunit/phpunit": "^5.7.10" + "phpunit/phpunit": "^5.7.26" }, "suggest": { "ext-fileinfo": "Required for MimeType", @@ -2101,7 +1983,7 @@ "sftp", "storage" ], - "time": "2020-01-04T16:30:31+00:00" + "time": "2020-03-08T18:53:20+00:00" }, { "name": "maatwebsite/excel", @@ -2172,30 +2054,30 @@ }, { "name": "markbaker/complex", - "version": "1.4.7", + "version": "1.4.8", "source": { "type": "git", "url": "https://github.com/MarkBaker/PHPComplex.git", - "reference": "1ea674a8308baf547cbcbd30c5fcd6d301b7c000" + "reference": "8eaa40cceec7bf0518187530b2e63871be661b72" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/MarkBaker/PHPComplex/zipball/1ea674a8308baf547cbcbd30c5fcd6d301b7c000", - "reference": "1ea674a8308baf547cbcbd30c5fcd6d301b7c000", + "url": "https://api.github.com/repos/MarkBaker/PHPComplex/zipball/8eaa40cceec7bf0518187530b2e63871be661b72", + "reference": "8eaa40cceec7bf0518187530b2e63871be661b72", "shasum": "" }, "require": { "php": "^5.6.0|^7.0.0" }, "require-dev": { - "dealerdirect/phpcodesniffer-composer-installer": "^0.4.3", - "phpcompatibility/php-compatibility": "^8.0", + "dealerdirect/phpcodesniffer-composer-installer": "^0.5.0", + "phpcompatibility/php-compatibility": "^9.0", "phpdocumentor/phpdocumentor": "2.*", "phploc/phploc": "2.*", "phpmd/phpmd": "2.*", "phpunit/phpunit": "^4.8.35|^5.4.0", "sebastian/phpcpd": "2.*", - "squizlabs/php_codesniffer": "^3.3.0" + "squizlabs/php_codesniffer": "^3.4.0" }, "type": "library", "autoload": { @@ -2263,7 +2145,7 @@ "complex", "mathematics" ], - "time": "2018-10-13T23:28:42+00:00" + "time": "2020-03-11T20:15:49+00:00" }, { "name": "markbaker/matrix", @@ -2334,67 +2216,6 @@ ], "time": "2019-10-06T11:29:25+00:00" }, - { - "name": "maximebf/debugbar", - "version": "v1.16.1", - "source": { - "type": "git", - "url": "https://github.com/maximebf/php-debugbar.git", - "reference": "58998b818c6567fac01e35b8a4b70c1a64530556" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/maximebf/php-debugbar/zipball/58998b818c6567fac01e35b8a4b70c1a64530556", - "reference": "58998b818c6567fac01e35b8a4b70c1a64530556", - "shasum": "" - }, - "require": { - "php": "^7.1", - "psr/log": "^1.0", - "symfony/var-dumper": "^2.6|^3|^4|^5" - }, - "require-dev": { - "phpunit/phpunit": "^5" - }, - "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.16-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": "2019-11-24T09:46:11+00:00" - }, { "name": "monolog/monolog", "version": "2.0.2", @@ -3064,26 +2885,27 @@ }, { "name": "prettus/l5-repository", - "version": "2.6.41", + "version": "2.6.42", "source": { "type": "git", "url": "https://github.com/andersao/l5-repository.git", - "reference": "363904bd1d01325223197d3de1ea3f6fc9da2a06" + "reference": "24c473c08ab46759a2ebe8bb1ec6de1d7c9e9d1e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/andersao/l5-repository/zipball/363904bd1d01325223197d3de1ea3f6fc9da2a06", - "reference": "363904bd1d01325223197d3de1ea3f6fc9da2a06", + "url": "https://api.github.com/repos/andersao/l5-repository/zipball/24c473c08ab46759a2ebe8bb1ec6de1d7c9e9d1e", + "reference": "24c473c08ab46759a2ebe8bb1ec6de1d7c9e9d1e", "shasum": "" }, "require": { - "illuminate/config": "~5.0|~6.0", - "illuminate/console": "~5.0|~6.0", - "illuminate/database": "~5.0|~6.0", - "illuminate/filesystem": "~5.0|~6.0", - "illuminate/http": "~5.0|~6.0", - "illuminate/pagination": "~5.0|~6.0", - "illuminate/support": "~5.0|~6.0", + "illuminate/config": "~5.0|~6.0|~7.0", + "illuminate/console": "~5.0|~6.0|~7.0", + "illuminate/database": "~5.0|~6.0|~7.0", + "illuminate/filesystem": "~5.0|~6.0|~7.0", + "illuminate/http": "~5.0|~6.0|~7.0", + "illuminate/pagination": "~5.0|~6.0|~7.0", + "illuminate/support": "~5.0|~6.0|~7.0", + "illuminate/validation": "~5.0|~6.0|~7.0", "prettus/laravel-validation": "~1.1|~1.2" }, "suggest": { @@ -3125,25 +2947,25 @@ "model", "repository" ], - "time": "2020-02-05T06:48:26+00:00" + "time": "2020-03-14T18:53:21+00:00" }, { "name": "prettus/laravel-validation", - "version": "1.2.0", + "version": "1.2.2", "source": { "type": "git", "url": "https://github.com/andersao/laravel-validator.git", - "reference": "5ffa053baae31d11fa34da013b940d85c99ba253" + "reference": "3d43037c2f497df3f8fbf3d8c16954a83c72e530" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/andersao/laravel-validator/zipball/5ffa053baae31d11fa34da013b940d85c99ba253", - "reference": "5ffa053baae31d11fa34da013b940d85c99ba253", + "url": "https://api.github.com/repos/andersao/laravel-validator/zipball/3d43037c2f497df3f8fbf3d8c16954a83c72e530", + "reference": "3d43037c2f497df3f8fbf3d8c16954a83c72e530", "shasum": "" }, "require": { - "illuminate/support": "~5.4|^6.0", - "illuminate/validation": "~5.4|^6.0", + "illuminate/support": "~5.4|^6.0|^7.0", + "illuminate/validation": "~5.4|^6.0|^7.0", "php": ">=5.4.0" }, "type": "library", @@ -3168,7 +2990,7 @@ "service", "validation" ], - "time": "2019-09-11T12:19:42+00:00" + "time": "2020-03-14T19:28:36+00:00" }, { "name": "psr/container", @@ -4043,16 +3865,16 @@ }, { "name": "symfony/finder", - "version": "v4.4.3", + "version": "v4.4.5", "source": { "type": "git", "url": "https://github.com/symfony/finder.git", - "reference": "3a50be43515590faf812fbd7708200aabc327ec3" + "reference": "ea69c129aed9fdeca781d4b77eb20b62cf5d5357" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/finder/zipball/3a50be43515590faf812fbd7708200aabc327ec3", - "reference": "3a50be43515590faf812fbd7708200aabc327ec3", + "url": "https://api.github.com/repos/symfony/finder/zipball/ea69c129aed9fdeca781d4b77eb20b62cf5d5357", + "reference": "ea69c129aed9fdeca781d4b77eb20b62cf5d5357", "shasum": "" }, "require": { @@ -4088,7 +3910,7 @@ ], "description": "Symfony Finder Component", "homepage": "https://symfony.com", - "time": "2020-01-04T13:00:46+00:00" + "time": "2020-02-14T07:42:58+00:00" }, { "name": "symfony/http-foundation", @@ -5273,16 +5095,16 @@ }, { "name": "vlucas/phpdotenv", - "version": "v3.6.0", + "version": "v3.6.1", "source": { "type": "git", "url": "https://github.com/vlucas/phpdotenv.git", - "reference": "1bdf24f065975594f6a117f0f1f6cabf1333b156" + "reference": "8f7961f7b9deb3b432452c18093cf16f88205902" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/vlucas/phpdotenv/zipball/1bdf24f065975594f6a117f0f1f6cabf1333b156", - "reference": "1bdf24f065975594f6a117f0f1f6cabf1333b156", + "url": "https://api.github.com/repos/vlucas/phpdotenv/zipball/8f7961f7b9deb3b432452c18093cf16f88205902", + "reference": "8f7961f7b9deb3b432452c18093cf16f88205902", "shasum": "" }, "require": { @@ -5291,8 +5113,12 @@ "symfony/polyfill-ctype": "^1.9" }, "require-dev": { + "ext-filter": "*", "phpunit/phpunit": "^4.8.35 || ^5.0 || ^6.0 || ^7.0" }, + "suggest": { + "ext-filter": "Required to use the boolean validator." + }, "type": "library", "extra": { "branch-alias": { @@ -5326,10 +5152,78 @@ "env", "environment" ], - "time": "2019-09-10T21:37:39+00:00" + "time": "2020-03-12T13:44:00+00:00" } ], "packages-dev": [ + { + "name": "barryvdh/laravel-debugbar", + "version": "v3.2.9", + "source": { + "type": "git", + "url": "https://github.com/barryvdh/laravel-debugbar.git", + "reference": "42d5da5379a7860093f8e4032167e4cb5ebec180" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/barryvdh/laravel-debugbar/zipball/42d5da5379a7860093f8e4032167e4cb5ebec180", + "reference": "42d5da5379a7860093f8e4032167e4cb5ebec180", + "shasum": "" + }, + "require": { + "illuminate/routing": "^5.5|^6|^7", + "illuminate/session": "^5.5|^6|^7", + "illuminate/support": "^5.5|^6|^7", + "maximebf/debugbar": "^1.15.1", + "php": ">=7.0", + "symfony/debug": "^3|^4|^5", + "symfony/finder": "^3|^4|^5" + }, + "require-dev": { + "laravel/framework": "5.5.x" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.2-dev" + }, + "laravel": { + "providers": [ + "Barryvdh\\Debugbar\\ServiceProvider" + ], + "aliases": { + "Debugbar": "Barryvdh\\Debugbar\\Facade" + } + } + }, + "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": "2020-02-25T20:42:23+00:00" + }, { "name": "behat/gherkin", "version": "v4.6.1", @@ -5916,6 +5810,56 @@ ], "time": "2020-01-15T10:00:00+00:00" }, + { + "name": "fzaninotto/faker", + "version": "v1.9.1", + "source": { + "type": "git", + "url": "https://github.com/fzaninotto/Faker.git", + "reference": "fc10d778e4b84d5bd315dad194661e091d307c6f" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/fzaninotto/Faker/zipball/fc10d778e4b84d5bd315dad194661e091d307c6f", + "reference": "fc10d778e4b84d5bd315dad194661e091d307c6f", + "shasum": "" + }, + "require": { + "php": "^5.3.3 || ^7.0" + }, + "require-dev": { + "ext-intl": "*", + "phpunit/phpunit": "^4.8.35 || ^5.7", + "squizlabs/php_codesniffer": "^2.9.2" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.9-dev" + } + }, + "autoload": { + "psr-4": { + "Faker\\": "src/Faker/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "François Zaninotto" + } + ], + "description": "Faker is a PHP library that generates fake data for you.", + "keywords": [ + "data", + "faker", + "fixtures" + ], + "time": "2019-12-12T13:22:17+00:00" + }, { "name": "hamcrest/hamcrest-php", "version": "v2.0.0", @@ -5965,53 +5909,41 @@ "time": "2016-01-20T08:20:44+00:00" }, { - "name": "laravel/dusk", - "version": "v5.9.2", + "name": "maximebf/debugbar", + "version": "v1.16.1", "source": { "type": "git", - "url": "https://github.com/laravel/dusk.git", - "reference": "7abf5a7152863f8597a43d640cce3adb6cd8ab3f" + "url": "https://github.com/maximebf/php-debugbar.git", + "reference": "58998b818c6567fac01e35b8a4b70c1a64530556" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laravel/dusk/zipball/7abf5a7152863f8597a43d640cce3adb6cd8ab3f", - "reference": "7abf5a7152863f8597a43d640cce3adb6cd8ab3f", + "url": "https://api.github.com/repos/maximebf/php-debugbar/zipball/58998b818c6567fac01e35b8a4b70c1a64530556", + "reference": "58998b818c6567fac01e35b8a4b70c1a64530556", "shasum": "" }, "require": { - "ext-json": "*", - "ext-zip": "*", - "illuminate/console": "~5.7.0|~5.8.0|^6.0|^7.0", - "illuminate/support": "~5.7.0|~5.8.0|^6.0|^7.0", - "nesbot/carbon": "^1.20|^2.0", - "php": ">=7.1.0", - "php-webdriver/webdriver": "^1.8.1", - "symfony/console": "^4.0|^5.0", - "symfony/finder": "^4.0|^5.0", - "symfony/process": "^4.0|^5.0", - "vlucas/phpdotenv": "^2.2|^3.0|^4.0" + "php": "^7.1", + "psr/log": "^1.0", + "symfony/var-dumper": "^2.6|^3|^4|^5" }, "require-dev": { - "mockery/mockery": "^1.0", - "phpunit/phpunit": "^7.5|^8.0" + "phpunit/phpunit": "^5" }, "suggest": { - "ext-pcntl": "Used to gracefully terminate Dusk when tests are running." + "kriswallsmith/assetic": "The best way to manage assets", + "monolog/monolog": "Log using Monolog", + "predis/predis": "Redis storage" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "5.0-dev" - }, - "laravel": { - "providers": [ - "Laravel\\Dusk\\DuskServiceProvider" - ] + "dev-master": "1.16-dev" } }, "autoload": { "psr-4": { - "Laravel\\Dusk\\": "src/" + "DebugBar\\": "src/DebugBar/" } }, "notification-url": "https://packagist.org/downloads/", @@ -6020,82 +5952,22 @@ ], "authors": [ { - "name": "Taylor Otwell", - "email": "taylor@laravel.com" - } - ], - "description": "Laravel Dusk provides simple end-to-end testing and browser automation.", - "keywords": [ - "laravel", - "testing", - "webdriver" - ], - "time": "2020-02-18T19:13:12+00:00" - }, - { - "name": "league/commonmark-ext-table", - "version": "v2.1.0", - "source": { - "type": "git", - "url": "https://github.com/thephpleague/commonmark-ext-table.git", - "reference": "3228888ea69636e855efcf6636ff8e6316933fe7" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/thephpleague/commonmark-ext-table/zipball/3228888ea69636e855efcf6636ff8e6316933fe7", - "reference": "3228888ea69636e855efcf6636ff8e6316933fe7", - "shasum": "" - }, - "require": { - "league/commonmark": "~0.19.3|^1.0", - "php": "^7.1" - }, - "require-dev": { - "friendsofphp/php-cs-fixer": "^2.14", - "phpstan/phpstan": "~0.11", - "phpunit/phpunit": "^7.0|^8.0", - "symfony/var-dumper": "^4.0", - "vimeo/psalm": "^3.0" - }, - "type": "commonmark-extension", - "extra": { - "branch-alias": { - "dev-master": "2.2-dev" - } - }, - "autoload": { - "psr-4": { - "League\\CommonMark\\Ext\\Table\\": "src" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Martin Hasoň", - "email": "martin.hason@gmail.com" + "name": "Maxime Bouroumeau-Fuseau", + "email": "maxime.bouroumeau@gmail.com", + "homepage": "http://maximebf.com" }, { - "name": "Webuni s.r.o.", - "homepage": "https://www.webuni.cz" - }, - { - "name": "Colin O'Dell", - "email": "colinodell@gmail.com", - "homepage": "https://www.colinodell.com" + "name": "Barry vd. Heuvel", + "email": "barryvdh@gmail.com" } ], - "description": "Table extension for league/commonmark", - "homepage": "https://github.com/thephpleague/commonmark-ext-table", + "description": "Debug bar in the browser for php application", + "homepage": "https://github.com/maximebf/php-debugbar", "keywords": [ - "commonmark", - "extension", - "markdown", - "table" + "debug", + "debugbar" ], - "time": "2019-09-26T13:28:33+00:00" + "time": "2019-11-24T09:46:11+00:00" }, { "name": "mockery/mockery", @@ -6376,71 +6248,6 @@ "description": "Library for handling version information and constraints", "time": "2018-07-08T19:19:57+00:00" }, - { - "name": "php-webdriver/webdriver", - "version": "1.8.2", - "source": { - "type": "git", - "url": "https://github.com/php-webdriver/php-webdriver.git", - "reference": "3308a70be084d6d7fd1ee5787b4c2e6eb4b70aab" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/php-webdriver/php-webdriver/zipball/3308a70be084d6d7fd1ee5787b4c2e6eb4b70aab", - "reference": "3308a70be084d6d7fd1ee5787b4c2e6eb4b70aab", - "shasum": "" - }, - "require": { - "ext-curl": "*", - "ext-json": "*", - "ext-zip": "*", - "php": "^5.6 || ~7.0", - "symfony/polyfill-mbstring": "^1.12", - "symfony/process": "^2.8 || ^3.1 || ^4.0 || ^5.0" - }, - "require-dev": { - "friendsofphp/php-cs-fixer": "^2.0", - "jakub-onderka/php-parallel-lint": "^1.0", - "php-coveralls/php-coveralls": "^2.0", - "php-mock/php-mock-phpunit": "^1.1", - "phpunit/phpunit": "^5.7", - "sebastian/environment": "^1.3.4 || ^2.0 || ^3.0", - "sminnee/phpunit-mock-objects": "^3.4", - "squizlabs/php_codesniffer": "^3.5", - "symfony/var-dumper": "^3.3 || ^4.0 || ^5.0" - }, - "suggest": { - "ext-SimpleXML": "For Firefox profile creation" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.8.x-dev" - } - }, - "autoload": { - "psr-4": { - "Facebook\\WebDriver\\": "lib/" - }, - "files": [ - "lib/Exception/TimeoutException.php" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "description": "A PHP client for Selenium WebDriver. Previously facebook/webdriver.", - "homepage": "https://github.com/php-webdriver/php-webdriver", - "keywords": [ - "Chromedriver", - "geckodriver", - "php", - "selenium", - "webdriver" - ], - "time": "2020-03-04T14:40:12+00:00" - }, { "name": "phpdocumentor/reflection-common", "version": "2.0.0", diff --git a/packages/Webkul/API/Http/Resources/Sales/Order.php b/packages/Webkul/API/Http/Resources/Sales/Order.php index 325fc5873..0ef36e52a 100644 --- a/packages/Webkul/API/Http/Resources/Sales/Order.php +++ b/packages/Webkul/API/Http/Resources/Sales/Order.php @@ -11,7 +11,8 @@ class Order extends JsonResource /** * Transform the resource into an array. * - * @param \Illuminate\Http\Request + * @param \Illuminate\Http\Request + * * @return array */ public function toArray($request) @@ -103,7 +104,7 @@ class Order extends JsonResource 'items' => OrderItem::collection($this->items), 'invoices' => Invoice::collection($this->invoices), 'shipments' => Shipment::collection($this->shipments), - 'created_at' => $this->created_at + 'created_at' => $this->created_at, ]; } } \ No newline at end of file diff --git a/packages/Webkul/Checkout/src/Cart.php b/packages/Webkul/Checkout/src/Cart.php index 48d54672e..c547ca694 100755 --- a/packages/Webkul/Checkout/src/Cart.php +++ b/packages/Webkul/Checkout/src/Cart.php @@ -2,6 +2,7 @@ namespace Webkul\Checkout; +use Webkul\Checkout\Models\CartAddress; use Webkul\Checkout\Repositories\CartRepository; use Webkul\Checkout\Repositories\CartItemRepository; use Webkul\Checkout\Repositories\CartAddressRepository; @@ -141,7 +142,7 @@ class Cart if (is_string($cartProducts)) { $this->collectTotals(); - if (! count($cart->all_items) > 0) { + if (count($cart->all_items) <= 0) { session()->forget('cart'); } @@ -340,6 +341,7 @@ class Cart $guestCart = session()->get('cart'); + //when the logged in customer is not having any of the cart instance previously and are active. if (! $cart) { $this->cartRepository->update([ 'customer_id' => $this->getCurrentCustomer()->user()->id, @@ -358,7 +360,11 @@ class Cart $found = false; foreach ($cart->items as $cartItem) { - if (! $cartItem->product->getTypeInstance()->compareOptions($cartItem->additional, $guestCartItem->additional)) { + if (! $cartItem + ->product + ->getTypeInstance() + ->compareOptions($cartItem->additional, $guestCartItem->additional) + ) { continue; } @@ -471,110 +477,25 @@ class Cart /** * Save customer address * - * @param array $data - * @return bool + * @param array $data + * + * @return void is the cart valid */ - public function saveCustomerAddress($data) + public function saveCustomerAddress($data): bool { if (! $cart = $this->getCart()) { return false; } - $billingAddress = $data['billing']; - $billingAddress['cart_id'] = $cart->id; + $billingAddressData = $this->gatherBillingAddress($data, $cart); - if (isset($data['billing']['address_id']) && $data['billing']['address_id']) { - $address = $this->customerAddressRepository->findOneWhere(['id' => $data['billing']['address_id']])->toArray(); + $shippingAddressData = $this->gatherShippingAddress($data, $cart); - $billingAddress['first_name'] = $this->getCurrentCustomer()->user()->first_name; - $billingAddress['last_name'] = $this->getCurrentCustomer()->user()->last_name; - $billingAddress['email'] = $this->getCurrentCustomer()->user()->email; - $billingAddress['address1'] = $address['address1']; - $billingAddress['country'] = $address['country']; - $billingAddress['state'] = $address['state']; - $billingAddress['city'] = $address['city']; - $billingAddress['postcode'] = $address['postcode']; - $billingAddress['phone'] = $address['phone']; - } + $this->saveAddressesWhenRequested($data, $billingAddressData, $shippingAddressData); - if (isset($data['billing']['save_as_address']) && $data['billing']['save_as_address']) { - $billingAddress['customer_id'] = $this->getCurrentCustomer()->user()->id; + $this->linkAddresses($cart, $billingAddressData, $shippingAddressData); - $this->customerAddressRepository->create($billingAddress); - } - - if ($cart->haveStockableItems()) { - $shippingAddress = $data['shipping']; - $shippingAddress['cart_id'] = $cart->id; - - if (isset($data['shipping']['address_id']) && $data['shipping']['address_id']) { - $address = $this->customerAddressRepository->findOneWhere(['id' => $data['shipping']['address_id']])->toArray(); - - $shippingAddress['first_name'] = $this->getCurrentCustomer()->user()->first_name; - $shippingAddress['last_name'] = $this->getCurrentCustomer()->user()->last_name; - $shippingAddress['email'] = $this->getCurrentCustomer()->user()->email; - $shippingAddress['address1'] = $address['address1']; - $shippingAddress['country'] = $address['country']; - $shippingAddress['state'] = $address['state']; - $shippingAddress['city'] = $address['city']; - $shippingAddress['postcode'] = $address['postcode']; - $shippingAddress['phone'] = $address['phone']; - } - - if (isset($data['shipping']['save_as_address']) && $data['shipping']['save_as_address']) { - $shippingAddress['customer_id'] = $this->getCurrentCustomer()->user()->id; - - $this->customerAddressRepository->create($shippingAddress); - } - } - - if ($billingAddressModel = $cart->billing_address) { - $this->cartAddressRepository->update($billingAddress, $billingAddressModel->id); - - if ($cart->haveStockableItems()) { - if ($shippingAddressModel = $cart->shipping_address) { - if (isset($billingAddress['use_for_shipping']) && $billingAddress['use_for_shipping']) { - $this->cartAddressRepository->update($billingAddress, $shippingAddressModel->id); - } else { - $this->cartAddressRepository->update($shippingAddress, $shippingAddressModel->id); - } - } else { - if (isset($billingAddress['use_for_shipping']) && $billingAddress['use_for_shipping']) { - $this->cartAddressRepository->create( - array_merge($billingAddress, ['address_type' => 'shipping']) - ); - } else { - $this->cartAddressRepository->create( - array_merge($shippingAddress, ['address_type' => 'shipping']) - ); - } - } - } - } else { - $this->cartAddressRepository->create(array_merge($billingAddress, ['address_type' => 'billing'])); - - if ($cart->haveStockableItems()) { - if (isset($billingAddress['use_for_shipping']) && $billingAddress['use_for_shipping']) { - $this->cartAddressRepository->create( - array_merge($billingAddress, ['address_type' => 'shipping']) - ); - } else { - $this->cartAddressRepository->create( - array_merge($shippingAddress, ['address_type' => 'shipping']) - ); - } - } - } - - if ($this->getCurrentCustomer()->check()) { - $cart->customer_email = $this->getCurrentCustomer()->user()->email; - $cart->customer_first_name = $this->getCurrentCustomer()->user()->first_name; - $cart->customer_last_name = $this->getCurrentCustomer()->user()->last_name; - } else { - $cart->customer_email = $cart->billing_address->email; - $cart->customer_first_name = $cart->billing_address->first_name; - $cart->customer_last_name = $cart->billing_address->last_name; - } + $this->assignCustomerFields($cart); $cart->save(); @@ -589,7 +510,7 @@ class Cart * @param string $shippingMethodCode * @return bool */ - public function saveShippingMethod($shippingMethodCode) + public function saveShippingMethod($shippingMethodCode): bool { if (! $cart = $this->getCart()) { return false; @@ -752,7 +673,7 @@ class Cart if ($address === null && auth()->guard('customer')->check()) { $address = auth()->guard('customer')->user()->addresses() - ->where('default_address',1)->first(); + ->where('default_address', 1)->first(); } if ($address === null) { @@ -791,7 +712,7 @@ class Cart $haveTaxRate = true; } } - + if ($haveTaxRate) { $item->tax_percent = $rate->tax_rate; $item->tax_amount = ($item->total * $rate->tax_rate) / 100; @@ -930,6 +851,7 @@ class Cart 'shipping_discount_amount' => $data['selected_shipping_rate']['discount_amount'], 'base_shipping_discount_amount' => $data['selected_shipping_rate']['base_discount_amount'], ]); + } foreach ($data['items'] as $item) { @@ -1009,7 +931,8 @@ class Cart } /** - * Function to move a already added product to wishlist will run only on customer authentication. + * Function to move a already added product to wishlist will run only on customer + * authentication. * * @param int $itemId * @return bool @@ -1095,4 +1018,200 @@ class Cart return $this; } + + /** + * Transfer the user profile information into the cart/into the order. + * + * When logged in as guest or the customer profile is not complete, we use the + * billing address to fill the order customer_ data. + * + * @param \Webkul\Checkout\Models\Cart $cart + */ + private function assignCustomerFields(\Webkul\Checkout\Models\Cart $cart): void + { + if ($this->getCurrentCustomer()->check() + && ($user = $this->getCurrentCustomer()->user()) + && $this->profileIsComplete($user) + ) { + $cart->customer_email = $user->email; + $cart->customer_first_name = $user->first_name; + $cart->customer_last_name = $user->last_name; + } else { + $cart->customer_email = $cart->billing_address->email; + $cart->customer_first_name = $cart->billing_address->first_name; + $cart->customer_last_name = $cart->billing_address->last_name; + } + } + + /** + * @param $user + * + * @return bool + */ + private function profileIsComplete($user): bool + { + return $user->email && $user->first_name && $user->last_name; + } + + /** + * @return array + */ + private function fillCustomerAttributes(): array + { + $attributes = []; + + $user = $this->getCurrentCustomer()->user(); + + if ($user) { + $attributes['first_name'] = $user->first_name; + $attributes['last_name'] = $user->last_name; + $attributes['email'] = $user->email; + $attributes['customer_id'] = $user->id; + } + + return $attributes; + } + + /** + * @return array + */ + private function fillAddressAttributes(array $addressAttributes): array + { + $attributes = []; + + $cartAddress = new CartAddress(); + + foreach ($cartAddress->getFillable() as $attribute) { + if (isset($addressAttributes[$attribute])) { + $attributes[$attribute] = $addressAttributes[$attribute]; + } + } + + return $attributes; + } + + /** + * @param array $data + * @param array $billingAddress + * @param array $shippingAddress + */ + private function saveAddressesWhenRequested( + array $data, + array $billingAddress, + array $shippingAddress + ): void + { + if (isset($data['billing']['save_as_address']) && $data['billing']['save_as_address']) { + $this->customerAddressRepository->create($billingAddress); + } + + if (isset($data['shipping']['save_as_address']) && $data['shipping']['save_as_address']) { + $this->customerAddressRepository->create($shippingAddress); + } + } + + /** + * @param $data + * @param $cart + * + * @return array + */ + private function gatherBillingAddress($data, \Webkul\Checkout\Models\Cart $cart): array + { + $customerAddress = []; + + if (isset($data['billing']['address_id']) && $data['billing']['address_id']) { + $customerAddress = $this + ->customerAddressRepository + ->findOneWhere(['id' => $data['billing']['address_id']]) + ->toArray(); + } + + $billingAddress = array_merge( + $customerAddress, + $data['billing'], + ['cart_id' => $cart->id], + $this->fillCustomerAttributes(), + $this->fillAddressAttributes($data['billing']) + ); + + + return $billingAddress; + } + + /** + * @param $data + * @param \Webkul\Checkout\Cart|null $cart + * + * @return array + */ + private function gatherShippingAddress($data, \Webkul\Checkout\Models\Cart $cart): array + { + $customerAddress = []; + + if (isset($data['shipping']['address_id']) && $data['shipping']['address_id']) { + $customerAddress = $this + ->customerAddressRepository + ->findOneWhere(['id' => $data['shipping']['address_id']]) + ->toArray(); + } + + $shippingAddress = array_merge( + $customerAddress, + $data['shipping'], + ['cart_id' => $cart->id], + $this->fillCustomerAttributes(), + $this->fillAddressAttributes($data['shipping']) + ); + + return $shippingAddress; + } + + /** + * @param \Webkul\Checkout\Cart|null $cart + * @param array $billingAddressData + * @param array $shippingAddressData + * + * @throws \Prettus\Validator\Exceptions\ValidatorException + */ + private function linkAddresses( + \Webkul\Checkout\Models\Cart $cart, + array $billingAddressData, + array $shippingAddressData + ): void + { + $billingAddressModel = $cart->billing_address; + if ($billingAddressModel) { + $this->cartAddressRepository->update($billingAddressData, $billingAddressModel->id); + + if ($cart->haveStockableItems()) { + $shippingAddressModel = $cart->shipping_address; + if ($shippingAddressModel) { + if (isset($billingAddressData['use_for_shipping']) && $billingAddressData['use_for_shipping']) { + $this->cartAddressRepository->update($billingAddressData, $shippingAddressModel->id); + } else { + $this->cartAddressRepository->update($shippingAddressData, $shippingAddressModel->id); + } + } else { + if (isset($billingAddressData['use_for_shipping']) && $billingAddressData['use_for_shipping']) { + $this->cartAddressRepository->create(array_merge($billingAddressData, + ['address_type' => 'shipping'])); + } else { + $this->cartAddressRepository->create(array_merge($shippingAddressData, + ['address_type' => 'shipping'])); + } + } + } + } else { + $this->cartAddressRepository->create(array_merge($billingAddressData, ['address_type' => 'billing'])); + + if ($cart->haveStockableItems()) { + if (isset($billingAddressData['use_for_shipping']) && $billingAddressData['use_for_shipping']) { + $this->cartAddressRepository->create(array_merge($billingAddressData, ['address_type' => 'shipping'])); + } else { + $this->cartAddressRepository->create(array_merge($shippingAddressData, ['address_type' => 'shipping'])); + } + } + } + } } diff --git a/packages/Webkul/Checkout/src/Models/CartAddress.php b/packages/Webkul/Checkout/src/Models/CartAddress.php index 0eca0b0e9..307526c9a 100755 --- a/packages/Webkul/Checkout/src/Models/CartAddress.php +++ b/packages/Webkul/Checkout/src/Models/CartAddress.php @@ -23,6 +23,7 @@ class CartAddress extends Model implements CartAddressContract 'phone', 'address_type', 'cart_id', + 'customer_id', ]; /** diff --git a/packages/Webkul/Checkout/src/Repositories/CartAddressRepository.php b/packages/Webkul/Checkout/src/Repositories/CartAddressRepository.php index 6e10091a7..7c733a7ca 100755 --- a/packages/Webkul/Checkout/src/Repositories/CartAddressRepository.php +++ b/packages/Webkul/Checkout/src/Repositories/CartAddressRepository.php @@ -4,12 +4,18 @@ namespace Webkul\Checkout\Repositories; use Webkul\Core\Eloquent\Repository; +/** + * Cart Address Repository + * + * @author Prashant Singh + * @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com) + */ class CartAddressRepository extends Repository { /** * Specify Model class name * - * @return Mixed + * @return string */ function model() { diff --git a/packages/Webkul/Core/src/Helpers/Laravel5Helper.php b/packages/Webkul/Core/src/Helpers/Laravel5Helper.php index 993b67bb1..1a2666014 100644 --- a/packages/Webkul/Core/src/Helpers/Laravel5Helper.php +++ b/packages/Webkul/Core/src/Helpers/Laravel5Helper.php @@ -6,9 +6,14 @@ namespace Webkul\Core\Helpers; // all public methods declared in helper class will be available in $I use Codeception\Module\Laravel5; +use Webkul\Checkout\Models\Cart; +use Webkul\Customer\Models\Customer; +use Webkul\Checkout\Models\CartItem; use Illuminate\Support\Facades\Event; use Webkul\Product\Models\Product; +use Webkul\Checkout\Models\CartAddress; use Webkul\Product\Models\ProductInventory; +use Webkul\Customer\Models\CustomerAddress; use Webkul\Product\Models\ProductAttributeValue; use Webkul\Product\Models\ProductDownloadableLink; use Webkul\Product\Models\ProductDownloadableLinkTranslation; @@ -22,7 +27,8 @@ class Laravel5Helper extends Laravel5 /** * Returns field name of given attribute. * - * @param string $attribute + * @param string $attribute + * * @return string|null * @part ORM */ @@ -57,7 +63,7 @@ class Laravel5Helper extends Laravel5 'brand' => 'text_value', 'guest_checkout' => 'boolean_value', ]; - + if (! array_key_exists($attribute, $attributes)) { return null; } @@ -65,16 +71,119 @@ class Laravel5Helper extends Laravel5 return $attributes[$attribute]; } + /** + * Generate a cart for the customer. Usually this is necessary to prepare the database + * before testing the checkout. + * + * @param array $options pass some options to configure some of the properties of the cart + * + * @return array the generated mocks as array + * + * @throws \Exception + */ + public function prepareCart(array $options = []): array + { + $faker = \Faker\Factory::create(); + + $I = $this; + + $product = $I->haveProduct(self::SIMPLE_PRODUCT, $options['productOptions'] ?? []); + + if (isset($options['customer'])) { + $customer = $options['customer']; + } else { + $customer = $I->have(Customer::class); + } + + $I->have(CustomerAddress::class, [ + 'customer_id' => $customer->id, + 'default_address' => 1, + 'first_name' => $customer->first_name, + 'last_name' => $customer->last_name, + 'company_name' => $faker->company, + ]); + + if (isset($options['payment_method']) + && $options['payment_method'] === 'free_of_charge') { + $grand_total = '0.0000'; + $base_grand_total = '0.0000'; + } else { + $grand_total = (string)$faker->numberBetween(1, 666); + $base_grand_total = $grand_total; + } + + $cart = $I->have(Cart::class, [ + 'customer_id' => $customer->id, + 'customer_first_name' => $customer->first_name, + 'customer_last_name' => $customer->last_name, + 'customer_email' => $customer->email, + 'is_active' => 1, + 'channel_id' => 1, + 'grand_total' => $grand_total, + 'base_grand_total' => $base_grand_total, + ]); + + $cartAddress = $I->have(CartAddress::class, ['cart_id' => $cart->id]); + + if (isset($options['product_type'])) { + $type = $options['product_type']; + } else { + $type = 'simple'; + } + + $totalQtyOrdered = 0; + + $cartItems = []; + + $generatedCartItems = rand(3, 10); + + for ($i = 2; $i <= $generatedCartItems; $i++) { + $quantity = random_int(1, 10); + $cartItem = $I->have(CartItem::class, [ + 'type' => $type, + 'quantity' => $quantity, + 'cart_id' => $cart->id, + 'product_id' => $product->id, + ]); + + $totalQtyOrdered += $quantity; + + $cartItems[] = $cartItem; + } + + // actually set the cart to the user's session + // when in an functional test: + $stub = new \StdClass(); + $stub->id = $cart->id; + $I->setSession(['cart' => $stub]); + + return [ + 'cart' => $cart, + 'product' => $product, + 'customer' => $customer, + 'cartAddress' => $cartAddress, + 'cartItems' => $cartItems, + 'totalQtyOrdered' => $totalQtyOrdered, + ]; + + } + + /** * Helper function to generate products for testing * - * @param int $productType - * @param array $configs - * @param array $productStates + * @param int $productType + * @param array $configs + * @param array $productStates + * * @return \Webkul\Product\Models\Product * @part ORM */ - public function haveProduct(int $productType, array $configs = [], array $productStates = []): Product + public function haveProduct( + int $productType, + array $configs = [], + array $productStates = [] + ): Product { $I = $this; @@ -86,7 +195,7 @@ class Laravel5Helper extends Laravel5 case self::VIRTUAL_PRODUCT: $product = $I->haveVirtualProduct($configs, $productStates); - + break; case self::SIMPLE_PRODUCT: @@ -102,11 +211,36 @@ class Laravel5Helper extends Laravel5 } /** - * @param array $configs - * @param array $productStates - * @return \Webkul\Product\Contracts\Product + * Set all session with the given key and value in the array. + * + * @param array $keyValue */ - private function haveSimpleProduct(array $configs = [], array $productStates = []): Product + public function setSession(array $keyValue) + { + session($keyValue); + } + + /** + * Flush the session data and regenerate the ID + * A logged in user will be logged off. + * + */ + public function invalidateSession() + { + session()->invalidate(); + } + + + /** + * @param array $configs + * @param array $productStates + * + * @return \Webkul\Product\Models\Product + */ + private function haveSimpleProduct( + array $configs = [], + array $productStates = [] + ): Product { $I = $this; @@ -125,8 +259,9 @@ class Laravel5Helper extends Laravel5 } /** - * @param array $configs - * @param array $productStates + * @param array $configs + * @param array $productStates + * * @return \Webkul\Product\Contracts\Product */ private function haveVirtualProduct(array $configs = [], array $productStates = []): Product @@ -148,8 +283,9 @@ class Laravel5Helper extends Laravel5 } /** - * @param array $configs - * @param array $productStates + * @param array $configs + * @param array $productStates + * * @return \Webkul\Product\Contracts\Product */ private function haveDownloadableProduct(array $configs = [], array $productStates = []): Product @@ -182,8 +318,9 @@ class Laravel5Helper extends Laravel5 } /** - * @param int $productId - * @param array $inventoryConfig + * @param int $productId + * @param array $inventoryConfig + * * @return void */ private function createInventory(int $productId, array $inventoryConfig = []): void @@ -193,11 +330,14 @@ class Laravel5Helper extends Laravel5 $I->have(ProductInventory::class, array_merge($inventoryConfig, [ 'product_id' => $productId, 'inventory_source_id' => 1, + 'qty' => random_int(100, 666), ])); + } /** - * @param int $productId + * @param int $productId + * * @return void */ private function createDownloadableLink(int $productId): void @@ -214,14 +354,15 @@ class Laravel5Helper extends Laravel5 } /** - * @param int $productId - * @param array $attributeValues + * @param int $productId + * @param array $attributeValues + * * @return void */ private function createAttributeValues(int $productId, array $attributeValues = []): void { $I = $this; - + $productAttributeValues = [ 'sku', 'url_key', @@ -254,7 +395,7 @@ class Laravel5Helper extends Laravel5 $data = [$fieldName => $attributeValues[$attribute]]; } } - + $I->have(ProductAttributeValue::class, $data, $attribute); } } diff --git a/packages/Webkul/Customer/src/Database/Factories/CustomerFactory.php b/packages/Webkul/Customer/src/Database/Factories/CustomerFactory.php index ec20de791..0d490948e 100644 --- a/packages/Webkul/Customer/src/Database/Factories/CustomerFactory.php +++ b/packages/Webkul/Customer/src/Database/Factories/CustomerFactory.php @@ -8,13 +8,12 @@ use Webkul\Customer\Models\Customer; $factory->define(Customer::class, function (Faker $faker) { $now = date("Y-m-d H:i:s"); - $gender = array_rand(['male', 'female', 'other']); $password = $faker->password; return [ - 'first_name' => $faker->firstName($gender), + 'first_name' => $faker->firstName(), 'last_name' => $faker->lastName, - 'gender' => ucfirst($gender), + 'gender' => array_random(['male', 'female', 'other']), 'email' => $faker->email, 'status' => 1, 'password' => Hash::make($password), @@ -22,7 +21,7 @@ $factory->define(Customer::class, function (Faker $faker) { 'is_verified' => 1, 'created_at' => $now, 'updated_at' => $now, - 'notes' => json_encode(array('plain_password' => $password)), + 'notes' => json_encode(['plain_password' => $password]), ]; }); diff --git a/packages/Webkul/Sales/src/Database/Migrations/2020_02_28_105104_fix_order_columns.php b/packages/Webkul/Sales/src/Database/Migrations/2020_02_28_105104_fix_order_columns.php new file mode 100644 index 000000000..b55718e11 --- /dev/null +++ b/packages/Webkul/Sales/src/Database/Migrations/2020_02_28_105104_fix_order_columns.php @@ -0,0 +1,31 @@ +removeColumn('customer_company_name'); + $table->removeColumn('customer_vat_id'); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + // + } +} diff --git a/packages/Webkul/Sales/src/Models/OrderAddress.php b/packages/Webkul/Sales/src/Models/OrderAddress.php index 0b5f5b89c..d1bcddc62 100755 --- a/packages/Webkul/Sales/src/Models/OrderAddress.php +++ b/packages/Webkul/Sales/src/Models/OrderAddress.php @@ -3,6 +3,7 @@ namespace Webkul\Sales\Models; use Illuminate\Database\Eloquent\Model; +use Webkul\Customer\Models\Customer; use Webkul\Sales\Contracts\OrderAddress as OrderAddressContract; class OrderAddress extends Model implements OrderAddressContract diff --git a/packages/Webkul/Sales/src/Repositories/OrderAddressRepository.php b/packages/Webkul/Sales/src/Repositories/OrderAddressRepository.php index fac4192d7..b52653aec 100755 --- a/packages/Webkul/Sales/src/Repositories/OrderAddressRepository.php +++ b/packages/Webkul/Sales/src/Repositories/OrderAddressRepository.php @@ -2,16 +2,21 @@ namespace Webkul\Sales\Repositories; -use Illuminate\Container\Container as App; use Webkul\Core\Eloquent\Repository; use Webkul\Sales\Contracts\OrderAddress; +/** + * Order Address Repository + * + * @author Jitendra Singh + * @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com) + */ class OrderAddressRepository extends Repository { /** * Specify Model class name * - * @return Mixed + * @return string */ function model() diff --git a/packages/Webkul/Shop/src/Http/Controllers/OnepageController.php b/packages/Webkul/Shop/src/Http/Controllers/OnepageController.php index 47bfd1db0..51964b6d4 100755 --- a/packages/Webkul/Shop/src/Http/Controllers/OnepageController.php +++ b/packages/Webkul/Shop/src/Http/Controllers/OnepageController.php @@ -52,12 +52,14 @@ class OnepageController extends Controller */ public function index() { - if (! auth()->guard('customer')->check() && ! core()->getConfigData('catalog.products.guest-checkout.allow-guest-checkout')) { + if (! auth()->guard('customer')->check() + && ! core()->getConfigData('catalog.products.guest-checkout.allow-guest-checkout')) { return redirect()->route('customer.session.index'); } - if (Cart::hasError()) + if (Cart::hasError()) { return redirect()->route('shop.checkout.cart.index'); + } $cart = Cart::getCart(); diff --git a/tests/_support/FunctionalTester.php b/tests/_support/FunctionalTester.php index 41b348f5a..18a68fb7a 100644 --- a/tests/_support/FunctionalTester.php +++ b/tests/_support/FunctionalTester.php @@ -6,6 +6,10 @@ use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\Route; use Webkul\User\Models\Admin; use Webkul\Customer\Models\Customer; +use Webkul\Customer\Models\CustomerAddress; +use Webkul\Checkout\Models\Cart; +use Webkul\Checkout\Models\CartItem; +use Webkul\Checkout\Models\CartAddress; /** * Inherited Methods @@ -104,18 +108,24 @@ class FunctionalTester extends \Codeception\Actor * // TODO: change method as soon as there is a method to set core config data * * @param $data array containing 'code => value' pairs + * * @return void */ - public function setConfigData($data): void { + public function setConfigData($data): void + { foreach ($data as $key => $value) { if (DB::table('core_config')->where('code', '=', $key)->exists()) { - DB::table('core_config')->where('code', '=', $key)->update(['value' => $value]); + DB::table('core_config') + ->where('code', '=', $key) + ->update(['value' => $value]); } else { DB::table('core_config')->insert([ - 'code' => $key, - 'value' => $value, - 'created_at' => date('Y-m-d H:i:s'), - 'updated_at' => date('Y-m-d H:i:s') + 'code' => $key, + 'value' => $value, + 'channel_code' => null, + 'locale_code' => null, + 'created_at' => date('Y-m-d H:i:s'), + 'updated_at' => date('Y-m-d H:i:s'), ]); } } diff --git a/tests/_support/Helper/Functional.php b/tests/_support/Helper/Functional.php index 4183cb0a5..9d1800eca 100644 --- a/tests/_support/Helper/Functional.php +++ b/tests/_support/Helper/Functional.php @@ -1,4 +1,5 @@ first(); + if (! $channel) { + throw new \Exception( + "Given theme '$theme' could not applied because channel '$channel' could not be fetched from database" + ); + } + + $channel->update(['theme' => $theme]); + } } diff --git a/tests/functional/Admin/Catalog/AttributeFamilyCest.php b/tests/functional/Admin/Catalog/AttributeFamilyCest.php index 9c17e02d6..60a20db72 100644 --- a/tests/functional/Admin/Catalog/AttributeFamilyCest.php +++ b/tests/functional/Admin/Catalog/AttributeFamilyCest.php @@ -74,8 +74,9 @@ class AttributeFamilyCest private function fillForm(FunctionalTester $I): array { $testData = [ - 'code' => $I->fake()->word, - 'name' => $I->fake()->word, + // code needs to match to: '/^[a-zA-Z]+[a-zA-Z0-9_]+$/' + 'code' => $I->fake()->word . strtr($I->fake()->uuid, ['-' => '_']), + 'name' => $I->fake()->sentence, ]; $I->fillField('code', $testData['code']); diff --git a/tests/functional/Checkout/Order/OrderCest.php b/tests/functional/Checkout/Order/OrderCest.php new file mode 100644 index 000000000..2cf903895 --- /dev/null +++ b/tests/functional/Checkout/Order/OrderCest.php @@ -0,0 +1,147 @@ +loginAsCustomer(); + + $faker = Factory::create(); + + $addressData = [ + 'city' => $faker->city, + 'company_name' => $faker->company, + 'country' => $faker->countryCode, + 'email' => $faker->email, + 'first_name' => $faker->firstName, + 'last_name' => $faker->lastName, + 'phone' => $faker->phoneNumber, + 'postcode' => $faker->postcode, + 'state' => $faker->state, + ]; + + $mocks = $I->prepareCart([ + 'customer' => $customer, + ]); + + // assert that checkout can be reached and generate csrf token. + $I->amOnRoute('shop.checkout.onepage.index'); + + // simulate the entering of the address(es): + $I->sendAjaxPostRequest(route('shop.checkout.save-address'), [ + '_token' => csrf_token(), + 'billing' => array_merge($addressData, [ + 'address1' => ['900 Nobel Parkway'], + 'save_as_address' => true, + 'use_for_shipping' => true, + ]), + 'shipping' => array_merge($addressData, [ + 'address1' => ['900 Nobel Parkway'], + 'save_as_address' => true, + 'use_for_shipping' => true, + ]), + ]); + + $I->seeResponseCodeIsSuccessful(); + + $I->seeRecord(CartAddress::class, array_merge($addressData, [ + 'address_type' => 'shipping', + 'cart_id' => $mocks['cart']->id, + 'customer_id' => $mocks['customer']->id, + ])); + + $I->seeRecord(CartAddress::class, array_merge($addressData, [ + 'address_type' => 'billing', + 'cart_id' => $mocks['cart']->id, + 'customer_id' => $mocks['customer']->id, + ])); + + $I->sendAjaxPostRequest(route('shop.checkout.save-shipping'), [ + '_token' => csrf_token(), + 'shipping_method' => 'free_free', + ]); + + $I->seeResponseCodeIsSuccessful(); + + $I->sendAjaxPostRequest(route('shop.checkout.save-payment'), [ + '_token' => csrf_token(), + 'payment' => [ + 'method' => 'cashondelivery', + ], + ]); + + $I->seeResponseCodeIsSuccessful(); + + $I->seeRecord(CartPayment::class, [ + 'method' => 'cashondelivery', + 'method_title' => null, + 'cart_id' => $mocks['cart']->id, + ]); + + // simulate click on the 'place order' button at the last step: + $I->sendAjaxPostRequest(route('shop.checkout.save-order'), + ['_token' => csrf_token()] + ); + + $I->seeResponseCodeIsSuccessful(); + + $order = $I->grabRecord(Order::class, [ + 'status' => 'pending', + 'channel_name' => 'Default', + 'is_guest' => 0, + 'customer_first_name' => $customer->first_name, + 'customer_last_name' => $customer->last_name, + 'customer_email' => $customer->email, + 'shipping_method' => 'free_free', + 'shipping_title' => 'Free Shipping - Free Shipping', + 'shipping_description' => 'Free Shipping', + 'customer_type' => Customer::class, + 'channel_id' => 1, + 'channel_type' => Channel::class, + 'cart_id' => $mocks['cart']->id, + 'customer_id' => $customer->id, + 'total_item_count' => count($mocks['cartItems']), + 'total_qty_ordered' => $mocks['totalQtyOrdered'], + ]); + + $I->seeRecord(OrderAddress::class, array_merge($addressData, [ + 'order_id' => $order->id, + 'address_type' => 'shipping', + 'customer_id' => $mocks['customer']->id, + ])); + + $I->seeRecord(OrderAddress::class, array_merge($addressData, [ + 'order_id' => $order->id, + 'address_type' => 'billing', + 'customer_id' => $mocks['customer']->id, + ])); + + $I->seeRecord(OrderPayment::class, [ + 'method' => 'cashondelivery', + 'method_title' => null, + 'order_id' => $order->id, + ]); + } +} \ No newline at end of file diff --git a/tests/functional/Shop/CartTaxesCest.php b/tests/functional/Shop/CartTaxesCest.php index 6e474fe16..a0ead79cc 100644 --- a/tests/functional/Shop/CartTaxesCest.php +++ b/tests/functional/Shop/CartTaxesCest.php @@ -26,19 +26,19 @@ class CartTaxesCest $tax1 = $I->have(TaxRate::class, [ 'country' => $this->country, ]); - $taxCategorie1 = $I->have(TaxCategory::class); + $taxCategory1 = $I->have(TaxCategory::class); $I->have(TaxMap::class, [ 'tax_rate_id' => $tax1->id, - 'tax_category_id' => $taxCategorie1->id, + 'tax_category_id' => $taxCategory1->id, ]); $tax2 = $I->have(TaxRate::class, [ 'country' => $this->country, ]); - $taxCategorie2 = $I->have(TaxCategory::class); + $taxCategory2 = $I->have(TaxCategory::class); $I->have(TaxMap::class, [ 'tax_rate_id' => $tax2->id, - 'tax_category_id' => $taxCategorie2->id, + 'tax_category_id' => $taxCategory2->id, ]); $config1 = [ @@ -46,7 +46,7 @@ class CartTaxesCest 'attributeValues' => [ 'status' => true, 'new' => 1, - 'tax_category_id' => $taxCategorie1->id, + 'tax_category_id' => $taxCategory1->id, ], ]; $product1 = $I->haveProduct(Laravel5Helper::SIMPLE_PRODUCT, $config1); @@ -56,7 +56,7 @@ class CartTaxesCest 'attributeValues' => [ 'status' => true, 'new' => 1, - 'tax_category_id' => $taxCategorie2->id, + 'tax_category_id' => $taxCategory2->id, ], ]; $product2 = $I->haveProduct(Laravel5Helper::SIMPLE_PRODUCT, $config2); @@ -158,15 +158,15 @@ class CartTaxesCest 'tax_rate' => $I->fake()->randomFloat(2, 3, 8), ]); - $taxCategorie1 = $I->have(TaxCategory::class); + $taxCategory1 = $I->have(TaxCategory::class); $I->have(TaxMap::class, [ 'tax_rate_id' => $tax11->id, - 'tax_category_id' => $taxCategorie1->id, + 'tax_category_id' => $taxCategory1->id, ]); $I->have(TaxMap::class, [ 'tax_rate_id' => $tax12->id, - 'tax_category_id' => $taxCategorie1->id, + 'tax_category_id' => $taxCategory1->id, ]); $tax21 = $I->have(TaxRate::class, [ @@ -186,15 +186,15 @@ class CartTaxesCest 'tax_rate' => $I->fake()->randomFloat(2, 14, 25), ]); - $taxCategorie2 = $I->have(TaxCategory::class); + $taxCategory2 = $I->have(TaxCategory::class); $I->have(TaxMap::class, [ 'tax_rate_id' => $tax21->id, - 'tax_category_id' => $taxCategorie2->id, + 'tax_category_id' => $taxCategory2->id, ]); $I->have(TaxMap::class, [ 'tax_rate_id' => $tax22->id, - 'tax_category_id' => $taxCategorie2->id, + 'tax_category_id' => $taxCategory2->id, ]); $config1 = [ @@ -202,7 +202,7 @@ class CartTaxesCest 'attributeValues' => [ 'status' => true, 'new' => 1, - 'tax_category_id' => $taxCategorie1->id, + 'tax_category_id' => $taxCategory1->id, ], ]; $product1 = $I->haveProduct(Laravel5Helper::SIMPLE_PRODUCT, $config1); @@ -212,7 +212,7 @@ class CartTaxesCest 'attributeValues' => [ 'status' => true, 'new' => 1, - 'tax_category_id' => $taxCategorie2->id, + 'tax_category_id' => $taxCategory2->id, ], ]; $product2 = $I->haveProduct(Laravel5Helper::SIMPLE_PRODUCT, $config2);