1
0
mirror of https://github.com/splitbrain/php-archive.git synced 2025-01-29 03:27:57 +01:00

updated testing

* test on github not travis
* run phpunit8 (tests only on 7.2+)
* use github action to build api docs
This commit is contained in:
Andreas Gohr 2021-02-05 13:30:53 +01:00
parent d4cf2d9a2d
commit d53bf2ed77
10 changed files with 84 additions and 91 deletions

21
.github/workflows/apigen.yml vendored Normal file
View File

@ -0,0 +1,21 @@
name: ApiGen
on:
workflow_run:
workflows: ["Unit Tests"]
branches: [master]
types:
- completed
jobs:
Document_Generator:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: 📝 ApiGen PHP Document Generator
uses: varunsridharan/action-apigen@2.1
with:
cached_apigen: 'no'
source_folder: 'src'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

36
.github/workflows/test.yml vendored Normal file
View File

@ -0,0 +1,36 @@
name: Unit Tests
on: [push, pull_request]
jobs:
run:
name: PHP ${{ matrix.php-versions }}
runs-on: ubuntu-latest
if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository
strategy:
matrix:
php-versions: ['7.2', '7.3', '7.4', '8.0']
fail-fast: false
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-versions }}
- name: Setup problem matchers
run: |
echo ::add-matcher::${{ runner.tool_cache }}/php.json
echo ::add-matcher::${{ runner.tool_cache }}/phpunit.json
- name: Setup Dependencies
run: |
composer update
composer install
- name: Run PHPUnit
run: |
./vendor/bin/phpunit --verbose

3
.gitignore vendored
View File

@ -5,4 +5,5 @@ vendor/
composer.lock
apigen.phar
docs/
nbproject/
nbproject/
.phpunit.result.cache

View File

@ -1,16 +0,0 @@
language: php
php:
- 5.6
- 7.0
- 7.1
- 7.2
- 7.3
- 7.4
before_script:
- composer install
script: ./vendor/bin/phpunit
after_success:
- sh generate-api.sh
env:
global:
secure: ctCQVPQgQziwIZf5QGHcnhHlXsyauG0W3AWF/6R8cTP+in2S/RygunPp7CkXiqA1YMluGr2Lo9h4DTVg7oqeXl79FXFXedijQmQEu3g3f4iDWtxbQhGf4bJQk57jXFldge4rQedlOJDzwGzJ1abrimJQlu090BZNeonzWL5cRK4=

View File

@ -6,8 +6,6 @@ needed for compression). It can create new files or extract existing ones.
To keep things simple, the modification (adding or removing files) of existing archives is not supported.
[![Build Status](https://travis-ci.org/splitbrain/php-archive.svg)](https://travis-ci.org/splitbrain/php-archive)
Install
-------

View File

@ -20,7 +20,7 @@
},
"require-dev": {
"phpunit/phpunit": "^4.8",
"phpunit/phpunit": "^8",
"mikey179/vfsstream": "^1.6",
"ext-zip": "*",
"ext-bz2": "*"

View File

@ -7,8 +7,7 @@
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"
syntaxCheck="false">
stopOnFailure="false">
<testsuites>
<testsuite name="Test Suite">
<directory suffix=".php">./tests/</directory>

View File

@ -86,11 +86,9 @@ class FileInfoTest extends TestCase
$this->assertTrue($fileinfo->matchExpression('/bang/', '/bark/'));
}
/**
* @expectedException \PHPUnit_Framework_Error_Notice
*/
public function testMatchDeprecation()
{
$this->expectException(\PHPUnit\Framework\Error\Notice::class);
$fileinfo = new FileInfo('foo/bar/baz/bang');
$fileinfo->match('/bang/', '/bark/');
}
@ -108,11 +106,9 @@ class FileInfoTest extends TestCase
$this->assertSame(0, $fileinfo->getSize());
}
/**
* @expectedException \splitbrain\PHPArchive\FileInfoException
*/
public function testFromPathWithFileNotExisted()
{
$this->expectException(\splitbrain\PHPArchive\FileInfoException::class);
FileInfo::fromPath('invalid_file_path');
}
}

