Skip to content

Commit d53bf2e

Browse files
committed
updated testing
* test on github not travis * run phpunit8 (tests only on 7.2+) * use github action to build api docs
1 parent d4cf2d9 commit d53bf2e

File tree

10 files changed

+84
-91
lines changed

10 files changed

+84
-91
lines changed

.github/workflows/apigen.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
name: ApiGen
2+
3+
on:
4+
workflow_run:
5+
workflows: ["Unit Tests"]
6+
branches: [master]
7+
types:
8+
- completed
9+
10+
jobs:
11+
Document_Generator:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: actions/checkout@v2
15+
- name: 📝 ApiGen PHP Document Generator
16+
uses: varunsridharan/[email protected]
17+
with:
18+
cached_apigen: 'no'
19+
source_folder: 'src'
20+
env:
21+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/test.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: Unit Tests
2+
3+
on: [push, pull_request]
4+
5+
jobs:
6+
run:
7+
name: PHP ${{ matrix.php-versions }}
8+
runs-on: ubuntu-latest
9+
if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository
10+
11+
strategy:
12+
matrix:
13+
php-versions: ['7.2', '7.3', '7.4', '8.0']
14+
fail-fast: false
15+
16+
steps:
17+
- name: Checkout
18+
uses: actions/checkout@v2
19+
20+
- name: Setup PHP
21+
uses: shivammathur/setup-php@v2
22+
with:
23+
php-version: ${{ matrix.php-versions }}
24+
25+
- name: Setup problem matchers
26+
run: |
27+
echo ::add-matcher::${{ runner.tool_cache }}/php.json
28+
echo ::add-matcher::${{ runner.tool_cache }}/phpunit.json
29+
30+
- name: Setup Dependencies
31+
run: |
32+
composer update
33+
composer install
34+
- name: Run PHPUnit
35+
run: |
36+
./vendor/bin/phpunit --verbose

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,5 @@ vendor/
55
composer.lock
66
apigen.phar
77
docs/
8-
nbproject/
8+
nbproject/
9+
.phpunit.result.cache

.travis.yml

Lines changed: 0 additions & 16 deletions
This file was deleted.

README.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@ needed for compression). It can create new files or extract existing ones.
66

77
To keep things simple, the modification (adding or removing files) of existing archives is not supported.
88

9-
[![Build Status](https://travis-ci.org/splitbrain/php-archive.svg)](https://travis-ci.org/splitbrain/php-archive)
10-
119
Install
1210
-------
1311

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
},
2121

2222
"require-dev": {
23-
"phpunit/phpunit": "^4.8",
23+
"phpunit/phpunit": "^8",
2424
"mikey179/vfsstream": "^1.6",
2525
"ext-zip": "*",
2626
"ext-bz2": "*"

phpunit.xml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@
77
convertNoticesToExceptions="true"
88
convertWarningsToExceptions="true"
99
processIsolation="false"
10-
stopOnFailure="false"
11-
syntaxCheck="false">
10+
stopOnFailure="false">
1211
<testsuites>
1312
<testsuite name="Test Suite">
1413
<directory suffix=".php">./tests/</directory>

tests/FileInfoTest.php

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -86,11 +86,9 @@ public function testMatchExpression()
8686
$this->assertTrue($fileinfo->matchExpression('/bang/', '/bark/'));
8787
}
8888

89-
/**
90-
* @expectedException \PHPUnit_Framework_Error_Notice
91-
*/
9289
public function testMatchDeprecation()
9390
{
91+
$this->expectException(\PHPUnit\Framework\Error\Notice::class);
9492
$fileinfo = new FileInfo('foo/bar/baz/bang');
9593
$fileinfo->match('/bang/', '/bark/');
9694
}
@@ -108,11 +106,9 @@ public function testFromPath()
108106
$this->assertSame(0, $fileinfo->getSize());
109107
}
110108

111-
/**
112-
* @expectedException \splitbrain\PHPArchive\FileInfoException
113-
*/
114109
public function testFromPathWithFileNotExisted()
115110
{
111+
$this->expectException(\splitbrain\PHPArchive\FileInfoException::class);
116112
FileInfo::fromPath('invalid_file_path');
117113
}
118114
}

tests/TarTestCase.php

Lines changed: 12 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class TarTestCase extends TestCase
1616
protected $extensions = array('tar');
1717

