Skip to content
Merged
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
54 changes: 1 addition & 53 deletions tests/src/Functional/SplitCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ public function testSplitMultipleEntries(): void

// Should create 11 files (one per entry)
$files = glob($this->tempDir.'/*.har');
$this->assertCount(11, $files);

// Verify file names are sequential
$expectedFiles = [];
Expand Down Expand Up @@ -86,7 +85,6 @@ public function testSplitSingleEntry(): void
// Should create 1 file
$files = glob($this->tempDir.'/*.har');
$this->assertCount(1, $files);
$this->assertFileExists($this->tempDir.'/1.har');

// Verify the file is valid HAR
$serializer = new Serializer();
Expand All @@ -111,13 +109,7 @@ public function testSplitWithMd5Option(): void
$files = glob($this->tempDir.'/*.har');
$this->assertCount(11, $files);

// Verify file names are MD5 hashes
foreach ($files as $file) {
$basename = basename($file, '.har');
$this->assertMatchesRegularExpression('/^[a-f0-9]{32}$/', $basename, 'Filename should be MD5 hash');
}

// Verify each file is valid HAR
// Verify each file is valid HAR and filename matches MD5 of URL
$serializer = new Serializer();
foreach ($files as $file) {
$contents = file_get_contents($file);
Expand All @@ -144,7 +136,6 @@ public function testSplitWithForceOption(): void
$this->assertSame(Command::SUCCESS, $this->commandTester->getStatusCode());

$outputFile = $this->tempDir.'/1.har';
$this->assertFileExists($outputFile);
$originalContent = file_get_contents($outputFile);

// Modify the file to verify it gets overwritten
Expand All @@ -162,7 +153,6 @@ public function testSplitWithForceOption(): void
// Verify the file was overwritten with original content
$newContent = file_get_contents($outputFile);
$this->assertEquals($originalContent, $newContent);
$this->assertNotEquals('modified content', $newContent);
}

public function testSplitFailsWhenFileExistsWithoutForce(): void
Expand Down Expand Up @@ -230,8 +220,6 @@ public function testSplitPreservesHarStructure(): void
// Load split files and compare each entry
for ($i = 0; $i < \count($originalEntries); ++$i) {
$splitFile = $this->tempDir.'/'.($i + 1).'.har';
$this->assertFileExists($splitFile);

$splitContents = file_get_contents($splitFile);
$splitHar = $serializer->deserializeHar($splitContents);
$splitEntry = $splitHar->getLog()->getEntries()[0];
Expand Down Expand Up @@ -315,8 +303,6 @@ public function testCommandConfiguration(): void

// Verify required arguments exist
$definition = $command->getDefinition();
$this->assertTrue($definition->hasArgument('har'));
$this->assertTrue($definition->hasArgument('destination'));
$this->assertTrue($definition->getArgument('har')->isRequired());
$this->assertFalse($definition->getArgument('destination')->isRequired());

Expand All @@ -325,36 +311,6 @@ public function testCommandConfiguration(): void
$this->assertTrue($definition->hasOption('force'));
}

public function testSplitUpdatesProgressBar(): void
{
$harFile = __DIR__.'/../../fixtures/www.softwareishard.com-multiple-entries.har';

// Execute the command
$this->commandTester->execute([
'har' => $harFile,
'destination' => $this->tempDir,
]);

$output = $this->commandTester->getDisplay();

// Verify progress bar completes (progressFinish mutation killer)
// The progress bar shows "11/11" and "100%" when progressFinish is called
$this->assertMatchesRegularExpression('/11\/11/', $output, 'Progress should show 11/11 completion');
$this->assertStringContainsString('100%', $output, 'Progress should show 100% completion');

// Verify intermediate progress is shown (progressAdvance mutation killer)
// Without progressAdvance(), we'd only see 0/11 then jump to 11/11
// Check for at least one intermediate state (anything from 1/11 to 10/11)
$this->assertMatchesRegularExpression('/[1-9]\/11|10\/11/', $output, 'Progress should show intermediate states');

// Verify the command succeeds
$this->assertSame(Command::SUCCESS, $this->commandTester->getStatusCode());

// Count the actual files created
$files = glob($this->tempDir.'/*.har');
$this->assertCount(11, $files, 'Should create 11 files');
}

public function testProgressAdvanceIsCalledForEachEntry(): void
{
// This test kills the MethodCallRemoval mutation for progressAdvance()
Expand All @@ -379,10 +335,6 @@ public function testProgressAdvanceIsCalledForEachEntry(): void
$this->assertGreaterThan(2, \count($progressStates),
'Progress bar should show multiple intermediate states when progressAdvance() is called. '.
'Found states: '.implode(', ', $progressStates));

// Verify we start at 0 and end at 11
$this->assertContains('0', $progressStates, 'Progress should start at 0');
$this->assertContains('11', $progressStates, 'Progress should end at 11');
}

public function testProgressFinishShowsCompletion(): void
Expand All @@ -402,10 +354,6 @@ public function testProgressFinishShowsCompletion(): void
// and outputs a newline after completion. Without progressFinish(),
// the output ends with "100%" but no newline.

// Check for 100% completion marker
$this->assertStringContainsString('100%', $output,
'Progress bar must show 100% completion - this requires progressFinish() to be called');

// Check that 11/11 appears (the final state)
$this->assertMatchesRegularExpression('/11\/11/', $output,
'Progress bar must show final 11/11 state - this requires progressFinish() to be called');
Expand Down