Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move to phpunit v7 #12

Merged
merged 5 commits into from
Apr 7, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .scrutinizer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ build:
PHPCS_REPORT_FILE: 'build/reports/cs-data'
COMPOSER_OPTIONS: '--optimize-autoloader'
php:
version: "7.0"
version: "7.1"
timezone: UTC
postgresql: false
redis: false
Expand Down
3 changes: 2 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
language: php

php:
- '7.0'
- '7.1'
- '7.2'

env:
TEST_OUTPUT_STYLE: 'pretty'
Expand Down
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
# PhpUnitExtended
[![Scrutinizer Build Status](https://img.shields.io/scrutinizer/build/g/yoanm/PhpUnitExtended.svg?label=Scrutinizer)](https://scrutinizer-ci.com/g/yoanm/PhpUnitExtended/?branch=master) [![Scrutinizer Code Quality](https://img.shields.io/scrutinizer/g/yoanm/PhpUnitExtended.svg?label=Code%20quality)](https://scrutinizer-ci.com/g/yoanm/PhpUnitExtended/?branch=master) [![Code Coverage](https://img.shields.io/scrutinizer/coverage/g/yoanm/PhpUnitExtended.svg?label=Coverage)](https://scrutinizer-ci.com/g/yoanm/PhpUnitExtended/?branch=master)
[![License](https://img.shields.io/github/license/yoanm/PhpUnitExtended.svg)](https://github.com/yoanm/PhpUnitExtended) [![Code size](https://img.shields.io/github/languages/code-size/yoanm/PhpUnitExtended.svg)](https://github.com/yoanm/PhpUnitExtended) [![PHP Versions](https://img.shields.io/badge/php-7.1%20%2F%207.2-8892BF.svg)](https://php.net/)

[![Travis Build Status](https://img.shields.io/travis/yoanm/PhpUnitExtended/master.svg?label=travis)](https://travis-ci.org/yoanm/PhpUnitExtended) [![PHP Versions](https://img.shields.io/badge/php-7.0-8892BF.svg)](https://php.net/)
[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/yoanm/PhpUnitExtended/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/yoanm/PhpUnitExtended/?branch=master) [![Build Status](https://scrutinizer-ci.com/g/yoanm/PhpUnitExtended/badges/build.png?b=master)](https://scrutinizer-ci.com/g/yoanm/PhpUnitExtended/build-status/master) [![Code Coverage](https://scrutinizer-ci.com/g/yoanm/PhpUnitExtended/badges/coverage.png?b=master)](https://scrutinizer-ci.com/g/yoanm/PhpUnitExtended/?branch=master)

[![Latest Stable Version](https://img.shields.io/packagist/v/yoanm/php-unit-extended.svg)](https://packagist.org/packages/yoanm/php-unit-extended)
[![Travis Build Status](https://img.shields.io/travis/yoanm/PhpUnitExtended/master.svg?label=travis)](https://travis-ci.org/yoanm/PhpUnitExtended) [![Travis PHP versions](https://img.shields.io/travis/php-v/yoanm/PhpUnitExtended.svg)](https://travis-ci.org/yoanm/PhpUnitExtended)

[![Latest Stable Version](https://img.shields.io/packagist/v/yoanm/php-unit-extended.svg)](https://packagist.org/packages/yoanm/php-unit-extended) [![Packagist PHP version](https://img.shields.io/packagist/php-v/yoanm/php-unit-extended.svg)](https://packagist.org/packages/yoanm/php-unit-extended)

Php library to extend PhpUnit

Expand Down
5 changes: 2 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
"name": "yoanm/php-unit-extended",
"type": "library",
"license": "MIT",
"version": "0.3.0",
"description": "Php library to extend PhpUnit",
"keywords": ["PhpUnit"],
"authors": [
Expand All @@ -28,10 +27,10 @@
}
},
"require": {
"php": ">=7.0"
"php": ">=7.1"
},
"require-dev": {
"phpunit/phpunit": "~6.0",
"phpunit/phpunit": "~7.0",
"squizlabs/php_codesniffer": "3.*",
"behat/behat": "~3.0",
"symfony/process": "~3.0"
Expand Down
22 changes: 11 additions & 11 deletions src/Listener/DelegatingListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class DelegatingListener implements TestListener
/**
* {@inheritdoc}
*/
public function addListener(TestListener $listener)
public function addListener(TestListener $listener) : void
{
$this->listenerList[] = $listener;
}
Expand All @@ -34,7 +34,7 @@ public function getListenerList()
/**
* {@inheritdoc}
*/
public function addError(Test $test, \Exception $e, $time)
public function addError(Test $test, \Throwable $e, float $time) : void
{
foreach ($this->listenerList as $listener) {
$listener->addError($test, $e, $time);
Expand All @@ -44,7 +44,7 @@ public function addError(Test $test, \Exception $e, $time)
/**
* {@inheritdoc}
*/
public function addWarning(Test $test, Warning $e, $time)
public function addWarning(Test $test, Warning $e, float $time) : void
{
foreach ($this->listenerList as $listener) {
$listener->addWarning($test, $e, $time);
Expand All @@ -54,7 +54,7 @@ public function addWarning(Test $test, Warning $e, $time)
/**
* {@inheritdoc}
*/
public function addFailure(Test $test, AssertionFailedError $e, $time)
public function addFailure(Test $test, AssertionFailedError $e, float $time) : void
{
foreach ($this->listenerList as $listener) {
$listener->addFailure($test, $e, $time);
Expand All @@ -64,7 +64,7 @@ public function addFailure(Test $test, AssertionFailedError $e, $time)
/**
* {@inheritdoc}
*/
public function addIncompleteTest(Test $test, \Exception $e, $time)
public function addIncompleteTest(Test $test, \Throwable $e, float $time) : void
{
foreach ($this->listenerList as $listener) {
$listener->addIncompleteTest($test, $e, $time);
Expand All @@ -74,7 +74,7 @@ public function addIncompleteTest(Test $test, \Exception $e, $time)
/**
* {@inheritdoc}
*/
public function addRiskyTest(Test $test, \Exception $e, $time)
public function addRiskyTest(Test $test, \Throwable $e, float $time) : void
{
foreach ($this->listenerList as $listener) {
$listener->addRiskyTest($test, $e, $time);
Expand All @@ -84,7 +84,7 @@ public function addRiskyTest(Test $test, \Exception $e, $time)
/**
* {@inheritdoc}
*/
public function addSkippedTest(Test $test, \Exception $e, $time)
public function addSkippedTest(Test $test, \Throwable $e, float $time) : void
{
foreach ($this->listenerList as $listener) {
$listener->addSkippedTest($test, $e, $time);
Expand All @@ -94,7 +94,7 @@ public function addSkippedTest(Test $test, \Exception $e, $time)
/**
* {@inheritdoc}
*/
public function startTestSuite(TestSuite $suite)
public function startTestSuite(TestSuite $suite) : void
{
foreach ($this->listenerList as $listener) {
$listener->startTestSuite($suite);
Expand All @@ -104,7 +104,7 @@ public function startTestSuite(TestSuite $suite)
/**
* {@inheritdoc}
*/
public function endTestSuite(TestSuite $suite)
public function endTestSuite(TestSuite $suite) : void
{
foreach ($this->listenerList as $listener) {
$listener->endTestSuite($suite);
Expand All @@ -114,7 +114,7 @@ public function endTestSuite(TestSuite $suite)
/**
* {@inheritdoc}
*/
public function startTest(Test $test)
public function startTest(Test $test) : void
{
foreach ($this->listenerList as $listener) {
$listener->startTest($test);
Expand All @@ -124,7 +124,7 @@ public function startTest(Test $test)
/**
* {@inheritdoc}
*/
public function endTest(Test $test, $time)
public function endTest(Test $test, float $time) : void
{
foreach ($this->listenerList as $listener) {
$listener->endTest($test, $time);
Expand Down
19 changes: 10 additions & 9 deletions src/Listener/RiskyToFailedListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,27 +17,28 @@ class RiskyToFailedListener implements TestListener
{
use TestListenerDefaultImplementation;

public function addWarning(Test $test, Warning $e, $time)
/**
* {@inheritdoc}
*/
public function addWarning(Test $test, Warning $e, float $time) : void
{
$this->addErrorIfNeeded($test, $e, $time);
}

/**
* @param Test $test
* @param \Exception $e
* @param float $time
* {@inheritdoc}
*/
public function addRiskyTest(Test $test, \Exception $e, $time)
public function addRiskyTest(Test $test, \Throwable $e, float $time) : void
{
$this->addErrorIfNeeded($test, $e, $time);
}

/**
* @param Test $test
* @param \Exception $e
* @param \Throwable $e
* @param $time
*/
protected function addErrorIfNeeded(Test $test, \Exception $e, $time)
protected function addErrorIfNeeded(Test $test, \Throwable $e, $time)
{
/* Must be TestCase instance to have access to "getTestResultObject" method */
if ($test instanceof TestCase) {
Expand All @@ -59,11 +60,11 @@ protected function addErrorIfNeeded(Test $test, \Exception $e, $time)
}

/**
* @param \Exception $e
* @param \Throwable $e
*
* @return null|string
*/
protected function getErrorReason(\Exception $e)
protected function getErrorReason(\Throwable $e)
{
$reason = null;
switch (true) {
Expand Down
6 changes: 2 additions & 4 deletions src/Listener/StrictCoverageListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,9 @@ class StrictCoverageListener implements TestListener
use TestListenerDefaultImplementation;

/**
* @param Test $test
* @param \Exception $e
* @param float $time
* {@inheritdoc}
*/
public function addRiskyTest(Test $test, \Exception $e, $time)
public function addRiskyTest(Test $test, \Throwable $e, float $time) : void
{
if (/* Must be PHPUnit_Framework_TestCase instance to have access to "getTestResultObject" method */
$test instanceof TestCase
Expand Down
8 changes: 4 additions & 4 deletions tests/Functional/Listener/DelegatingListenerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ public function testShouldHandleSkippedTest()
$this->listener->addSkippedTest($test->reveal(), $exception->reveal(), $time);
}

public function testStartTestSuite()
public function testShouldHandleTestSuiteStart()
{
/** @var TestListener|ObjectProphecy $delegate */
$delegate = $this->prophesize(TestListener::class);
Expand All @@ -165,7 +165,7 @@ public function testStartTestSuite()
$this->listener->startTestSuite($testSuite->reveal());
}

public function testEndTestSuite()
public function testShouldHandleTestSuiteEnd()
{
/** @var TestListener|ObjectProphecy $delegate */
$delegate = $this->prophesize(TestListener::class);
Expand All @@ -180,7 +180,7 @@ public function testEndTestSuite()
$this->listener->endTestSuite($testSuite->reveal());
}

public function testStartTest()
public function testShouldHandleTestStart()
{
/** @var TestListener|ObjectProphecy $delegate */
$delegate = $this->prophesize(TestListener::class);
Expand All @@ -195,7 +195,7 @@ public function testStartTest()
$this->listener->startTest($test->reveal());
}

public function testEndTest()
public function testShouldHandleTestEnd()
{
$time = 0.2;

Expand Down
14 changes: 10 additions & 4 deletions tests/Functional/Listener/RiskyToFailedListenerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,17 @@ public function testShouldHandleBadCoverageTagWarning()
/**
* @dataProvider getExceptionMessageProvider
*
* @param string $exceptionClass
* @param string $expectedReason
* @param $exceptionClass
* @param $expectedReason
* @param bool|true $called
* @param null $exceptionMessage
*/
public function testHandleRiskyTest($exceptionClass, $expectedReason, $called = true, $exceptionMessage = null)
{
public function testShouldHandleRiskyTestWith(
$exceptionClass,
$expectedReason,
$called = true,
$exceptionMessage = null
) {
$time = 0.3;

/** @var TestCase|ObjectProphecy $test */
Expand Down
2 changes: 1 addition & 1 deletion tests/Functional/Listener/StrictCoverageListenerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public function setUp()
*
* @param array $baseCoverageData
*/
public function testCoverageRemoval(array $baseCoverageData)
public function testShouldCorrectlyHandleCoverageRemovalWith(array $baseCoverageData)
{
$time = 0.3;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public function testShouldHaveRiskyToFailListenerByDefault()
);
}

public function testShouldStrictCoverageListenerByDefault()
public function testShouldHaveStrictCoverageListenerByDefault()
{
$this->shouldHaveListenerClass(
StrictCoverageListener::class,
Expand Down