Skip to content

Latest commit

 

History

History
123 lines (88 loc) · 3.1 KB

DEVELOPPING.md

File metadata and controls

123 lines (88 loc) · 3.1 KB

Developing on Commerce Google Tag Manager

📦 Repositories

Github repo

git remote add github https://github.com/gridonic/commerce_google_tag_manager

Drupal repo

git remote add drupal git@git.drupal.org:project/commerce_google_tag_manager.git

🔧 Prerequisites

First of all, you will need to have the following tools installed globally on your environment:

  • drush
  • Latest dev release of Drupal 8.x.

🏆 Tests

You must provide a SIMPLETEST_BASE_URL, Eg. http://localhost. You must provide a SIMPLETEST_DB, Eg. sqlite://localhost/build/commerce_google_tag_manager.sqlite.

Run the functional tests:

# You must be on the drupal-root folder - usually /web.
$ cd web
$ SIMPLETEST_DB="sqlite://localhost//tmp/commerce_google_tag_manager.sqlite" \
SIMPLETEST_BASE_URL='http://sandbox.test' \
BROWSERTEST_OUTPUT_DIRECTORY="/path/to/webroot/browser_output" \
../vendor/bin/phpunit -c core \
--group commerce_google_tag_manager \
--printer="\Drupal\Tests\Listeners\HtmlOutputPrinter" --stop-on-error

🚔 Check Drupal coding standards & Drupal best practices

You need to run composer before using PHPCS. Then register the Drupal and DrupalPractice Standard with PHPCS:

`./vendor/bin/phpcs --config-set installed_paths \
`pwd`/vendor/drupal/coder/coder_sniffer`

Command Line Usage

Check Drupal coding standards:

./vendor/bin/phpcs --standard=Drupal --colors \
--extensions=php,module,inc,install,test,profile,theme,info,md \
--ignore=*/vendor/*,*/node_modules/*,*/scripts/* --encoding=utf-8 ./

Check Drupal best practices:

./vendor/bin/phpcs --standard=DrupalPractice --colors \
--extensions=php,module,inc,install,test,profile,theme,info,md \
--ignore=*/vendor/*,*/node_modules/*,*/scripts/* --encoding=utf-8 ./

Automatically fix coding standards

./vendor/bin/phpcbf --standard=Drupal --colors \
--extensions=php,module,inc,install,test,profile,theme,info \
--ignore=*/vendor/*,*/node_modules/*,*/scripts/* ./

Improve global code quality using PHPCPD PHPMD, & PHPCF

Add requirements if necessary using composer:

composer install

Detect overcomplicated expressions & Unused parameters, methods, properties

./vendor/bin/phpmd ./ text ./phpmd.xml --suffixes \
php,module,inc,install,test,profile,theme,info,txt \
--exclude vendor,scripts

Copy/Paste Detector

./vendor/bin/phpcpd ./ \
--names=*.php,*.module,*.inc,*.install,*.test,*.profile,*.theme,*.info,*.txt \
--names-exclude=*.md,*.info.yml --progress --ansi \
--exclude=scripts --exclude=vendor

Checks compatibility with PHP interpreter versions

./vendor/bin/phpcf --target 7.2 \
--file-extensions php,module,inc,install,test,profile,theme,info \
./src

Enforce code standards with git hooks

Maintaining code quality by adding the custom post-commit hook to yours.

cat ./scripts/hooks/post-commit >> ./.git/hooks/post-commit