@@ -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