Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
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
Remove int return type from FlattenException::getCode
  • Loading branch information
wucdbm authored and fabpot committed Mar 9, 2020
commit 0f22e076c4bd6455a2727fd3eb01b40bcd9df4fe
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ public function setMessage($message): self
return $this;
}

public function getCode(): int
public function getCode()
{
return $this->code;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
use PHPUnit\Framework\TestCase;
use Symfony\Component\Debug\Exception\FatalThrowableError;
use Symfony\Component\ErrorHandler\Exception\FlattenException;
use Symfony\Component\ErrorHandler\Tests\Fixtures\StringErrorCodeException;
use Symfony\Component\HttpFoundation\Exception\SuspiciousOperationException;
use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
Expand Down Expand Up @@ -197,6 +198,15 @@ public function testFile(\Throwable $exception)
$this->assertSame($exception->getFile(), $flattened->getFile());
}

/**
* @dataProvider stringAndIntDataProvider
*/
public function testCode(\Throwable $exception)
{
$flattened = FlattenException::createFromThrowable($exception);
$this->assertSame($exception->getCode(), $flattened->getCode());
}

/**
* @dataProvider flattenDataProvider
*/
Expand Down Expand Up @@ -238,6 +248,14 @@ public function flattenDataProvider(): array
];
}

public function stringAndIntDataProvider(): array
{
return [
[new \Exception('test1', 123)],
[new StringErrorCodeException('test2', '42S02')],
];
}

public function testArguments()
{
if (\PHP_VERSION_ID >= 70400) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

namespace Symfony\Component\ErrorHandler\Tests\Fixtures;

class StringErrorCodeException extends \Exception
{

public function __construct(string $message, string $code) {
parent::__construct($message);
$this->code = $code;
}

}