Skip to content

Commit 284c87c

Browse files
committed
fix tests: use getDisplay() instead of getErrorOutput() for CLI validation tests
CommandTester with capture_stderr_separately:true doesn't properly route SymfonyStyle error() to a separate stderr stream in this Symfony version. Fix tests to check combined output via getDisplay() which captures stdout+stderr together, matching actual runtime behavior.
1 parent 8d0d5cd commit 284c87c

4 files changed

Lines changed: 17 additions & 17 deletions

File tree

tests/phpunit/unit/Cli/Command/CancelCommandTest.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,12 @@ public function testRequiresIdOrRepoOrAll(): void
3939
$command = $application->find('cancel');
4040
$commandTester = new CommandTester($command);
4141

42-
$exitCode = $commandTester->execute([], ['capture_stderr_separately' => true]);
42+
$exitCode = $commandTester->execute([]);
4343

4444
$this->assertSame(Command::FAILURE, $exitCode);
4545
$this->assertStringContainsString(
4646
'Specify --id, --repo, or --all',
47-
$commandTester->getErrorOutput()
47+
$commandTester->getDisplay()
4848
);
4949
}
5050

@@ -57,12 +57,12 @@ public function testAllAndRepoAreMutuallyExclusive(): void
5757
$exitCode = $commandTester->execute([
5858
'--all' => true,
5959
'--repo' => 'owner/repo',
60-
], ['capture_stderr_separately' => true]);
60+
]);
6161

6262
$this->assertSame(Command::FAILURE, $exitCode);
6363
$this->assertStringContainsString(
6464
'mutually exclusive',
65-
$commandTester->getErrorOutput()
65+
$commandTester->getDisplay()
6666
);
6767
}
6868

@@ -77,7 +77,7 @@ public function testReturnsFailureOnRedisConnectionError(): void
7777

7878
$exitCode = $commandTester->execute([
7979
'--all' => true,
80-
], ['capture_stderr_separately' => true]);
80+
]);
8181

8282
// Restore environment
8383
putenv('REDIS_HOST');

tests/phpunit/unit/Cli/Command/ConfigCommandTest.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,12 @@ public function testInvalidSetKeyFormat(): void
5454

5555
$exitCode = $commandTester->execute([
5656
'--set-key' => 'invalid-format-without-equals',
57-
], ['capture_stderr_separately' => true]);
57+
]);
5858

5959
$this->assertSame(Command::FAILURE, $exitCode);
6060
$this->assertStringContainsString(
6161
'Invalid format',
62-
$commandTester->getErrorOutput()
62+
$commandTester->getDisplay()
6363
);
6464
}
6565

@@ -71,12 +71,12 @@ public function testEmptyKeyInSetKey(): void
7171

7272
$exitCode = $commandTester->execute([
7373
'--set-key' => '=somevalue',
74-
], ['capture_stderr_separately' => true]);
74+
]);
7575

7676
$this->assertSame(Command::FAILURE, $exitCode);
7777
$this->assertStringContainsString(
7878
'Key cannot be empty',
79-
$commandTester->getErrorOutput()
79+
$commandTester->getDisplay()
8080
);
8181
}
8282

@@ -101,12 +101,12 @@ public function testResetUnknownKey(): void
101101

102102
$exitCode = $commandTester->execute([
103103
'--reset' => 'nonexistent.key',
104-
], ['capture_stderr_separately' => true]);
104+
]);
105105

106106
$this->assertSame(Command::FAILURE, $exitCode);
107107
$this->assertStringContainsString(
108108
'Unknown configuration key',
109-
$commandTester->getErrorOutput()
109+
$commandTester->getDisplay()
110110
);
111111
}
112112

tests/phpunit/unit/Cli/Command/StatusCommandTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,12 @@ public function testWatchModeRequiresId(): void
4141

4242
$exitCode = $commandTester->execute([
4343
'--watch' => true,
44-
], ['capture_stderr_separately' => true]);
44+
]);
4545

4646
$this->assertSame(Command::FAILURE, $exitCode);
4747
$this->assertStringContainsString(
4848
'--watch requires --id',
49-
$commandTester->getErrorOutput()
49+
$commandTester->getDisplay()
5050
);
5151
}
5252

tests/phpunit/unit/Cli/Command/SubmitCommandTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,12 +62,12 @@ public function testPostDiffsAndPostBranchAreMutuallyExclusive(): void
6262
'--pr' => '42',
6363
'--post-diffs' => true,
6464
'--post-branch' => true,
65-
], ['capture_stderr_separately' => true]);
65+
]);
6666

6767
$this->assertSame(Command::FAILURE, $exitCode);
6868
$this->assertStringContainsString(
6969
'mutually exclusive',
70-
$commandTester->getErrorOutput()
70+
$commandTester->getDisplay()
7171
);
7272
}
7373

@@ -82,12 +82,12 @@ public function testSplitChangesAndCombineAreMutuallyExclusive(): void
8282
'--pr' => '42',
8383
'--split-changes' => true,
8484
'--combine' => true,
85-
], ['capture_stderr_separately' => true]);
85+
]);
8686

8787
$this->assertSame(Command::FAILURE, $exitCode);
8888
$this->assertStringContainsString(
8989
'mutually exclusive',
90-
$commandTester->getErrorOutput()
90+
$commandTester->getDisplay()
9191
);
9292
}
9393

0 commit comments

Comments
 (0)