Skip to content

Commit

Permalink
Backport 1.7.0-dev fixes to the 1.6.x series
Browse files Browse the repository at this point in the history
  • Loading branch information
allejo committed Jul 16, 2021
1 parent 9260406 commit 0a3dbf2
Show file tree
Hide file tree
Showing 13 changed files with 143 additions and 60 deletions.
2 changes: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@
/.gitignore export-ignore
/.travis.yml export-ignore
/phpdoc.dist.xml export-ignore

*.diff eol=lf
70 changes: 70 additions & 0 deletions .github/workflows/runTests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
name: Tests

on:
push:
branches:
- v1.6
pull_request:
branches:
- v1.6

jobs:
tests:
name: PHP ${{ matrix.php-versions }} on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
php-versions:
- '5.6'
- '7.0'
- '7.1'
- '7.2'
- '7.3'
- '7.4'
- '8.0'
os: [ubuntu-latest, windows-latest, macOS-latest]

steps:
- name: Checkout
uses: actions/checkout@v2

- name: Set up PHP ${{ matrix.php-versions }}
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-versions }}
extensions: mbstring
coverage: pcov

- name: Setup Problem Matchers for PHP
run: echo "::add-matcher::${{ runner.tool_cache }}/php.json"

- name: Setup Problem Matchers for PHPUnit
run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"

- name: Validate composer.json and composer.lock
run: composer validate

- name: Get Composer Cache Directory
id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"

- name: Cache dependencies
uses: actions/cache@v2
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer-

- name: Install dependencies
run: composer install --prefer-dist --no-progress

- name: Install PHPUnit 8 for PHP 8
if: matrix.php-versions == '8.0'
run: |
rm composer.lock
composer require --dev phpunit/phpunit:8.5.17
git apply --reject --whitespace=fix src/test/patches/php8-return-types.diff
- name: Run test suite
run: composer run-script test -- --coverage-text
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/docs
/nbproject
/vendor
*.cache
composer.lock
33 changes: 0 additions & 33 deletions .travis.yml

This file was deleted.

22 changes: 0 additions & 22 deletions appveyor.yml

This file was deleted.

3 changes: 3 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@
"autoload": {
"psr-0": { "org\\bovigo\\vfs\\": "src/main/php" }
},
"scripts": {
"test": "phpunit"
},
"extra": {
"branch-alias": {
"dev-master": "1.6.x-dev"
Expand Down
2 changes: 1 addition & 1 deletion phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,6 @@

<php>
<ini name="memory_limit" value="-1"/>
<ini name="error_reporting" value="30719"/> <!-- E_ALL | E_STRICT -->
<ini name="error_reporting" value="30719"/> <!-- E_ALL | E_STRICT -->
</php>
</phpunit>
2 changes: 1 addition & 1 deletion src/main/php/org/bovigo/vfs/vfsStreamFile.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class vfsStreamFile extends vfsStreamAbstractContent
*/
public function __construct($name, $permissions = null)
{
$this->content = new StringBasedFileContent(null);
$this->content = new StringBasedFileContent('');
$this->type = vfsStreamContent::TYPE_FILE;
parent::__construct($name, $permissions);
}
Expand Down
32 changes: 32 additions & 0 deletions src/test/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,38 @@

require __DIR__ . "/../../vendor/autoload.php";

if (!class_exists("PHPUnit_Framework_TestCase"))
{
class_alias('\PHPUnit\Framework\TestCase', 'PHPUnit_Framework_TestCase');
}

if (!class_exists("PHPUnit_Framework_Error"))
{
class_alias('PHPUnit\Framework\Error\Warning', 'PHPUnit_Framework_Error');
}

if (!class_exists("PHPUnit_Util_ErrorHandler"))
{
class PHPUnit_Util_ErrorHandler {
public static function handleError($errno, $errstr, $errfile, $errline)
{
$errorHandler = new \PHPUnit\Util\ErrorHandler(
true,
true,
true,
true
);

return $errorHandler($errno, $errstr, $errfile, $errline);
}
}
}

if (!class_exists("PHPUnit_TextUI_ResultPrinter"))
{
class PHPUnit_TextUI_ResultPrinter extends \PHPUnit\TextUI\ResultPrinter {}
}

/**
* A modified version of PHPUnit's TestCase to rid ourselves of deprecation
* warnings since we're using two different versions of PHPUnit in this branch
Expand Down
21 changes: 21 additions & 0 deletions src/test/patches/php8-return-types.diff
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
diff --git a/vendor/phpunit/phpunit/src/Framework/TestCase.php b/vendor/phpunit/phpunit/src/Framework/TestCase.php
index 1223ca0c8..b5725af4c 100644
--- a/vendor/phpunit/phpunit/src/Framework/TestCase.php
+++ b/vendor/phpunit/phpunit/src/Framework/TestCase.php
@@ -475,14 +475,14 @@ public static function tearDownAfterClass(): void
/**
* This method is called before each test.
*/
- protected function setUp(): void
+ protected function setUp()
{
}

/**
* This method is called after each test.
*/
- protected function tearDown(): void
+ protected function tearDown()
{
}

2 changes: 1 addition & 1 deletion src/test/php/org/bovigo/vfs/FilenameTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public function worksWithCorrectName()
/**
* @test
* @expectedException UnexpectedValueException
* @expectedExceptionMessage failed to open dir
* @expectedExceptionMessage ailed to open dir
*/
public function doesNotWorkWithInvalidName()
{
Expand Down
2 changes: 1 addition & 1 deletion src/test/php/org/bovigo/vfs/vfsStreamFileTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public function defaultValues()
*/
public function content()
{
$this->assertNull($this->file->getContent());
$this->assertEquals('', $this->file->getContent());
$this->assertSame($this->file, $this->file->setContent('bar'));
$this->assertEquals('bar', $this->file->getContent());
$this->assertSame($this->file, $this->file->withContent('baz'));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,18 @@ class vfsStreamWrapperSelectStreamTestCase extends \BC_PHPUnit_Framework_TestCas
{
/**
* @test
* @expectedException \PHPUnit_Framework_Error
*/
public function selectStream()
{
if (PHP_VERSION_ID >= 80000)
{
$this->expectException(\ValueError::class);
}
else
{
$this->expectException(\PHPUnit_Framework_Error::class);
}

$root = vfsStream::setup();
$file = vfsStream::newFile('foo.txt')->at($root)->withContent('testContent');

Expand Down

0 comments on commit 0a3dbf2

Please sign in to comment.