1818
/** @inheritdoc */
19-
protected function setUp()
19+
protected function setUp() : void
2020
{
2121
parent::setUp();
2222
if (extension_loaded('zlib')) {
@@ -31,7 +31,7 @@ protected function setUp()
3131
}
3232

3333
/** @inheritdoc */
34-
protected function tearDown()
34+
protected function tearDown() : void
3535
{
3636
parent::tearDown();
3737
$this->extensions[] = null;
@@ -62,11 +62,9 @@ public function testExtBz2IsInstalled()
6262
$this->assertTrue(function_exists('bzopen'));
6363
}
6464

65-
/**
66-
* @expectedException \splitbrain\PHPArchive\ArchiveIOException
67-
*/
6865
public function testTarFileIsNotExisted()
6966
{
67+
$this->expectException(ArchiveIOException::class);
7068
$tar = new Tar();
7169
$tar->open('non_existed_file.tar');
7270
}
@@ -609,20 +607,16 @@ public function testGzipIsValid()
609607
}
610608
}
611609

612-
/**
613-
* @expectedException \splitbrain\PHPArchive\ArchiveIOException
614-
*/
615610
public function testContentsWithInvalidArchiveStream()
616611
{
612+
$this->expectException(ArchiveIOException::class);
617613
$tar = new Tar();
618614
$tar->contents();
619615
}
620616

621-
/**
622-
* @expectedException \splitbrain\PHPArchive\ArchiveIOException
623-
*/
624617
public function testExtractWithInvalidOutDir()
625618
{
619+
$this->expectException(ArchiveIOException::class);
626620
$dir = dirname(__FILE__) . '/tar';
627621
$out = '/root/invalid_out_dir';
628622

@@ -632,11 +626,9 @@ public function testExtractWithInvalidOutDir()
632626
$tar->extract($out);
633627
}
634628

635-
/**
636-
* @expectedException \splitbrain\PHPArchive\ArchiveIOException
637-
*/
638629
public function testExtractWithArchiveStreamIsClosed()
639630
{
631+
$this->expectException(ArchiveIOException::class);
640632
$dir = dirname(__FILE__) . '/tar';
641633
$out = '/root/invalid_out_dir';
642634

@@ -647,23 +639,19 @@ public function testExtractWithArchiveStreamIsClosed()
647639
$tar->extract($out);
648640
}
649641

650-
/**
651-
* @expectedException \splitbrain\PHPArchive\ArchiveIOException
652-
*/
653642
public function testCreateWithInvalidFile()
654643
{
644+
$this->expectException(ArchiveIOException::class);
655645
$dir = dirname(__FILE__) . '/tar';
656646
$tar = new Tar();
657647

658648
$tar->open("$dir/tarbomb.tgz");
659649
$tar->create('/root/invalid_file');
660650
}
661651

662-
/**
663-
* @expectedException \splitbrain\PHPArchive\ArchiveIOException
664-
*/
665652
public function testAddFileWithArchiveStreamIsClosed()
666653
{
654+
$this->expectException(ArchiveIOException::class);
667655
$archive = sys_get_temp_dir() . '/dwtartest' . md5(time()) . '.tar';
668656

669657
$tar = new Tar();
@@ -672,23 +660,19 @@ public function testAddFileWithArchiveStreamIsClosed()
672660
$tar->addFile('archive_file', false);
673661
}
674662

675-
/**
676-
* @expectedException \splitbrain\PHPArchive\ArchiveIOException
677-
*/
678663
public function testAddFileWithInvalidFile()
679664
{
665+
$this->expectException(ArchiveIOException::class);
680666
$archive = sys_get_temp_dir() . '/dwtartest' . md5(time()) . '.tar';
681667

682668
$tar = new Tar();
683669
$tar->create($archive);
684670
$tar->addFile('archive_file', false);
685671
}
686672

687-
/**
688-
* @expectedException \splitbrain\PHPArchive\ArchiveIOException
689-
*/
690673
public function testAddDataWithArchiveStreamIsClosed()
691674
{
675+
$this->expectException(ArchiveIOException::class);
692676
$archive = sys_get_temp_dir() . '/dwtartest' . md5(time()) . '.tar';
693677

694678
$tar = new Tar();
@@ -721,7 +705,7 @@ public function testGetArchiveWithBzipCompress()
721705
$tar->addFile("$dir/zero.txt", 'zero.txt');
722706
$file = $tar->getArchive();
723707

724-
$this->assertInternalType('string', $file); // 1 header block + 2 footer blocks
708+
$this->assertIsString($file); // 1 header block + 2 footer blocks
725709
}
726710

727711
public function testSaveWithCompressionAuto()
@@ -736,11 +720,9 @@ public function testSaveWithCompressionAuto()
736720
$this->assertTrue(true); // succeed if no exception, yet
737721
}
738722

739-
/**
740-
* @expectedException \splitbrain\PHPArchive\ArchiveIOException
741-
*/
742723
public function testSaveWithInvalidDestinationFile()
743724
{
725+
$this->expectException(ArchiveIOException::class);
744726
$dir = dirname(__FILE__) . '/tar';
745727
$tar = new Tar();
746728
$tar->setCompression();

0 commit comments

Comments
 (0)