Skip to content
This repository has been archived by the owner on Mar 30, 2018. It is now read-only.

Commit

Permalink
Add PHPUnit 6 support (#270)
Browse files Browse the repository at this point in the history
  • Loading branch information
theofidry committed Oct 8, 2017
1 parent ef73419 commit 4ee9617
Show file tree
Hide file tree
Showing 20 changed files with 34 additions and 73 deletions.
1 change: 0 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
language: php

php:
- 5.6
- 7.0
- 7.1

Expand Down
9 changes: 1 addition & 8 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,6 @@
"support": {
"issues": "https://github.com/padraic/humbug/issues"
},
"repositories": [
{
"type": "vcs",
"url": "https://github.com/humbug/phpunit-accelerator"
}
],
"require": {
"php": "^7.0",
"ext-ctype": "*",
Expand All @@ -34,12 +28,11 @@
"symfony/process": "^2.6|^3.0",
"symfony/event-dispatcher": "^2.6|^3.0",
"sebastian/diff": "^2.0",
"padraic/phpunit-accelerator": "dev-master",
"padraic/phpunit-extensions": "^1.0.0",
"padraic/phar-updater": "^1.0.0"
},
"require-dev": {
"mockery/mockery": "^0.9",
"mockery/mockery": "^1.0",
"behat/behat": "^3.3",
"symfony/filesystem": "^2.6|^3.0",
"mikey179/vfsStream": "^1.4",
Expand Down
18 changes: 3 additions & 15 deletions features/logging/developer_uses_json_logging_configuration.feature
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Feature: Use Humbug
And the test file "tests/FooNormalTest.php" contains:
"""
<?php
class FooNormalTest extends \PHPUnit_Framework_TestCase
class FooNormalTest extends \PHPUnit\Framework\TestCase
{
public function testAddsNumbers() {
$foo = new Foo;
Expand All @@ -40,7 +40,7 @@ Feature: Use Humbug
And the test file "tests/FooErrorTest.php" contains:
"""
<?php
class FooErrorTest extends \PHPUnit_Framework_TestCase
class FooErrorTest extends \PHPUnit\Framework\TestCase
{
public function testAddsNumbersError() {
$foo = new Foo;
Expand All @@ -54,7 +54,7 @@ Feature: Use Humbug
And the test file "tests/FooTimeoutTest.php" contains:
"""
<?php
class FooTimeoutTest extends \PHPUnit_Framework_TestCase
class FooTimeoutTest extends \PHPUnit\Framework\TestCase
{
public function testAddsNumbersTimeout() {
$foo = new Foo;
Expand All @@ -65,18 +65,6 @@ Feature: Use Humbug
}
}
"""
And the test file "tests/FooEscapeTest.php" contains:
"""
<?php
class FooEscapeTest extends \PHPUnit_Framework_TestCase
{
public function testMultipliesNumbers() {
$foo = new Foo;
$foo->add4(2, 1);
// No assertion here...
}
}
"""
And the phpunit bootstrap file "tests/bootstrap.php" contains:
"""
<?php
Expand Down
18 changes: 3 additions & 15 deletions features/logging/developer_uses_text_logging_configuration.feature
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Feature: Use Humbug
And the test file "tests/FooNormalTest.php" contains:
"""
<?php
class FooNormalTest extends \PHPUnit_Framework_TestCase
class FooNormalTest extends \PHPUnit\Framework\TestCase
{
public function testAddsNumbers() {
$foo = new Foo;
Expand All @@ -40,7 +40,7 @@ Feature: Use Humbug
And the test file "tests/FooErrorTest.php" contains:
"""
<?php
class FooErrorTest extends \PHPUnit_Framework_TestCase
class FooErrorTest extends \PHPUnit\Framework\TestCase
{
public function testAddsNumbersError() {
$foo = new Foo;
Expand All @@ -54,7 +54,7 @@ Feature: Use Humbug
And the test file "tests/FooTimeoutTest.php" contains:
"""
<?php
class FooTimeoutTest extends \PHPUnit_Framework_TestCase
class FooTimeoutTest extends \PHPUnit\Framework\TestCase
{
public function testAddsNumbersTimeout() {
$foo = new Foo;
Expand All @@ -65,18 +65,6 @@ Feature: Use Humbug
}
}
"""
And the test file "tests/FooEscapeTest.php" contains:
"""
<?php
class FooEscapeTest extends \PHPUnit_Framework_TestCase
{
public function testMultipliesNumbers() {
$foo = new Foo;
$foo->add4(2, 1);
// No assertion here...
}
}
"""
And the phpunit bootstrap file "tests/bootstrap.php" contains:
"""
<?php
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Feature: Use Humbug
And the test file "tests/FooTest.php" contains:
"""
<?php
class FooTest extends \PHPUnit_Framework_TestCase
class FooTest extends \PHPUnit\Framework\TestCase
{
public function testAddsNumbers() {
$foo = new Foo;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Feature: Use Humbug
And the test file "tests/FooTest.php" contains:
"""
<?php
class FooTest extends \PHPUnit_Framework_TestCase
class FooTest extends \PHPUnit\Framework\TestCase
{
public function testAddsNumbers() {
$foo = new Foo;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Feature: Use Humbug
And the test file "tests/FooTest.php" contains:
"""
<?php
class FooTest extends \PHPUnit_Framework_TestCase
class FooTest extends \PHPUnit\Framework\TestCase
{
public function testAddsNumbers() {
$foo = new Foo;
Expand Down
3 changes: 1 addition & 2 deletions features/running/developer_sees_mutant_error_result.feature
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ Feature: Use Humbug
As a developer
I need to be able to run Humbug

@php:^5.6
Scenario:
Given the class file "src/Foo.php" contains:
"""
Expand All @@ -18,7 +17,7 @@ Feature: Use Humbug
And the test file "tests/FooTest.php" contains:
"""
<?php
class FooTest extends \PHPUnit_Framework_TestCase
class FooTest extends \PHPUnit\Framework\TestCase
{
public function testAddsNumbers() {
$foo = new Foo;
Expand Down
5 changes: 3 additions & 2 deletions features/running/developer_sees_mutant_escape_result.feature
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,13 @@ Feature: Use Humbug
And the test file "tests/FooTest.php" contains:
"""
<?php
class FooTest extends \PHPUnit_Framework_TestCase
class FooTest extends \PHPUnit\Framework\TestCase
{
public function testAddsNumbers() {
$foo = new Foo;
$foo->add(2, 1);
// Whoops! No assertion!
// Whoops! No good assertion!
$this->assertTrue(true);
}
}
"""
Expand Down
2 changes: 1 addition & 1 deletion features/running/developer_sees_mutant_kill_result.feature
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Feature: Use Humbug
And the test file "tests/FooTest.php" contains:
"""
<?php
class FooTest extends \PHPUnit_Framework_TestCase
class FooTest extends \PHPUnit\Framework\TestCase
{
public function testAddsNumbers() {
$foo = new Foo;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Feature: Use Humbug
And the test file "tests/FooTest.php" contains:
"""
<?php
class FooTest extends \PHPUnit_Framework_TestCase
class FooTest extends \PHPUnit\Framework\TestCase
{
public function testAddsNumbers() {
$foo = new Foo;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ Feature: Use Humbug
And the test file "tests/FooTest.php" contains:
"""
<?php
class FooTest extends \PHPUnit_Framework_TestCase
class FooTest extends \PHPUnit\Framework\TestCase
{
public function testAddsNumbers() {
true === true;
$this->assertTrue(true);
// Well, that executes nothing...
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@

use Humbug\Phpunit\Listener\TimeCollectorListener;
use Humbug\Phpunit\Logger\JsonLogger;
use Humbug\Phpunit\Writer\JsonWriter;

class JsonLoggingTimeCollectorListener extends TimeCollectorListener
{
public function __construct($logFile, $rootSuiteNestingLevel = 0)
{
$logger = new JsonLogger($logFile);
$logger = new JsonLogger(new JsonWriter($logFile));

parent::__construct($logger, $rootSuiteNestingLevel);
}
Expand Down
5 changes: 0 additions & 5 deletions src/Adapter/Phpunit/XmlConfigurationBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,11 +103,6 @@ public function getConfiguration()
$xmlConfiguration->addWhiteListFilter($this->coverageWhiteListDirs, $this->coverageExcludeDirs);
}

if ($this->acceleratorListener) {
$acceleratorListener = new ObjectVisitor('\MyBuilder\PhpunitAccelerator\TestListener', [true]);
$xmlConfiguration->addListener($acceleratorListener);
}

if ($this->pathToTimeStats) {
$timeCollectionListener = new ObjectVisitor('\Humbug\Adapter\Phpunit\Listeners\JsonLoggingTimeCollectorListener', [
$this->pathToTimeStats,
Expand Down
15 changes: 2 additions & 13 deletions tests/Adapter/Phpunit/XmlConfigurationBuilderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,17 +57,6 @@ public function testShouldBuildXmlConfigurationFromConfigurationDirectory()
$xmlConfiguration->wasCalledWith('replacePathsToAbsolutePaths', [$expectedPathVisitor, $expectedWildcardVisitor], 0);
}

public function testShouldBuildConfigurationWithAcceleratorListener()
{
$this->builder->setAcceleratorListener();

$xmlConfiguration = $this->builder->getConfiguration();

$acceleratorListener = new ObjectVisitor('\MyBuilder\PhpunitAccelerator\TestListener', [true]);

$xmlConfiguration->wasCalledWith('addListener', [$acceleratorListener]);
}

public function testShouldBuildConfigurationWithPhpCoverage()
{
$this->builder->setPhpCoverage('file/coverage.php');
Expand Down Expand Up @@ -188,7 +177,7 @@ public function addEnvironmentVariable($name, $value)

public function wasCalledWith($function, $arguments, $at = 1)
{
\PHPUnit_Framework_Assert::assertTrue(isset($this->calls[$at][$function]));
\PHPUnit_Framework_Assert::assertEquals($arguments, $this->calls[$at][$function]);
\PHPUnit\Framework\Assert::assertTrue(isset($this->calls[$at][$function]));
\PHPUnit\Framework\Assert::assertEquals($arguments, $this->calls[$at][$function]);
}
}
5 changes: 2 additions & 3 deletions tests/Adapter/_files/regression/wildcard-dirs/phpunit.xml
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>

<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/4.4/phpunit.xsd"
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/6.0/phpunit.xsd"
backupGlobals="false"
backupStaticAttributes="false"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"
syntaxCheck="false">
stopOnFailure="false">

<testsuites>
<testsuite name="Test Suite">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@ class SecondTest extends \PHPUnit\Framework\TestCase
{
public function testSecond()
{
$this->assertTrue(true);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@ class FirstTest extends \PHPUnit\Framework\TestCase
{
public function testFirst()
{
$this->assertTrue(true);
}
}
6 changes: 5 additions & 1 deletion tests/ContainerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,21 @@
use Humbug\Container;
use Humbug\Exception\InvalidArgumentException;
use Mockery as m;
use Mockery\Adapter\Phpunit\MockeryPHPUnitIntegration;
use Symfony\Component\Finder\Finder;

class ContainerTest extends \PHPUnit\Framework\TestCase
{
use MockeryPHPUnitIntegration;

private $container;

public function setup()
{
$this->container = new Container(['timeout'=>10]);
}


public function testShouldHaveAdapterOptionsAfterCreate()
{
$input = [
Expand Down Expand Up @@ -95,7 +99,7 @@ public function testsetTempDirectory()
*/
public function testsetTempDirectoryThrowsExceptionOnUnwriteableParam()
{
$result = $this->container->setTempDirectory('/really/does/not/exist');
$this->container->setTempDirectory('/really/does/not/exist');
}

public function testSetPrimaryTimeout()
Expand Down
3 changes: 3 additions & 0 deletions tests/File/CollectionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,14 @@

use Humbug\File\Collection;
use Mockery as m;
use Mockery\Adapter\Phpunit\MockeryPHPUnitIntegration;
use org\bovigo\vfs\vfsStream;
use org\bovigo\vfs\vfsStreamDirectory;

class CollectionTest extends \PHPUnit\Framework\TestCase
{
use MockeryPHPUnitIntegration;

private $tmp;

public function setup()
Expand Down

0 comments on commit 4ee9617

Please sign in to comment.