Skip to content

Commit 2f38a46

Browse files
committed
Tests reworked
1 parent 282eb4b commit 2f38a46

File tree

2 files changed

+26
-36
lines changed

2 files changed

+26
-36
lines changed

src/Symfony/Component/VarDumper/Tests/Dumper/ContextualizedDumperTest.php

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,11 @@
1212
namespace Symfony\Component\VarDumper\Tests\Dumper;
1313

1414
use PHPUnit\Framework\TestCase;
15+
use Symfony\Component\Console\Command\Command;
16+
use Symfony\Component\Console\Input\InputInterface;
17+
use Symfony\Component\Console\Input\StringInput;
18+
use Symfony\Component\Console\Output\ConsoleOutput;
19+
use Symfony\Component\Console\Output\OutputInterface;
1520
use Symfony\Component\VarDumper\Cloner\VarCloner;
1621
use Symfony\Component\VarDumper\Dumper\CliDumper;
1722
use Symfony\Component\VarDumper\Dumper\ContextProvider\SourceContextProvider;
@@ -28,15 +33,14 @@ public function testContextualizedCliDumper(): void
2833
$wrappedDumper->setColors(true);
2934

3035
$var = 'example';
31-
$href = sprintf('file://%s#L%s', __FILE__, 37);
36+
$href = sprintf('file://%s#L%s', __FILE__, 42);
3237
$dumper = new ContextualizedDumper($wrappedDumper, [new SourceContextProvider()]);
3338
$cloner = new VarCloner();
3439
$data = $cloner->cloneVar($var);
3540

3641
ob_start();
3742
$dumper->dump($data);
38-
$out = ob_get_clean();
39-
$out = preg_replace('/[ \t]+$/m', '', $out);
43+
$out = preg_replace('/[ \t]+$/m', '', ob_get_clean());
4044

4145
$this->assertStringMatchesFormat(
4246
<<<EOTXT
@@ -49,14 +53,27 @@ public function testContextualizedCliDumper(): void
4953

5054
public function testContextualizedCliDumperInCommand(): void
5155
{
56+
$command = new class() extends Command {
57+
public function execute(InputInterface $input, OutputInterface $output)
58+
{
59+
$var = 'example';
60+
$wrappedDumper = new CliDumper('php://output');
61+
$wrappedDumper->setColors(true);
62+
63+
$dumper = new ContextualizedDumper($wrappedDumper, [new SourceContextProvider()]);
64+
$cloner = new VarCloner();
65+
$data = $cloner->cloneVar($var);
66+
67+
$dumper->dump($data);
68+
}
69+
};
70+
5271
$var = 'example';
53-
$href = 'file://%s/Tests/Fixtures/dumb-console.php#L22';
72+
$href = sprintf('file://%s#L%s', __FILE__, 67);
5473

55-
$dumbConsole = __DIR__.'/../Fixtures/dumb-console.php';
56-
$sh = [];
57-
exec("php {$dumbConsole}", $sh);
58-
$out = implode(PHP_EOL, $sh);
59-
$out = preg_replace('/[ \t]+$/m', '', $out);
74+
ob_start();
75+
$command->run(new StringInput(''), new ConsoleOutput());
76+
$out = preg_replace('/[ \t]+$/m', '', ob_get_clean());
6077

6178
$this->assertStringMatchesFormat(
6279
<<<EOTXT

src/Symfony/Component/VarDumper/Tests/Fixtures/dumb-console.php

Lines changed: 0 additions & 27 deletions
This file was deleted.

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy