Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: Yoast/PHPUnit-Polyfills
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 0.1.0
Choose a base ref
...
head repository: Yoast/PHPUnit-Polyfills
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 0.2.0
Choose a head ref
  • 16 commits
  • 46 files changed
  • 1 contributor

Commits on Nov 13, 2020

  1. Composer: update YoastCS

    ... and remove the `composer self-update` from the Travis script as it's no longer needed.
    
    YoastCS 2.1.0 requires the DealerDirect Composer PHPCS plugin at version `0.7.0`, which is compatible with Composer 2.0.
    
    Refs:
    * https://github.com/Yoast/yoastcs/releases/tag/2.1.0
    jrfnl committed Nov 13, 2020
    Configuration menu
    Copy the full SHA
    be95a38 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    e6093f6 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    b8507ce View commit details
    Browse the repository at this point in the history
  4. Readme: fix badges

    jrfnl committed Nov 13, 2020
    Configuration menu
    Copy the full SHA
    3b9d3a4 View commit details
    Browse the repository at this point in the history

Commits on Nov 25, 2020

  1. Readme: minor tweaks

    jrfnl committed Nov 25, 2020
    Configuration menu
    Copy the full SHA
    ab009b9 View commit details
    Browse the repository at this point in the history
  2. Autoloader: add "default" case

    .. to simplify handling of those files which don't need PHPUnit version based loading.
    
    The `default` case translates the class name to the file path based on PSR4 and loads them, without using hard-coded class names nor file paths.
    jrfnl committed Nov 25, 2020
    Configuration menu
    Copy the full SHA
    5960fb6 View commit details
    Browse the repository at this point in the history
  3. Composer: more specific PHPUnit requirements

    This ensures that the "forward compatible" namespaced versions of common PHPUnit classes/interfaces are available.
    
    PHP 6.0 introduced namespaces to PHPUnit.
    The last few version(s) of PHPUnit 4.x and 5.x, contain both non-namespaced and namespaced versions of the most commonly referred to classes used by test suites.
    
    By being strict about the minimum supported versions of PHPUnit 4.x and 5.x, we can be sure that the namespaced versions of the files are available when we need them and that we don't need to create `class_alias()`-es for these.
    jrfnl committed Nov 25, 2020
    Configuration menu
    Copy the full SHA
    17b7095 View commit details
    Browse the repository at this point in the history
  4. TestCase: add support for assert(Pre|Post)Conditions() fixture methods

    Add cross-version handling of the `assertPreConditions()` and `assertPostConditions()` methods via snake_case methods to the `Yoast\PHPUnitPolyfills\TestCases\TestCase`.
    
    Includes unit tests.
    
    Includes improving the documentation within the class.
    
    Note: these methods are not included in the `XTestCase` as there are no annotations available to handle these methods.
    jrfnl committed Nov 25, 2020
    Configuration menu
    Copy the full SHA
    e5a2e38 View commit details
    Browse the repository at this point in the history
  5. New Helpers\AssertAttributeHelper

    The PHPUnit `assertAttribute*()` methods were deprecated in PHPUnit 8.x and removed in PHPUnit 9.0.
    
    Public properties can still be tested by accessing them directly.
    Protected and private properties can no longer be tested using PHPUnit native functionality.
    
    The reasoning for the removal of these assertion methods is that _private and protected properties are an implementation detail and should not be tested directly, but via methods in the class_.
    
    It is strongly recommended to refactor tests, and if needs be, classes to adhere to this.
    
    However, if for some reason the value of protected or private properties still needs to be tested, this helper can be used to get access to their properties and value.
    
    Includes tests.
    
    Fixes 2
    jrfnl committed Nov 25, 2020
    Configuration menu
    Copy the full SHA
    45c6489 View commit details
    Browse the repository at this point in the history
  6. Add a cross-version compatible TestListenerDefaultImplementation

    The method signatures in the PHPUnit `TestListener` interface have changed a number of times across versions, including adding scalar parameter (PHP 7.0+) and `void` return type (PHP 7.1+) declarations.
    
    Additionally, the use of the TestListener principle has been deprecated in PHPUnit 7 in favour of using the [TestRunner hook interfaces](https://phpunit.readthedocs.io/en/9.3/extending-phpunit.html#extending-the-testrunner).
    
    If a test suite does not need to support PHPUnit < 7, it is strongly recommended to use the TestRunner hook interfaces extensions instead.
    
    However, for test suites that still need to support PHPUnit 6 or lower, implementing the `TestListener` interface is the only viable option.
    
    This commit adds a `Yoast\PHPUnitPolyfills\TestListeners\TestListenerDefaultImplementation` trait which overcomes the signature mismatches by having multiple versions and loading the correct one depending on the PHPUnit version being used.
    
    Similar to the `TestCase` implementation, snake_case methods without type declarations are used to get round the signature mismatches. The snake_case methods will automatically be called.
    
    Includes tests for this TestListener implementation.
    
    Includes making an allowance for the `float` parameter and `void` return type in the PHPUnit 7+ specific testlistener trait in:
    * the PHPCS config.
    * the Parallel Lint command.
    jrfnl committed Nov 25, 2020
    Configuration menu
    Copy the full SHA
    2f1a5e9 View commit details
    Browse the repository at this point in the history
  7. Remove use of constant scalar expressions

    ... and allow this package to be installed on PHP 5.5.
    jrfnl committed Nov 25, 2020
    Configuration menu
    Copy the full SHA
    83ba7e3 View commit details
    Browse the repository at this point in the history
  8. AssertNumericType trait: polyfill the Assert::assertInfinite() et al …

    …methods
    
    PHPUnit 5.0.0 introduced the new `Assert::assertFinite()`, `Assert::assertInfinite()` and `Assert::assertNan()` methods.
    
    This commit:
    * Adds two traits with the same name.
        One to polyfill the methods when not available in PHPUnit.
        The other - an empty trait - to allow for `use`-ing the trait in PHPUnit versions in which the methods are already natively available.
    * Logic to the custom autoloader which will load the correct trait depending on the PHPUnit version used.
    * An availability test for the functionality polyfilled.
    
    Note: the methods use `static::` to call the PHPUnit native functionality. This allows for existing method overloads in a child class of the PHPUnit native `TestCase` to be respected.
    jrfnl committed Nov 25, 2020
    Configuration menu
    Copy the full SHA
    057a83d View commit details
    Browse the repository at this point in the history
  9. ExpectException trait: polyfill the expectException*() et al methods

    PHPUnit 5.2.0 introduced the new `TestCase::expectException()`, `TestCase::expectExceptionCode()`,`TestCase::expectExceptionMessage()` and `TestCase::expectExceptionMessageRegExp()` methods as a replacement for the `Testcase::setExpectedException() method which was deprecated in PHPUnit 5.2.0 and the  `Testcase::setExpectedExceptionRegExp()` method which was deprecated in 5.6.0.
    Both these methods were removed in PHPUnit 6.0.0.
    
    This commit:
    * Adds two traits with the same name.
        One to polyfill the methods when not available in PHPUnit.
        The other - an empty trait - to allow for `use`-ing the trait in PHPUnit versions in which the methods are already natively available.
    * Logic to the custom autoloader which will load the correct trait depending on the PHPUnit version used.
    * An availability test and partial functionality test for the functionality polyfilled.
    
    Includes:
    * Adding the new polyfill to the existing `TestCases` classes.
    * Adding the new polyfill to select test files to allow those to run and pass on PHPUnit 4.8.x.
    * Making an allowance in the PHPCS ruleset for an exception quirk which PHPCS can't handle correctly.
    jrfnl committed Nov 25, 2020
    Configuration menu
    Copy the full SHA
    b537298 View commit details
    Browse the repository at this point in the history
  10. AssertFileDirectory trait: polyfill the Assert::assertIsReadable() et…

    … al methods
    
    PHPUnit 5.6.0 introduced the new `Assert::assertIsReadable()`, `Assert::assertNotIsReadable()`, `Assert::assertIsWritable()`, `Assert::assertNotIsWritable()`, `Assert::assertDirectoryExists()`, `Assert::assertDirectoryNotExists()`, `Assert::assertDirectoryIsReadable()`, `Assert::assertDirectoryNotIsReadable()`, `Assert::assertDirectoryIsWritable()`, `Assert::assertDirectoryNotIsWritable()`, `Assert::assertFileIsReadable()`, `Assert::assertFileNotIsReadable()`, `Assert::assertFileIsWritable()`, and `Assert::assertFileNotIsWritable()` methods.
    
    This commit:
    * Adds two traits with the same name.
        One to polyfill the methods when not available in PHPUnit.
        The other - an empty trait - to allow for `use`-ing the trait in PHPUnit versions in which the methods are already natively available.
    * Logic to the custom autoloader which will load the correct trait depending on the PHPUnit version used.
    * An availability test for the functionality polyfilled.
    
    Note: the methods use `static::` to call the PHPUnit native functionality. This allows for existing method overloads in a child class of the PHPUnit native `TestCase` to be respected.
    
    Includes:
    * Adding the new polyfill to the existing `TestCases` classes.
    * Adding the new polyfill to select test files to allow those to run and pass on PHPUnit 4.8.x.
    * Making an allowance in the PHPCS ruleset for an exception quirk which PHPCS can't handle correctly.
    jrfnl committed Nov 25, 2020
    Configuration menu
    Copy the full SHA
    347c768 View commit details
    Browse the repository at this point in the history
  11. Allow installation in combination with PHPUnit 4.8.36

    To allow for testing on PHP 5.5, PHPUnit 4 is needed.
    
    PHPUnit 4.8.36 is the only version in the 4.x series which contains the forward-compatible layer with the namespaced versions of common PHPUnit classes.
    
    With the additional polyfills which have been put in place, installation of this package on PHP 5.5 in combination with PHPUnit 4.8.36 is now supported.
    
    Includes annotating this change in all the relevant places.
    Includes adding a new build to the Travis matrix to also run all tests against PHP 5.5 / PHPUnit 4.8.36.
    jrfnl committed Nov 25, 2020
    Configuration menu
    Copy the full SHA
    701f40c View commit details
    Browse the repository at this point in the history
  12. Configuration menu
    Copy the full SHA
    c48e4cf View commit details
    Browse the repository at this point in the history
Loading