Skip to content
Permalink
Browse files

Merge branch 'PR2191' into 4.x

Closes #2191
  • Loading branch information...
akrabat committed Apr 17, 2017
2 parents 63de022 + 4062311 commit 54401a4f5df38da67cfcf665051c166ee669a911
@@ -36,7 +36,7 @@
},
"require-dev": {
"squizlabs/php_codesniffer": "^2.5",
"phpunit/phpunit": "^5.0"
"phpunit/phpunit": "^5.7|^6.0"
},
"provide": {
"psr/http-message-implementation": "1.0"
@@ -9,6 +9,7 @@
namespace Slim\Tests;
use PHPUnit\Framework\TestCase;
use Psr\Http\Message\ResponseInterface;
use Slim\App;
use Slim\Exception\MethodNotAllowedException;
@@ -24,7 +25,7 @@
use Slim\Router;
use Slim\Tests\Mocks\MockAction;
class AppTest extends \PHPUnit_Framework_TestCase
class AppTest extends TestCase
{
public static function setupBeforeClass()
{
@@ -1275,6 +1276,9 @@ public function testInvokeWithPimpleCallable()
$this->assertEquals('Hello', (string)$res->getBody());
}
/**
* @expectedException \RuntimeException
*/
public function testInvokeWithPimpleUndefinedCallable()
{
// Prepare request and response objects
@@ -1301,8 +1305,6 @@ public function testInvokeWithPimpleUndefinedCallable()
$app->get('/foo', 'foo:bar');
$this->setExpectedException('\RuntimeException');
// Invoke app
$app($req, $res);
}
@@ -8,12 +8,13 @@
*/
namespace Slim\Tests;
use PHPUnit\Framework\TestCase;
use Slim\CallableResolver;
use Slim\Container;
use Slim\Tests\Mocks\CallableTest;
use Slim\Tests\Mocks\InvokableTest;
class CallableResolverTest extends \PHPUnit_Framework_TestCase
class CallableResolverTest extends TestCase
{
/**
* @var Container
@@ -107,32 +108,42 @@ public function testResolutionToAnInvokableClass()
$this->assertEquals(1, InvokableTest::$CalledCount);
}
/**
* @expectedException \RuntimeException
*/
public function testMethodNotFoundThrowException()
{
$this->container['callable_service'] = new CallableTest();
$resolver = new CallableResolver($this->container);
$this->setExpectedException('\RuntimeException');
$resolver->resolve('callable_service:noFound');
}
/**
* @expectedException \RuntimeException
*/
public function testFunctionNotFoundThrowException()
{
$resolver = new CallableResolver($this->container);
$this->setExpectedException('\RuntimeException');
$resolver->resolve('noFound');
}
/**
* @expectedException \RuntimeException
* @expectedExceptionMessage Callable Unknown does not exist
*/
public function testClassNotFoundThrowException()
{
$resolver = new CallableResolver($this->container);
$this->setExpectedException('\RuntimeException', 'Callable Unknown does not exist');
$resolver->resolve('Unknown:notFound');
}
/**
* @expectedException \RuntimeException
* @expectedExceptionMessage is not resolvable
*/
public function testCallableClassNotFoundThrowException()
{
$resolver = new CallableResolver($this->container);
$this->setExpectedException('\RuntimeException', 'is not resolvable');
$resolver->resolve(['Unknown', 'notFound']);
}
}
@@ -8,10 +8,11 @@
*/
namespace Slim\Tests;
use PHPUnit\Framework\TestCase;
use ReflectionProperty;
use Slim\Collection;
class CollectionTest extends \PHPUnit_Framework_TestCase
class CollectionTest extends TestCase
{
/**
* @var Collection
@@ -8,10 +8,11 @@
*/
namespace Slim\Tests;
use PHPUnit\Framework\TestCase;
use Slim\Container;
use Interop\Container\ContainerInterface;
class ContainerTest extends \PHPUnit_Framework_TestCase
class ContainerTest extends TestCase
{
/**
* @var Container
@@ -3,12 +3,13 @@
namespace Slim\Tests;
use PHPUnit\Framework\TestCase;
use Slim\CallableResolver;
use Slim\Container;
use Slim\DeferredCallable;
use Slim\Tests\Mocks\CallableTest;
class DeferredCallableTest extends \PHPUnit_Framework_TestCase
class DeferredCallableTest extends TestCase
{
public function testItResolvesCallable()
{
@@ -8,9 +8,10 @@
*/
namespace Slim\Tests\Handlers;
use PHPUnit\Framework\TestCase;
use Slim\Handlers\AbstractHandler;
class AbstractHandlerTest extends \PHPUnit_Framework_TestCase
class AbstractHandlerTest extends TestCase
{
public function testHalfValidContentType()
{
@@ -8,10 +8,11 @@
*/
namespace Slim\Tests\Handlers;
use PHPUnit\Framework\TestCase;
use Slim\Handlers\Error;
use Slim\Http\Response;
class ErrorTest extends \PHPUnit_Framework_TestCase
class ErrorTest extends TestCase
{
public function errorProvider()
{
@@ -61,6 +62,9 @@ public function testErrorDisplayDetails($acceptHeader, $contentType, $startOfBod
$this->assertEquals(0, strpos((string)$res->getBody(), $startOfBody));
}
/**
* @expectedException \UnexpectedValueException
*/
public function testNotFoundContentType()
{
$errorMock = $this->getMockBuilder(Error::class)->setMethods(['determineContentType'])->getMock();
@@ -71,7 +75,6 @@ public function testNotFoundContentType()
$req = $this->getMockBuilder('Slim\Http\Request')->disableOriginalConstructor()->getMock();
$this->setExpectedException('\UnexpectedValueException');
$errorMock->__invoke($req, new Response(), $e);
}
@@ -98,15 +101,15 @@ public function testPreviousException()
/**
* If someone extends the Error handler and calls renderHtmlExceptionOrError with
* a parameter that isn't an Exception or Error, then we thrown an Exception.
*
* @expectedException \RuntimeException
*/
public function testRenderHtmlExceptionorErrorTypeChecksParameter()
{
$class = new \ReflectionClass(Error::class);
$renderHtmlExceptionorError = $class->getMethod('renderHtmlExceptionOrError');
$renderHtmlExceptionorError->setAccessible(true);
$this->setExpectedException(\RuntimeException::class);
$error = new Error();
$renderHtmlExceptionorError->invokeArgs($error, ['foo']);
}
@@ -8,10 +8,11 @@
*/
namespace Slim\Tests\Handlers;
use PHPUnit\Framework\TestCase;
use Slim\Handlers\NotAllowed;
use Slim\Http\Response;
class NotAllowedTest extends \PHPUnit_Framework_TestCase
class NotAllowedTest extends TestCase
{
public function invalidMethodProvider()
{
@@ -56,13 +57,15 @@ public function testOptions()
$this->assertEquals('POST, PUT', $res->getHeaderLine('Allow'));
}
/**
* @expectedException \UnexpectedValueException
*/
public function testNotFoundContentType()
{
$errorMock = $this->getMockBuilder(NotAllowed::class)->setMethods(['determineContentType'])->getMock();
$errorMock->method('determineContentType')
->will($this->returnValue('unknown/type'));
$this->setExpectedException('\UnexpectedValueException');
$errorMock->__invoke($this->getRequest('GET', 'unknown/type'), new Response(), ['POST']);
}
@@ -8,11 +8,12 @@
*/
namespace Slim\Tests\Handlers;
use PHPUnit\Framework\TestCase;
use Slim\Handlers\NotFound;
use Slim\Http\Response;
use Slim\Http\Uri;
class NotFoundTest extends \PHPUnit_Framework_TestCase
class NotFoundTest extends TestCase
{
public function notFoundProvider()
{
@@ -43,6 +44,9 @@ public function testNotFound($acceptHeader, $contentType, $startOfBody)
$this->assertEquals(0, strpos((string)$res->getBody(), $startOfBody));
}
/**
* @expectedException \UnexpectedValueException
*/
public function testNotFoundContentType()
{
$errorMock = $this->getMockBuilder(NotFound::class)->setMethods(['determineContentType'])->getMock();
@@ -51,7 +55,6 @@ public function testNotFoundContentType()
$req = $this->getMockBuilder('Slim\Http\Request')->disableOriginalConstructor()->getMock();
$this->setExpectedException('\UnexpectedValueException');
$errorMock->__invoke($req, new Response(), ['POST']);
}
@@ -9,10 +9,12 @@
namespace Slim\Tests\Handlers;
use Doctrine\Instantiator\Exception\UnexpectedValueException;
use PHPUnit\Framework\TestCase;
use Slim\Handlers\PhpError;
use Slim\Http\Response;
class PhpErrorTest extends \PHPUnit_Framework_TestCase
class PhpErrorTest extends TestCase
{
public function phpErrorProvider()
{
@@ -66,6 +68,7 @@ public function testPhpErrorDisplayDetails($acceptHeader, $contentType, $startOf
/**
* @requires PHP 7.0
* @expectedException \UnexpectedValueException
*/
public function testNotFoundContentType()
{
@@ -75,7 +78,6 @@ public function testNotFoundContentType()
$req = $this->getMockBuilder('Slim\Http\Request')->disableOriginalConstructor()->getMock();
$this->setExpectedException('\UnexpectedValueException');
$errorMock->__invoke($req, new Response(), new \Exception());
}
@@ -140,6 +142,7 @@ public function testPhpErrorDisplayDetails5($acceptHeader, $contentType, $startO
/**
* @requires PHP 5.0
* @expectedException \UnexpectedValueException
*/
public function testNotFoundContentType5()
{
@@ -152,7 +155,6 @@ public function testNotFoundContentType5()
$throwable = $this->getMockBuilder('\Throwable')->getMock();
$req = $this->getMockBuilder('Slim\Http\Request')->disableOriginalConstructor()->getMock();
$this->setExpectedException('\UnexpectedValueException');
$errorMock->__invoke($req, new Response(), $throwable);
}

0 comments on commit 54401a4

Please sign in to comment.
You can’t perform that action at this time.