Skip to content

Commit

Permalink
ToStringPluginTest: Use fixture for bad string test
Browse files Browse the repository at this point in the history
Turns out kint is so good at detecting stuff that dumping a
phpunit stub will result in an out of memory from dumping the
entirety of phpunit...
  • Loading branch information
jnvsor committed Aug 26, 2024
1 parent 523b6b9 commit 8646693
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
13 changes: 13 additions & 0 deletions tests/Fixtures/BadToStringClass.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

namespace Kint\Test\Fixtures;

use InvalidArgumentException;

class BadToStringClass
{
public function __toString()
{
throw new InvalidArgumentException('Bad toString');
}
}
6 changes: 2 additions & 4 deletions tests/Parser/ToStringPluginTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,9 @@

namespace Kint\Test\Parser;

use InvalidArgumentException;
use Kint\Parser\Parser;
use Kint\Parser\ToStringPlugin;
use Kint\Test\Fixtures\TestClass;
use Kint\Test\Fixtures\BadToStringClass;
use Kint\Test\KintTestCase;
use Kint\Zval\BlobValue;
use Kint\Zval\Value;
Expand Down Expand Up @@ -114,8 +113,7 @@ public function testParseBuggyValue()
$p->addPlugin(new ToStringPlugin($p));
$b = new Value('$v');

$v = $this->createStub(TestClass::class);
$v->method('__toString')->willThrowException(new InvalidArgumentException('Bad toString'));
$v = new BadToStringClass();

$obj = $p->parse($v, clone $b);

Expand Down

0 comments on commit 8646693

Please sign in to comment.