Commit Graph

6 Commits

Author SHA1 Message Date
Steve Grunwell 6fe6faf7ca Don't flag instances of print_r() within the tests/ directory.
In some cases, calls like `print_r( $data, true )` (return the printed array as a string) can be helpful for providing context if/when a test fails.
2018-01-15 17:12:33 +00:00
Steve Grunwell 4804d9e8a5 Don't hold the test suite to the same naming conventions as WordPress/WooCommerce. 2018-01-15 17:02:39 +00:00
Steve Grunwell 4cded5e9aa Exclude the /tests/ directory from PHP Compatibility checks
The composer.json file in WooCommerce specifies PHPUnit version 6.2.3 as a development dependency; that version of PHPUnit sets PHP 7.0 as the minimum PHP version, effectively making the minimum development version for WooCommerce to be PHP 7.0 (hooray!).

With a more modern version of PHP as the minimum requirement for developers, the code that isn't distributed with the plugin (e.g. the /tests/ directory) doesn't necessarily need to adhere to PHP 5.2-compatible coding standards. This commit removes the /tests/ directory from the scope of the PHP Compatibility checks, enabling the test suite to leverage modern (relative to PHP 5.2, anyway) features like closures, short-array syntax, and namespaces. Embracing more modern PHP in the test suite also opens up the possibilities of using libraries like Faker to populate dummy data, rather than the hard-coded helpers that exist now.

An example test enabled by this change: developers can now use closures for filter callbacks.

    add_filter( 'some_filter', function () {
        return 'the filtered value';
    }

    $this->assertEquals( 'the filtered value', my_function() );

Without a closure, this test would need to either write a one-off method in the test class or hack around it with static properties to configure the expected filter response.
2018-01-11 23:17:22 +00:00
Claudio Sanches 5b15dbe8fe Ignore "namespace" used in REST API 2018-01-11 13:11:24 -02:00
Claudio Sanches 61b5c7a445 Added WooCommerce-Core sniffs 2017-12-21 21:29:49 -02:00
Rodrigo Primo bf052c14c7 Use default name for PHPCS configuration file
This commit renames PHPCS configutarion file to `phpcs.xml`. With the default name, it is not necessary to use the argument `--standard=phpcs.ruleset.xml` anymore when calling `phpcs`.
2017-12-18 11:49:44 -02:00