Laravel version update
Laravel version update
This commit is contained in:
@@ -11,23 +11,25 @@
|
||||
|
||||
namespace Symfony\Component\Debug\Tests\Exception;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Component\Debug\Exception\FlattenException;
|
||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
use Symfony\Component\HttpKernel\Exception\MethodNotAllowedHttpException;
|
||||
use Symfony\Component\HttpKernel\Exception\UnauthorizedHttpException;
|
||||
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
|
||||
use Symfony\Component\HttpKernel\Exception\NotAcceptableHttpException;
|
||||
use Symfony\Component\HttpKernel\Exception\ConflictHttpException;
|
||||
use Symfony\Component\HttpFoundation\Exception\SuspiciousOperationException;
|
||||
use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;
|
||||
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
|
||||
use Symfony\Component\HttpKernel\Exception\ConflictHttpException;
|
||||
use Symfony\Component\HttpKernel\Exception\GoneHttpException;
|
||||
use Symfony\Component\HttpKernel\Exception\LengthRequiredHttpException;
|
||||
use Symfony\Component\HttpKernel\Exception\MethodNotAllowedHttpException;
|
||||
use Symfony\Component\HttpKernel\Exception\NotAcceptableHttpException;
|
||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
use Symfony\Component\HttpKernel\Exception\PreconditionFailedHttpException;
|
||||
use Symfony\Component\HttpKernel\Exception\PreconditionRequiredHttpException;
|
||||
use Symfony\Component\HttpKernel\Exception\ServiceUnavailableHttpException;
|
||||
use Symfony\Component\HttpKernel\Exception\TooManyRequestsHttpException;
|
||||
use Symfony\Component\HttpKernel\Exception\UnauthorizedHttpException;
|
||||
use Symfony\Component\HttpKernel\Exception\UnsupportedMediaTypeHttpException;
|
||||
|
||||
class FlattenExceptionTest extends \PHPUnit_Framework_TestCase
|
||||
class FlattenExceptionTest extends TestCase
|
||||
{
|
||||
public function testStatusCode()
|
||||
{
|
||||
@@ -78,6 +80,11 @@ class FlattenExceptionTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
$flattened = FlattenException::create(new UnsupportedMediaTypeHttpException());
|
||||
$this->assertEquals('415', $flattened->getStatusCode());
|
||||
|
||||
if (class_exists(SuspiciousOperationException::class)) {
|
||||
$flattened = FlattenException::create(new SuspiciousOperationException());
|
||||
$this->assertEquals('400', $flattened->getStatusCode());
|
||||
}
|
||||
}
|
||||
|
||||
public function testHeadersForHttpException()
|
||||
@@ -104,7 +111,7 @@ class FlattenExceptionTest extends \PHPUnit_Framework_TestCase
|
||||
/**
|
||||
* @dataProvider flattenDataProvider
|
||||
*/
|
||||
public function testFlattenHttpException(\Exception $exception, $statusCode)
|
||||
public function testFlattenHttpException(\Exception $exception)
|
||||
{
|
||||
$flattened = FlattenException::create($exception);
|
||||
$flattened2 = FlattenException::create($exception);
|
||||
@@ -119,7 +126,7 @@ class FlattenExceptionTest extends \PHPUnit_Framework_TestCase
|
||||
/**
|
||||
* @dataProvider flattenDataProvider
|
||||
*/
|
||||
public function testPrevious(\Exception $exception, $statusCode)
|
||||
public function testPrevious(\Exception $exception)
|
||||
{
|
||||
$flattened = FlattenException::create($exception);
|
||||
$flattened2 = FlattenException::create($exception);
|
||||
@@ -166,7 +173,7 @@ class FlattenExceptionTest extends \PHPUnit_Framework_TestCase
|
||||
/**
|
||||
* @dataProvider flattenDataProvider
|
||||
*/
|
||||
public function testToArray(\Exception $exception, $statusCode)
|
||||
public function testToArray(\Exception $exception)
|
||||
{
|
||||
$flattened = FlattenException::create($exception);
|
||||
$flattened->setTrace(array(), 'foo.php', 123);
|
||||
@@ -186,12 +193,75 @@ class FlattenExceptionTest extends \PHPUnit_Framework_TestCase
|
||||
public function flattenDataProvider()
|
||||
{
|
||||
return array(
|
||||
array(new \Exception('test', 123), 500),
|
||||
array(new \Exception('test', 123)),
|
||||
);
|
||||
}
|
||||
|
||||
public function testArguments()
|
||||
{
|
||||
$dh = opendir(__DIR__);
|
||||
$fh = tmpfile();
|
||||
|
||||
$incomplete = unserialize('O:14:"BogusTestClass":0:{}');
|
||||
|
||||
$exception = $this->createException(array(
|
||||
(object) array('foo' => 1),
|
||||
new NotFoundHttpException(),
|
||||
$incomplete,
|
||||
$dh,
|
||||
$fh,
|
||||
function () {},
|
||||
array(1, 2),
|
||||
array('foo' => 123),
|
||||
null,
|
||||
true,
|
||||
false,
|
||||
0,
|
||||
0.0,
|
||||
'0',
|
||||
'',
|
||||
INF,
|
||||
NAN,
|
||||
));
|
||||
|
||||
$flattened = FlattenException::create($exception);
|
||||
$trace = $flattened->getTrace();
|
||||
$args = $trace[1]['args'];
|
||||
$array = $args[0][1];
|
||||
|
||||
closedir($dh);
|
||||
fclose($fh);
|
||||
|
||||
$i = 0;
|
||||
$this->assertSame(array('object', 'stdClass'), $array[$i++]);
|
||||
$this->assertSame(array('object', 'Symfony\Component\HttpKernel\Exception\NotFoundHttpException'), $array[$i++]);
|
||||
$this->assertSame(array('incomplete-object', 'BogusTestClass'), $array[$i++]);
|
||||
$this->assertSame(array('resource', \defined('HHVM_VERSION') ? 'Directory' : 'stream'), $array[$i++]);
|
||||
$this->assertSame(array('resource', 'stream'), $array[$i++]);
|
||||
|
||||
$args = $array[$i++];
|
||||
$this->assertSame($args[0], 'object');
|
||||
$this->assertTrue('Closure' === $args[1] || is_subclass_of($args[1], '\Closure'), 'Expect object class name to be Closure or a subclass of Closure.');
|
||||
|
||||
$this->assertSame(array('array', array(array('integer', 1), array('integer', 2))), $array[$i++]);
|
||||
$this->assertSame(array('array', array('foo' => array('integer', 123))), $array[$i++]);
|
||||
$this->assertSame(array('null', null), $array[$i++]);
|
||||
$this->assertSame(array('boolean', true), $array[$i++]);
|
||||
$this->assertSame(array('boolean', false), $array[$i++]);
|
||||
$this->assertSame(array('integer', 0), $array[$i++]);
|
||||
$this->assertSame(array('float', 0.0), $array[$i++]);
|
||||
$this->assertSame(array('string', '0'), $array[$i++]);
|
||||
$this->assertSame(array('string', ''), $array[$i++]);
|
||||
$this->assertSame(array('float', INF), $array[$i++]);
|
||||
|
||||
// assertEquals() does not like NAN values.
|
||||
$this->assertEquals($array[$i][0], 'float');
|
||||
$this->assertTrue(is_nan($array[$i++][1]));
|
||||
}
|
||||
|
||||
public function testRecursionInArguments()
|
||||
{
|
||||
$a = null;
|
||||
$a = array('foo', array(2, &$a));
|
||||
$exception = $this->createException($a);
|
||||
|
||||
@@ -216,6 +286,9 @@ class FlattenExceptionTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
$flattened = FlattenException::create($exception);
|
||||
$trace = $flattened->getTrace();
|
||||
|
||||
$this->assertSame($trace[1]['args'][0], array('array', array('array', '*SKIPPED over 10000 entries*')));
|
||||
|
||||
$serializeTrace = serialize($trace);
|
||||
|
||||
$this->assertContains('*SKIPPED over 10000 entries*', $serializeTrace);
|
||||
@@ -226,45 +299,4 @@ class FlattenExceptionTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
return new \Exception();
|
||||
}
|
||||
|
||||
public function testSetTraceIncompleteClass()
|
||||
{
|
||||
$flattened = FlattenException::create(new \Exception('test', 123));
|
||||
$flattened->setTrace(
|
||||
array(
|
||||
array(
|
||||
'file' => __FILE__,
|
||||
'line' => 123,
|
||||
'function' => 'test',
|
||||
'args' => array(
|
||||
unserialize('O:14:"BogusTestClass":0:{}'),
|
||||
),
|
||||
),
|
||||
),
|
||||
'foo.php', 123
|
||||
);
|
||||
|
||||
$this->assertEquals(array(
|
||||
array(
|
||||
'message' => 'test',
|
||||
'class' => 'Exception',
|
||||
'trace' => array(
|
||||
array(
|
||||
'namespace' => '', 'short_class' => '', 'class' => '', 'type' => '', 'function' => '',
|
||||
'file' => 'foo.php', 'line' => 123,
|
||||
'args' => array(),
|
||||
),
|
||||
array(
|
||||
'namespace' => '', 'short_class' => '', 'class' => '', 'type' => '', 'function' => 'test',
|
||||
'file' => __FILE__, 'line' => 123,
|
||||
'args' => array(
|
||||
array(
|
||||
'incomplete-object', 'BogusTestClass',
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
), $flattened->toArray());
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user