2
0

JarMarkerExtraFieldTest.php 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. <?php
  2. declare(strict_types=1);
  3. /*
  4. * This file is part of the nelexa/zip package.
  5. * (c) Ne-Lexa <https://github.com/Ne-Lexa/php-zip>
  6. * For the full copyright and license information, please view the LICENSE
  7. * file that was distributed with this source code.
  8. */
  9. namespace PhpZip\Tests\Extra\Fields;
  10. use PHPUnit\Framework\TestCase;
  11. use PhpZip\Exception\ZipException;
  12. use PhpZip\Model\Extra\Fields\JarMarkerExtraField;
  13. /**
  14. * Class JarMarkerExtraFieldTest.
  15. *
  16. * @internal
  17. *
  18. * @small
  19. */
  20. final class JarMarkerExtraFieldTest extends TestCase
  21. {
  22. /**
  23. * @throws ZipException
  24. */
  25. public function testExtraField(): void
  26. {
  27. $jarField = new JarMarkerExtraField();
  28. self::assertSame('', $jarField->packLocalFileData());
  29. self::assertSame('', $jarField->packCentralDirData());
  30. self::assertEquals(JarMarkerExtraField::unpackLocalFileData(''), $jarField);
  31. self::assertEquals(JarMarkerExtraField::unpackCentralDirData(''), $jarField);
  32. }
  33. /**
  34. * @throws ZipException
  35. */
  36. public function testInvalidUnpackLocalData(): void
  37. {
  38. $this->expectException(ZipException::class);
  39. $this->expectExceptionMessage("JarMarker doesn't expect any data");
  40. JarMarkerExtraField::unpackLocalFileData("\x02\x00\00");
  41. }
  42. /**
  43. * @throws ZipException
  44. */
  45. public function testInvalidUnpackCdData(): void
  46. {
  47. $this->expectException(ZipException::class);
  48. $this->expectExceptionMessage("JarMarker doesn't expect any data");
  49. JarMarkerExtraField::unpackCentralDirData("\x02\x00\00");
  50. }
  51. }