Coder Social home page Coder Social logo

testing-suite's Introduction

Scrutinizer Code Quality

MediaCT Testing Suite

This package serves as an umbrella package for several of MediaCT's testing packages.

Installation

composer require mediact/testing-suite --dev

Usage

The testing suite can be run through the GrumPHP command.

vendor/bin/grumphp run

The testing suite is also automatically run at each git commit using a git commit hook.

Components

The following components are part of the testing suite.

Coding style validation (PHPCS)

The coding style is validated using PHPCS and uses the MediaCT Coding Standard.

During the installation of the testing suite a file called phpcs.xml is added to the root of the repository which refers to the coding standard. To make adjustments to the coding standard this file can be edited and committed.

Depending on the composer type of the project an other standard will be used:

Coding complexity validation (PHPMD)

The complexity of the code is validated using PHPMD. A file called phpmd.xml is added during the installation of the testing suite.

Static code analysis (PHPStan)

Static code analysis is executed using PHPStan. A file called phpstan.neon is added during the installation of the testing suite.

Unit tests (PHPUnit)

Unit tests are executed using PHPUnit. A file called phpunit.xml is added during the installation of the testing suite.

The unit tests are expected to be in a directory called tests. The code is expected to be in a directory called src.

Bitbucket Pipelines

When the project is hosted on Bitbucket a Pipelines script will be installed. The scripts supports a callback that will be called before composer install is executed. This callback can be used to add credentials to composer. To enable the callback go to Bitbucket Settings > Pipelines > Environment Variables and add an environment variable called COMPOSER_PRE_INSTALL_CALLBACK.

Example to add basic authentication for repo.example.com:

composer config --global http-basic.repo.example.com $YOUR_USER $YOUR_PASSWORD

ESLint

Javascript linting for Magento 1 and Magento 2 projects is executed using ESLint. Two files called .eslintrc.json and .eslintignore are added to the root of the repository which contains the coding standards and files excluded from analysis.

A third file called package.json is added which contains the needed npm modules. Run npm install after the installation in order to enable ESLint:

npm install

Integration with PHPStorm

When the testing suite is installed in a PHPStorm environment it automatically configures PHPStorm to use the correct coding style.

To enable PHPCS and PHPMD inspections in PHPStorm the correct binaries need to be configured. This is a global setting in PHPStorm and can therefore not be configured by the testing suite.

The recommended way to get the correct binaries is by installing the MediaCT Coding Standard globally.

composer global require mediact/coding-standard

The package will be installed in the home directory of composer. The location of this directory can be found using the following command:

composer global config home

Open PHPStorm and go to Settings > Languages & Frameworks > PHP > Code Sniffer.

Choose "Local" for the development environment and fill in the full path to <composer_home_directory>/vendor/bin/phpcs.

Then go to Settings > Languages & Frameworks > PHP > Mess Detector.

Choose "Local" for the development environment and fill in the full path to <composer_home_directory>/vendor/bin/phpmd.

After these adjustments the coding style and complexity will be validated while typing in PHPStorm.

To enable ESLint open PHPStorm and go to Settings > Languages & Frameworks > Javascript > Code Quality Tools > ESLint.

Enable ESLint by checking Enabled. Then set the Node interpreter to Project and Configuration file to Automatic Search.

testing-suite's People

Contributors

ashokadewit avatar janmartenjongerius avatar ksangers avatar leonhelmus avatar marcelmediact avatar michielfb avatar sjokki avatar vssr avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.