Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add the PHAR timestamp to the info command #1104

Merged
merged 2 commits into from
Oct 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/Console/Command/Info.php
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,10 @@ private static function showPharMeta(PharInfo $pharInfo, IO $io): void

$io->newLine();

PharInfoRenderer::renderTimestamp($pharInfo, $io);

$io->newLine();

PharInfoRenderer::renderContentsSummary($pharInfo, $io);
}

Expand Down
1 change: 1 addition & 0 deletions src/Console/PharInfoRenderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

namespace KevinGH\Box\Console;

use DateTimeImmutable;
use Fidry\Console\Input\IO;
use KevinGH\Box\NotInstantiable;
use KevinGH\Box\Phar\CompressionAlgorithm;
Expand Down
32 changes: 32 additions & 0 deletions tests/Console/Command/InfoTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,8 @@ public static function inputProvider(): iterable

Metadata: None

Timestamp: 1680285013 (2023-03-31T17:50:13+00:00)

Contents: 1 file (6.62KB)

// Use the --list|-l option to list the content of the PHAR.
Expand All @@ -130,6 +132,8 @@ public static function inputProvider(): iterable

Metadata: None

Timestamp: 1559807994 (2019-06-06T07:59:54+00:00)

Contents: 2 files (6.61KB)

// Use the --list|-l option to list the content of the PHAR.
Expand All @@ -154,6 +158,8 @@ public static function inputProvider(): iterable

Metadata: None

Timestamp: 1680284754 (2023-03-31T17:45:54+00:00)

Contents: 1 file (2.00KB)

// Use the --list|-l option to list the content of the PHAR.
Expand All @@ -178,6 +184,8 @@ public static function inputProvider(): iterable

Metadata: None

Timestamp: 1680284754 (2023-03-31T17:45:54+00:00)

Contents: 1 file (2.00KB)
sample.txt [NONE] - 13.00B

Expand All @@ -200,6 +208,8 @@ public static function inputProvider(): iterable

Metadata: None

Timestamp: 1509920675 (2017-11-05T22:24:35+00:00)

Contents: 1 file (2.56KB)

// Use the --list|-l option to list the content of the PHAR.
Expand All @@ -225,6 +235,8 @@ public static function inputProvider(): iterable

Metadata: None

Timestamp: 1680645848 (2023-04-04T22:04:08+00:00)

Contents: 13 files (7.09KB)

// Use the --list|-l option to list the content of the PHAR.
Expand All @@ -251,6 +263,8 @@ public static function inputProvider(): iterable

Metadata: None

Timestamp: 1680645848 (2023-04-04T22:04:08+00:00)

Contents: 13 files (7.09KB)
fileX [NONE] - 0.00B
.hidden-file [NONE] - 0.00B
Expand Down Expand Up @@ -293,6 +307,8 @@ public static function inputProvider(): iterable

Metadata: None

Timestamp: 1680645848 (2023-04-04T22:04:08+00:00)

Contents: 13 files (7.09KB)
fileX [NONE] - 0.00B
dir0/
Expand Down Expand Up @@ -338,6 +354,8 @@ public static function inputProvider(): iterable

Metadata: None

Timestamp: 1680645848 (2023-04-04T22:04:08+00:00)

Contents: 13 files (7.09KB)
fileX [NONE] - 0.00B
.hidden-file [NONE] - 0.00B
Expand Down Expand Up @@ -367,6 +385,8 @@ public static function inputProvider(): iterable

Metadata: None

Timestamp: 1680645848 (2023-04-04T22:04:08+00:00)

Contents: 13 files (7.09KB)
fileX [NONE] - 0.00B
dir0/
Expand Down Expand Up @@ -398,6 +418,8 @@ public static function inputProvider(): iterable

Metadata: None

Timestamp: 1680645848 (2023-04-04T22:04:08+00:00)

Contents: 13 files (7.09KB)
fileX [NONE] - 0.00B
.hidden-file [NONE] - 0.00B
Expand Down Expand Up @@ -434,6 +456,8 @@ public static function inputProvider(): iterable

Metadata: None

Timestamp: 1680645848 (2023-04-04T22:04:08+00:00)

Contents: 13 files (7.09KB)
fileX [NONE] - 0.00B
dir0/fileA [NONE] - 0.00B
Expand Down Expand Up @@ -473,6 +497,8 @@ public static function inputProvider(): iterable

Metadata: None

Timestamp: 1680645848 (2023-04-04T22:04:08+00:00)

Contents: 13 files (7.09KB)
fileX [NONE] - 0.00B
.hidden-file [NONE] - 0.00B
Expand Down Expand Up @@ -510,6 +536,8 @@ public static function inputProvider(): iterable

Metadata: None

Timestamp: 1680645848 (2023-04-04T22:04:08+00:00)

Contents: 13 files (7.09KB)
fileX [NONE] - 0.00B
dir0/fileA [NONE] - 0.00B
Expand Down Expand Up @@ -553,6 +581,8 @@ public static function inputProvider(): iterable
'test' => 123,
)

Timestamp: 1527142573 (2018-05-24T06:16:13+00:00)

Contents: 3 files (6.75KB)
a/
bar.php [BZ2] - 60.00B
Expand Down Expand Up @@ -586,6 +616,8 @@ public static function inputProvider(): iterable
'test' => 123,
)

Timestamp: 1527142573 (2018-05-24T06:16:13+00:00)

Contents: 3 files (6.75KB)
b/
beta/
Expand Down
53 changes: 37 additions & 16 deletions tests/Phar/PharMetaTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

namespace KevinGH\Box\Phar;

use KevinGH\Box\Platform;
use Phar;
use PHPUnit\Framework\TestCase;
use function rtrim;
Expand Down Expand Up @@ -402,25 +403,45 @@ public static function pharProvider(): iterable
}

if (extension_loaded('zlib')) {
yield 'ZIP compressed simple tar' => [
self::FIXTURES_DIR.'/../phar/simple.zip',
null,
new PharMeta(
CompressionAlgorithm::NONE,
null,
yield 'ZIP compressed simple tar' => Platform::isOSX()
? [
self::FIXTURES_DIR.'/../phar/simple.zip',
null,
new PharMeta(
CompressionAlgorithm::NONE,
null,
null,
null,
null,
1680284660,
null,
[
'sample.txt' => [
'compression' => CompressionAlgorithm::GZ,
'compressedSize' => 15,
],
],
),
]
: [
self::FIXTURES_DIR.'/../phar/simple.zip',
null,
null,
1680284660,
null,
[
'sample.txt' => [
'compression' => CompressionAlgorithm::GZ,
'compressedSize' => 15,
new PharMeta(
CompressionAlgorithm::NONE,
null,
null,
null,
null,
1680291860,
null,
[
'sample.txt' => [
'compression' => CompressionAlgorithm::GZ,
'compressedSize' => 15,
],
],
],
),
];
),
];
}

if (extension_loaded('bz2')) {
Expand Down