View File

@ -16,7 +16,7 @@ class TarTestCase extends TestCase
protected $extensions = array('tar');
/** @inheritdoc */
protected function setUp()
protected function setUp() : void
{
parent::setUp();
if (extension_loaded('zlib')) {
@ -31,7 +31,7 @@ class TarTestCase extends TestCase
}
/** @inheritdoc */
protected function tearDown()
protected function tearDown() : void
{
parent::tearDown();
$this->extensions[] = null;
@ -62,11 +62,9 @@ class TarTestCase extends TestCase
$this->assertTrue(function_exists('bzopen'));
}
/**
* @expectedException \splitbrain\PHPArchive\ArchiveIOException
*/
public function testTarFileIsNotExisted()
{
$this->expectException(ArchiveIOException::class);
$tar = new Tar();
$tar->open('non_existed_file.tar');
}
@ -609,20 +607,16 @@ class TarTestCase extends TestCase
}
}
/**
* @expectedException \splitbrain\PHPArchive\ArchiveIOException
*/
public function testContentsWithInvalidArchiveStream()
{
$this->expectException(ArchiveIOException::class);
$tar = new Tar();
$tar->contents();
}
/**
* @expectedException \splitbrain\PHPArchive\ArchiveIOException
*/
public function testExtractWithInvalidOutDir()
{
$this->expectException(ArchiveIOException::class);
$dir = dirname(__FILE__) . '/tar';
$out = '/root/invalid_out_dir';
@ -632,11 +626,9 @@ class TarTestCase extends TestCase
$tar->extract($out);
}
/**
* @expectedException \splitbrain\PHPArchive\ArchiveIOException
*/
public function testExtractWithArchiveStreamIsClosed()
{
$this->expectException(ArchiveIOException::class);
$dir = dirname(__FILE__) . '/tar';
$out = '/root/invalid_out_dir';
@ -647,11 +639,9 @@ class TarTestCase extends TestCase
$tar->extract($out);
}
/**
* @expectedException \splitbrain\PHPArchive\ArchiveIOException
*/
public function testCreateWithInvalidFile()
{
$this->expectException(ArchiveIOException::class);
$dir = dirname(__FILE__) . '/tar';
$tar = new Tar();
@ -659,11 +649,9 @@ class TarTestCase extends TestCase
$tar->create('/root/invalid_file');
}
/**
* @expectedException \splitbrain\PHPArchive\ArchiveIOException
*/
public function testAddFileWithArchiveStreamIsClosed()
{
$this->expectException(ArchiveIOException::class);
$archive = sys_get_temp_dir() . '/dwtartest' . md5(time()) . '.tar';
$tar = new Tar();
@ -672,11 +660,9 @@ class TarTestCase extends TestCase
$tar->addFile('archive_file', false);
}
/**
* @expectedException \splitbrain\PHPArchive\ArchiveIOException
*/
public function testAddFileWithInvalidFile()
{
$this->expectException(ArchiveIOException::class);
$archive = sys_get_temp_dir() . '/dwtartest' . md5(time()) . '.tar';
$tar = new Tar();
@ -684,11 +670,9 @@ class TarTestCase extends TestCase
$tar->addFile('archive_file', false);
}
/**
* @expectedException \splitbrain\PHPArchive\ArchiveIOException
*/
public function testAddDataWithArchiveStreamIsClosed()
{
$this->expectException(ArchiveIOException::class);
$archive = sys_get_temp_dir() . '/dwtartest' . md5(time()) . '.tar';
$tar = new Tar();
@ -721,7 +705,7 @@ class TarTestCase extends TestCase
$tar->addFile("$dir/zero.txt", 'zero.txt');
$file = $tar->getArchive();
$this->assertInternalType('string', $file); // 1 header block + 2 footer blocks
$this->assertIsString($file); // 1 header block + 2 footer blocks
}
public function testSaveWithCompressionAuto()
@ -736,11 +720,9 @@ class TarTestCase extends TestCase
$this->assertTrue(true); // succeed if no exception, yet
}
/**
* @expectedException \splitbrain\PHPArchive\ArchiveIOException
*/
public function testSaveWithInvalidDestinationFile()
{
$this->expectException(ArchiveIOException::class);
$dir = dirname(__FILE__) . '/tar';
$tar = new Tar();
$tar->setCompression();

View File

@ -11,7 +11,7 @@ class ZipTestCase extends TestCase
protected $counter = 0;
/** @inheritdoc */
protected function setUp()
protected function setUp() : void
{
vfsStream::setup('home_root_path');
}
@ -33,11 +33,9 @@ class ZipTestCase extends TestCase
$this->assertTrue(function_exists('zip_open'));
}
/**
* @expectedException \splitbrain\PHPArchive\ArchiveIOException
*/
public function testMissing()
{
$this->expectException(ArchiveIOException::class);
$tar = new Zip();
$tar->open('nope.zip');
}
@ -125,41 +123,29 @@ class ZipTestCase extends TestCase
$this->assertTrue(strpos($data, "foobar") === false, 'Path not in ZIP');
}
/**
* @expectedException \splitbrain\PHPArchive\ArchiveIOException
*/
public function testCreateWithInvalidFilePath()
{
$this->expectException(ArchiveIOException::class);
$zip = new Zip();
$tmp = vfsStream::url('invalid_root_path/test.zip');
$zip->create($tmp);
}
/**
* @expectedException \splitbrain\PHPArchive\ArchiveIOException
*/
public function testAddFileWithArchiveStreamIsClosed()
{
$this->expectException(ArchiveIOException::class);
$zip = new Zip();
$dir = dirname(__FILE__) . '/zip';
$zip->setCompression(0);
$zip->close();
$zip->addFile("$dir/testdata1.txt", "$dir/testdata1.txt");
}
/**
* @expectedException \splitbrain\PHPArchive\ArchiveIOException
*/
public function testAddFileWithInvalidFile()
{
$this->expectException(ArchiveIOException::class);
$zip = new Zip();
$tmp = vfsStream::url('home_root_path/test.zip');
$zip->create($tmp);
$zip->setCompression(0);
$zip->addFile('invalid_file', false);
@ -188,16 +174,12 @@ class ZipTestCase extends TestCase
$this->assertEquals(13, $content[4]->getSize(), "Contents of $file");
}
/**
* @expectedException \splitbrain\PHPArchive\ArchiveIOException
*/
public function testZipContentWithArchiveStreamIsClosed()
{
$this->expectException(ArchiveIOException::class);
$dir = dirname(__FILE__) . '/zip';
$zip = new Zip();
$file = "$dir/test.zip";
$zip->open($file);
$zip->close();
$zip->contents();
@ -273,11 +255,9 @@ class ZipTestCase extends TestCase
unlink($archive);
}
/**
* @expectedException \splitbrain\PHPArchive\ArchiveIOException
*/
public function testAddDataWithArchiveStreamIsClosed()
{
$this->expectException(ArchiveIOException::class);
$archive = sys_get_temp_dir() . '/dwziptest' . md5(time()) . '.zip';
$zip = new Zip();
@ -310,11 +290,9 @@ class ZipTestCase extends TestCase
$this->assertTrue(true); // succeed if no exception, yet
}
/**
* @expectedException \splitbrain\PHPArchive\ArchiveIOException
*/
public function testSaveWithInvalidFilePath()
{
$this->expectException(ArchiveIOException::class);
$archive = sys_get_temp_dir() . '/dwziptest' . md5(time()) . '.zip';
$zip = new Zip();
@ -396,11 +374,9 @@ class ZipTestCase extends TestCase
self::RDelete($out);
}
/**
* @expectedException \splitbrain\PHPArchive\ArchiveIOException
*/
public function testZipExtractWithArchiveStreamIsClosed()
{
$this->expectException(ArchiveIOException::class);
$dir = dirname(__FILE__) . '/zip';
$out = sys_get_temp_dir() . '/dwziptest' . md5(time());