Skip to content

Commit

Permalink
Fixes unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
butschster committed Jun 10, 2024
1 parent 3a8d418 commit 47990fa
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 6 deletions.
6 changes: 5 additions & 1 deletion app/modules/VarDumper/Application/Dump/PrimitiveBody.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,11 @@ public function getValue(): string

public function __toString(): string
{
return (string) $this->value;
return match (true) {
$this->value === true => '1',
$this->value === false => '0',
default => (string) $this->value,
};
}

public function jsonSerialize(): string
Expand Down
24 changes: 19 additions & 5 deletions tests/Feature/Interfaces/TCP/VarDumper/SymfonyV7Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,24 +17,34 @@ final class SymfonyV7Test extends TCPTestCase
public static function variablesDataProvider(): iterable
{
yield 'string' => ['foo', 'string', 'foo'];
yield 'int' => [1, 'integer', 1];
yield 'float' => [1.1, 'double', 1.1];
yield 'array' => [['foo' => 'bar'], 'array', <<<'HTML'
yield 'true' => [true, 'boolean', '1'];
yield 'false' => [false, 'boolean', '0'];
yield 'int' => [1, 'integer', '1'];
yield 'float' => [1.1, 'double', '1.1'];
yield 'array' => [
['foo' => 'bar'],
'array',
<<<'HTML'
<pre class=sf-dump id=sf-dump-730421088 data-indent-pad=" "><span class=sf-dump-label>Some label</span> <span class=sf-dump-note>array:1</span> [<samp data-depth=1 class=sf-dump-expanded>
"<span class=sf-dump-key>foo</span>" => "<span class=sf-dump-str>bar</span>"
</samp>]
</pre><script>Sfdump("sf-dump-730421088")</script>

HTML
,
];
yield 'object' => [(object) ['type' => 'string', 'value' => 'foo'], 'stdClass', <<<HTML
<pre class=sf-dump id=sf-dump-730421088 data-indent-pad=" "><span class=sf-dump-label>Some label</span> {<a class=sf-dump-ref>#208</a><samp data-depth=1 class=sf-dump-expanded>
yield 'object' => [
(object) ['type' => 'string', 'value' => 'foo'],
'stdClass',
<<<HTML
<pre class=sf-dump id=sf-dump-730421088 data-indent-pad=" "><span class=sf-dump-label>Some label</span> {<a class=sf-dump-ref>#%s</a><samp data-depth=1 class=sf-dump-expanded>
+"<span class=sf-dump-public>type</span>": "<span class=sf-dump-str>string</span>"
+"<span class=sf-dump-public>value</span>": "<span class=sf-dump-str>foo</span>"
</samp>}
</pre><script>Sfdump("sf-dump-730421088")</script>
HTML
,
];
}

Expand All @@ -47,6 +57,10 @@ public function testSendDump(mixed $value, string $type, mixed $expected): void
$message = $this->buildPayload(var: $value);
$this->handleVarDumperRequest($message);

if (\is_object($value)) {
$expected = \sprintf($expected, \spl_object_id($value));
}

$this->broadcastig->assertPushed(new EventsChannel(), function (array $data) use ($value, $type, $expected) {
$this->assertSame('event.received', $data['event']);
$this->assertSame('var-dump', $data['data']['type']);
Expand Down

0 comments on commit 47990fa

Please sign in to comment.