Skip to content

Commit c6ba917

Browse files
Added support for PHP 8.0 (#180)
1 parent 3d70f35 commit c6ba917

9 files changed

+75
-20
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/.phpunit.result.cache
12
/composer.lock
23
/phpunit.xml
34
/vendor

.travis.yml

+18-4
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,23 @@ matrix:
4141
- php: 7.4
4242
dist: bionic
4343
env: SYMFONY_VERSION=^5.0
44+
- php: nightly
45+
dist: bionic
46+
env: SYMFONY_VERSION=^3.4
47+
- php: nightly
48+
dist: bionic
49+
env: SYMFONY_VERSION=^4.0
50+
- php: nightly
51+
dist: bionic
52+
env: SYMFONY_VERSION=^5.0
4453

45-
before_install: travis_retry composer require "symfony/process:${SYMFONY_VERSION}" --no-update
46-
47-
install: travis_retry composer install --prefer-dist --no-progress -n -o
54+
before_install:
55+
- composer self-update --2
56+
- travis_retry composer require "symfony/process:${SYMFONY_VERSION}" --no-update
4857

49-
script: vendor/bin/phpunit
58+
install:
59+
- if [[ "$TRAVIS_PHP_VERSION" != 'nightly' ]]; then travis_retry composer update --prefer-dist --no-progress -n -o; fi
60+
- if [[ "$TRAVIS_PHP_VERSION" = 'nightly' ]]; then travis_retry composer update --ignore-platform-req=php --prefer-dist --no-progress -n -o; fi
61+
62+
script:
63+
- vendor/bin/phpunit

composer.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,14 @@
3131
}
3232
},
3333
"require": {
34-
"php": "^5.6 || ^7.0",
34+
"php": "^5.6 || ^7.0 || ^8.0",
3535
"ext-pcre": "*",
3636
"symfony/polyfill-mbstring": "^1.7",
37-
"symfony/process": "^3.4|^4.0|^5.0"
37+
"symfony/process": "^3.4 || ^4.0 || ^5.0"
3838
},
3939
"require-dev": {
4040
"ext-fileinfo": "*",
41-
"phpunit/phpunit": "^5.7|^6.5|^7.0",
41+
"phpunit/phpunit": "^5.7 || ^6.5 || ^7.0 || ^8.0 || ^9.0",
4242
"psr/log": "^1.0"
4343
},
4444
"suggest": {

phpunit.xml.dist

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
convertNoticesToExceptions="true"
1010
convertWarningsToExceptions="true"
1111
failOnRisky="true"
12-
failOnWarning="true"
12+
failOnWarning="false"
1313
processIsolation="false"
1414
stopOnError="false"
1515
stopOnFailure="false"

tests/Gitonomy/Git/Tests/AbstractTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ public static function createTempDir()
117117
*
118118
* @param string $dir directory to delete
119119
*/
120-
public static function deleteDir($dir)
120+
protected static function deleteDir($dir)
121121
{
122122
$iterator = new \RecursiveDirectoryIterator($dir, \FilesystemIterator::SKIP_DOTS | \FilesystemIterator::FOLLOW_SYMLINKS);
123123
$iterator = new \RecursiveIteratorIterator($iterator, \RecursiveIteratorIterator::CHILD_FIRST);

tests/Gitonomy/Git/Tests/AdminTest.php

+9-3
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,20 @@ class AdminTest extends AbstractTest
2121
{
2222
private $tmpDir;
2323

24-
protected function setUp()
24+
/**
25+
* @before
26+
*/
27+
public function setUpTmpDir()
2528
{
2629
$this->tmpDir = self::createTempDir();
2730
}
2831

29-
protected function tearDown()
32+
/**
33+
* @after
34+
*/
35+
public function tearDownTmpDir()
3036
{
31-
$this->deleteDir(self::createTempDir());
37+
self::deleteDir(self::createTempDir());
3238
}
3339

3440
public function testBare()

tests/Gitonomy/Git/Tests/BlobTest.php

+11-2
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,11 @@ public function testGetContent($repository)
3030
{
3131
$blob = $this->getReadmeBlob($repository);
3232

33-
$this->assertContains(self::README_FRAGMENT, $blob->getContent());
33+
if (method_exists($this, 'assertStringContainsString')) {
34+
$this->assertStringContainsString(self::README_FRAGMENT, $blob->getContent());
35+
} else {
36+
$this->assertContains(self::README_FRAGMENT, $blob->getContent());
37+
}
3438
}
3539

3640
/**
@@ -50,7 +54,12 @@ public function testNotExisting($repository)
5054
public function testGetMimetype($repository)
5155
{
5256
$blob = $this->getReadmeBlob($repository);
53-
$this->assertRegexp('#text/plain#', $blob->getMimetype());
57+
58+
if (method_exists($this, 'assertMatchesRegularExpression')) {
59+
$this->assertMatchesRegularExpression('#text/plain#', $blob->getMimetype());
60+
} else {
61+
$this->assertRegExp('#text/plain#', $blob->getMimetype());
62+
}
5463
}
5564

5665
/**

tests/Gitonomy/Git/Tests/HooksTest.php

+24-4
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,10 @@ class HooksTest extends AbstractTest
1919
{
2020
private static $symlinkOnWindows = null;
2121

22-
public static function setUpBeforeClass()
22+
/**
23+
* @beforeClass
24+
*/
25+
public static function setUpWindows()
2326
{
2427
if (defined('PHP_WINDOWS_VERSION_MAJOR')) {
2528
self::$symlinkOnWindows = true;
@@ -52,6 +55,7 @@ public function assertHasHook($repository, $hook)
5255
$file = $this->hookPath($repository, $hook);
5356

5457
$this->assertTrue($repository->getHooks()->has($hook), "hook $hook in repository");
58+
5559
$this->assertFileExists($file, "Hook $hook is present");
5660
}
5761

@@ -60,7 +64,12 @@ public function assertNoHook($repository, $hook)
6064
$file = $this->hookPath($repository, $hook);
6165

6266
$this->assertFalse($repository->getHooks()->has($hook), "No hook $hook in repository");
63-
$this->assertFileNotExists($file, "Hook $hook is not present");
67+
68+
if (method_exists($this, 'assertFileDoesNotExist')) {
69+
$this->assertFileDoesNotExist($file, "Hook $hook is not present");
70+
} else {
71+
$this->assertFileNotExists($file, "Hook $hook is not present");
72+
}
6473
}
6574

6675
/**
@@ -104,7 +113,12 @@ public function testSymlink($repository)
104113
$repository->getHooks()->setSymlink('foo', $file);
105114

106115
$this->assertTrue(is_link($this->hookPath($repository, 'foo')), 'foo hook is a symlink');
107-
$this->assertEquals(str_replace('\\', '/', $file), str_replace('\\', '/', readlink($this->hookPath($repository, 'foo'))), 'target of symlink is correct');
116+
117+
$this->assertEquals(
118+
str_replace('\\', '/', $file),
119+
str_replace('\\', '/', readlink($this->hookPath($repository, 'foo'))),
120+
'target of symlink is correct'
121+
);
108122
}
109123

110124
/**
@@ -147,6 +161,7 @@ public function testSet_Existing_ThrowsLogicException($repository)
147161
$repository->getHooks()->set('foo', 'bar');
148162

149163
$this->expectException(LogicException::class);
164+
150165
$repository->getHooks()->set('foo', 'bar');
151166
}
152167

@@ -159,7 +174,12 @@ public function testRemove($repository)
159174
touch($file);
160175

161176
$repository->getHooks()->remove('foo');
162-
$this->assertFileNotExists($file);
177+
178+
if (method_exists($this, 'assertFileDoesNotExist')) {
179+
$this->assertFileDoesNotExist($file);
180+
} else {
181+
$this->assertFileNotExists($file);
182+
}
163183
}
164184

165185
/**

tests/Gitonomy/Git/Tests/RepositoryTest.php

+7-2
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,17 @@ class RepositoryTest extends AbstractTest
2121
/**
2222
* @dataProvider provideFoobar
2323
*/
24-
public function testGetBlob_WithExisting_Works($repository)
24+
public function testGetBlobWithExistingWorks($repository)
2525
{
2626
$blob = $repository->getCommit(self::LONGFILE_COMMIT)->getTree()->resolvePath('README.md');
2727

2828
$this->assertInstanceOf(Blob::class, $blob, 'getBlob() returns a Blob object');
29-
$this->assertContains('Foo Bar project', $blob->getContent(), 'file is correct');
29+
30+
if (method_exists($this, 'assertStringContainsString')) {
31+
$this->assertStringContainsString('Foo Bar project', $blob->getContent(), 'file is correct');
32+
} else {
33+
$this->assertContains('Foo Bar project', $blob->getContent(), 'file is correct');
34+
}
3035
}
3136

3237
/**

0 commit comments

Comments
 (0)