Skip to content

Commit

Permalink
Merge pull request #129 from 10up/compat-pr
Browse files Browse the repository at this point in the history
PHPUnit 7.x Compatibility Fixes

Fixes #117
  • Loading branch information
ericmann authored Jan 17, 2019
2 parents d1cdc6e + 3382b8b commit 9f3525a
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 22 deletions.
18 changes: 10 additions & 8 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,25 @@ language: php

matrix:
include:
- php: '7.0'
env: WP_MOCK_INSTALL_LOWEST=0
- php: '7.1'
env: WP_MOCK_INSTALL_LOWEST=0
- php: '7.2'
env: WP_MOCK_INSTALL_LOWEST=0
- php: '7.3'
env: WP_MOCK_INSTALL_LOWEST=0
- php: nightly
env: WP_MOCK_INSTALL_LOWEST=0
- php: '7.0'
env: WP_MOCK_INSTALL_LOWEST=1
- php: '7.1'
env: WP_MOCK_INSTALL_LOWEST=1
- php: '7.2'
env: WP_MOCK_INSTALL_LOWEST=1
- php: '7.3'
env: WP_MOCK_INSTALL_LOWEST=1
- php: nightly
env: WP_MOCK_INSTALL_LOWEST=1
allow_failures:
- php: nightly
env: WP_MOCK_INSTALL_LOWEST=0
- php: nightly
env: WP_MOCK_INSTALL_LOWEST=1

Expand All @@ -26,9 +31,6 @@ script:
- mkdir -p build/logs
- composer run-script coverage

after_script:
- php vendor/bin/coveralls -v

cache:
directories:
- vendor
Expand All @@ -39,4 +41,4 @@ branches:
- master

after_success:
- travis_retry php vendor/bin/coveralls
- travis_retry php vendor/bin/php-coveralls
2 changes: 1 addition & 1 deletion LICENSE.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
WP_Mock - WordPress API Mocking Framework

Copyright 2013-2017 by the contributors
Copyright 2013-2019 by the contributors

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# WP_Mock ![PHP 7.0+][php-image] [![Build Status][travis-image]][travis-url] [![Coverage Status][coveralls-image]][coveralls-url] [![Packagist][packagist-image]][packagist-url]
# WP_Mock ![PHP 7.1+][php-image] [![Build Status][travis-image]][travis-url] [![Coverage Status][coveralls-image]][coveralls-url] [![Packagist][packagist-image]][packagist-url]

WP_Mock is an API mocking framework, built and maintained by [10up](http://10up.com) for the purpose of making it possible to properly unit test within WordPress.

Expand Down Expand Up @@ -398,7 +398,7 @@ function test_get_post_ids() {

Thanks so much for being interested in contributing! Please read over our [guidelines](https://github.com/10up/wp_mock/blob/dev/CONTRIBUTING.md) before you get started.

[php-image]: https://img.shields.io/badge/php-7.0%2B-green.svg
[php-image]: https://img.shields.io/badge/php-7.1%2B-green.svg
[packagist-image]: https://img.shields.io/packagist/dt/10up/wp_mock.svg
[packagist-url]: https://packagist.org/packages/10up/wp_mock
[travis-image]: https://travis-ci.org/10up/wp_mock.svg?branch=master
Expand Down
10 changes: 5 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
{
"name" : "10up/wp_mock",
"description": "A mocking library to take the pain out of unit testing for WordPress",
"license" : "GPL-2.0+",
"version" : "0.3.0",
"license" : "GPL-2.0-or-later",
"version" : "0.4.0",
"require" : {
"php" : ">=7.0",
"phpunit/phpunit" : ">=6.0",
"php" : ">=7.1",
"phpunit/phpunit" : ">=7.0",
"mockery/mockery" : "^1.0",
"antecedent/patchwork": "^2.1"
},
"require-dev": {
"behat/behat" : "^3.0",
"sebastian/comparator": ">=1.2.3",
"satooshi/php-coveralls": "^1.0"
"php-coveralls/php-coveralls": "^2.1"
},
"autoload" : {
"psr-4" : {"WP_Mock\\": "./php/WP_Mock"},
Expand Down
8 changes: 4 additions & 4 deletions php/WP_Mock/Tools/Constraints/ExpectationsMet.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class ExpectationsMet extends \PHPUnit\Framework\Constraint\Constraint {

private $_mockery_message;

public function matches( $other ) {
public function matches( $other ): bool {
try {
Mockery::getContainer()->mockery_verify();
} catch ( Exception $e ) {
Expand All @@ -25,15 +25,15 @@ public function matches( $other ) {
*
* @return string
*/
public function toString() {
public function toString(): string {
return 'WP Mock expectations are met';
}

protected function additionalFailureDescription( $other ) {
protected function additionalFailureDescription( $other ): string {
return str_replace( array( "\r", "\n" ), '', (string) $this->_mockery_message );
}

protected function failureDescription( $other ) {
protected function failureDescription( $other ): string {
return $this->toString();
}

Expand Down
4 changes: 2 additions & 2 deletions php/WP_Mock/Tools/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ public function stripTabsAndNewlines( $content ) {
return str_replace( array( "\t", "\r", "\n" ), '', $content );
}

public function expectOutputString( $expectedString ) {
public function expectOutputString( string $expectedString ): void {
if ( is_callable( $this->__contentFilterCallback ) ) {
$expectedString = call_user_func( $this->__contentFilterCallback, $expectedString );
}
Expand Down Expand Up @@ -296,7 +296,7 @@ protected function setUpContentFiltering() {
}
}

public function run( \PHPUnit\Framework\TestResult $result = null ) {
public function run( TestResult $result = null ): TestResult {
if ( $result === null ) {
$result = $this->createResult();
}
Expand Down
2 changes: 2 additions & 0 deletions tests/WP_Mock/DeprecatedListenerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ public function testCheckCalls_scalar_only() {
$result->shouldReceive( 'addFailure' )
->once()
->andReturnUsing( function ( $case, $exception, $int ) use ( $testCase ) {
$int = (int) $int; // It's coming as 0.0
\PHPUnit\Framework\Assert::assertSame( $testCase, $case );
\PHPUnit\Framework\Assert::assertTrue( $exception instanceof \PHPUnit\Framework\RiskyTest );
$message = <<<EOT
Expand Down Expand Up @@ -86,6 +87,7 @@ public function testCheckCalls_non_scalars() {
$this->object->setTestCase( $testCase );
$result = Mockery::mock( '\PHPUnit\Framework\TestResult' );
$testClosure = function ( $case, $exception, $int ) use ( $testCase, $callback1, $object1, $range ) {
$int = (int) $int; // It's coming as 0.0
$callback1 = get_class( $callback1 ) . ':' . spl_object_hash( $callback1 );
$object1 = get_class( $object1 ) . ':' . spl_object_hash( $object1 );
\PHPUnit\Framework\Assert::assertSame( $testCase, $case );
Expand Down

0 comments on commit 9f3525a

Please sign in to comment.