Skip to content

Commit

Permalink
Merge pull request #2905 from t0mmy742/php7.2
Browse files Browse the repository at this point in the history
PHP 7.2 as minimal dependency
  • Loading branch information
l0gicgate committed Dec 31, 2019
2 parents 541fad7 + 962c27a commit 00d6610
Show file tree
Hide file tree
Showing 22 changed files with 168 additions and 194 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
.DS_Store
.idea
.phpunit.result.cache
composer.lock
phpunit.xml
clover.xml
Expand Down
6 changes: 2 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,20 +1,18 @@
language: php

dist: trusty

matrix:
include:
- php: 7.1
- php: 7.2
- php: 7.3
env: ANALYSIS='true'
- php: 7.4
- php: nightly

allow_failures:
- php: nightly

before_script:
- if [[ "$ANALYSIS" == 'true' ]]; then composer require php-coveralls/php-coveralls:^2.1.0 ; fi
- if [[ "$ANALYSIS" == 'true' ]]; then composer require php-coveralls/php-coveralls:^2.2.0 ; fi
- composer install -n

script:
Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"require": {
"ext-json": "*",
"nikic/fast-route": "^1.3",
"php": "^7.1",
"php": "^7.2",
"psr/container": "^1.0",
"psr/http-factory": "^1.0",
"psr/http-message": "^1.0",
Expand All @@ -48,7 +48,7 @@
"http-interop/http-factory-guzzle": "^1.0",
"nyholm/psr7": "^1.1",
"nyholm/psr7-server": "^0.3.0",
"phpunit/phpunit": "^7.5",
"phpunit/phpunit": "^8.5",
"phpspec/prophecy": "^1.10",
"phpstan/phpstan": "^0.11.5",
"slim/http": "^0.7",
Expand Down
2 changes: 1 addition & 1 deletion phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/7.1/phpunit.xsd"
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/8.5/phpunit.xsd"
backupGlobals="false"
backupStaticAttributes="false"
beStrictAboutTestsThatDoNotTestAnything="true"
Expand Down
2 changes: 1 addition & 1 deletion tests/AppTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@

class AppTest extends TestCase
{
public static function setupBeforeClass()
public static function setupBeforeClass(): void
{
ini_set('error_log', tempnam(sys_get_temp_dir(), 'slim'));
}
Expand Down
145 changes: 63 additions & 82 deletions tests/CallableResolverTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
use Prophecy\Prophecy\ObjectProphecy;
use Psr\Container\ContainerInterface;
use Psr\Http\Server\RequestHandlerInterface;
use RuntimeException;
use Slim\CallableResolver;
use Slim\Tests\Mocks\CallableTest;
use Slim\Tests\Mocks\InvokableTest;
Expand All @@ -26,15 +27,15 @@ class CallableResolverTest extends TestCase
*/
private $containerProphecy;

public static function setUpBeforeClass()
public static function setUpBeforeClass(): void
{
function testAdvancedCallable()
{
return true;
}
}

public function setUp()
public function setUp(): void
{
CallableTest::$CalledCount = 0;
InvokableTest::$CalledCount = 0;
Expand Down Expand Up @@ -211,12 +212,11 @@ public function testResolutionToAnInvokableClass()
$this->assertEquals(3, InvokableTest::$CalledCount);
}

/**
* @expectedException RuntimeException
* @expectedExceptionMessage Slim\Tests\Mocks\RequestHandlerTest is not resolvable
*/
public function testResolutionToAPsrRequestHandlerClass()
{
$this->expectException(RuntimeException::class);
$this->expectExceptionMessage('Slim\\Tests\\Mocks\\RequestHandlerTest is not resolvable');

$resolver = new CallableResolver(); // No container injected
$resolver->resolve(RequestHandlerTest::class);
}
Expand All @@ -230,22 +230,20 @@ public function testRouteResolutionToAPsrRequestHandlerClass()
$this->assertEquals('1', RequestHandlerTest::$CalledCount);
}

/**
* @expectedException RuntimeException
* @expectedExceptionMessage Slim\Tests\Mocks\RequestHandlerTest is not resolvable
*/
public function testMiddlewareResolutionToAPsrRequestHandlerClass()
{
$this->expectException(RuntimeException::class);
$this->expectExceptionMessage('Slim\\Tests\\Mocks\\RequestHandlerTest is not resolvable');

$resolver = new CallableResolver(); // No container injected
$resolver->resolveMiddleware(RequestHandlerTest::class);
}

/**
* @expectedException RuntimeException
* @expectedExceptionMessage {} is not resolvable
*/
public function testObjPsrRequestHandlerClass()
{
$this->expectException(RuntimeException::class);
$this->expectExceptionMessage('{} is not resolvable');

$obj = new RequestHandlerTest();
$resolver = new CallableResolver(); // No container injected
$resolver->resolve($obj);
Expand All @@ -261,23 +259,21 @@ public function testRouteObjPsrRequestHandlerClass()
$this->assertEquals('1', RequestHandlerTest::$CalledCount);
}

/**
* @expectedException RuntimeException
* @expectedExceptionMessage {} is not resolvable
*/
public function testMiddlewareObjPsrRequestHandlerClass()
{
$this->expectException(RuntimeException::class);
$this->expectExceptionMessage('{} is not resolvable');

$obj = new RequestHandlerTest();
$resolver = new CallableResolver(); // No container injected
$resolver->resolveMiddleware($obj);
}

/**
* @expectedException RuntimeException
* @expectedExceptionMessage a_requesthandler is not resolvable
*/
public function testObjPsrRequestHandlerClassInContainer()
{
$this->expectException(RuntimeException::class);
$this->expectExceptionMessage('a_requesthandler is not resolvable');

$this->containerProphecy->has('a_requesthandler')->willReturn(true);
$this->containerProphecy->get('a_requesthandler')->willReturn(new RequestHandlerTest());

Expand All @@ -302,12 +298,11 @@ public function testRouteObjPsrRequestHandlerClassInContainer()
$this->assertEquals('1', RequestHandlerTest::$CalledCount);
}

/**
* @expectedException RuntimeException
* @expectedExceptionMessage a_requesthandler is not resolvable
*/
public function testMiddlewareObjPsrRequestHandlerClassInContainer()
{
$this->expectException(RuntimeException::class);
$this->expectExceptionMessage('a_requesthandler is not resolvable');

$this->containerProphecy->has('a_requesthandler')->willReturn(true);
$this->containerProphecy->get('a_requesthandler')->willReturn(new RequestHandlerTest());

Expand Down Expand Up @@ -337,23 +332,21 @@ public function testResolutionToAPsrRequestHandlerClassWithCustomMethod()
$this->assertEquals('custom', $callableMiddleware[1]);
}

/**
* @expectedException RuntimeException
* @expectedExceptionMessage {} is not resolvable
*/
public function testObjMiddlewareClass()
{
$this->expectException(RuntimeException::class);
$this->expectExceptionMessage('{} is not resolvable');

$obj = new MiddlewareTest();
$resolver = new CallableResolver(); // No container injected
$resolver->resolve($obj);
}

/**
* @expectedException RuntimeException
* @expectedExceptionMessage {} is not resolvable
*/
public function testRouteObjMiddlewareClass()
{
$this->expectException(RuntimeException::class);
$this->expectExceptionMessage('{} is not resolvable');

$obj = new MiddlewareTest();
$resolver = new CallableResolver(); // No container injected
$resolver->resolveRoute($obj);
Expand All @@ -369,12 +362,11 @@ public function testMiddlewareObjMiddlewareClass()
$this->assertEquals('1', MiddlewareTest::$CalledCount);
}

/**
* @expectedException RuntimeException
* @expectedExceptionMessage callable_service:notFound is not resolvable
*/
public function testMethodNotFoundThrowException()
{
$this->expectException(RuntimeException::class);
$this->expectExceptionMessage('callable_service:notFound is not resolvable');

$this->containerProphecy->has('callable_service')->willReturn(true);
$this->containerProphecy->get('callable_service')->willReturn(new CallableTest());

Expand All @@ -384,12 +376,11 @@ public function testMethodNotFoundThrowException()
$resolver->resolve('callable_service:notFound');
}

/**
* @expectedException RuntimeException
* @expectedExceptionMessage callable_service:notFound is not resolvable
*/
public function testRouteMethodNotFoundThrowException()
{
$this->expectException(RuntimeException::class);
$this->expectExceptionMessage('callable_service:notFound is not resolvable');

$this->containerProphecy->has('callable_service')->willReturn(true);
$this->containerProphecy->get('callable_service')->willReturn(new CallableTest());

Expand All @@ -399,12 +390,11 @@ public function testRouteMethodNotFoundThrowException()
$resolver->resolveRoute('callable_service:notFound');
}

/**
* @expectedException RuntimeException
* @expectedExceptionMessage callable_service:notFound is not resolvable
*/
public function testMiddlewareMethodNotFoundThrowException()
{
$this->expectException(RuntimeException::class);
$this->expectExceptionMessage('callable_service:notFound is not resolvable');

$this->containerProphecy->has('callable_service')->willReturn(true);
$this->containerProphecy->get('callable_service')->willReturn(new CallableTest());

Expand All @@ -414,108 +404,99 @@ public function testMiddlewareMethodNotFoundThrowException()
$resolver->resolveMiddleware('callable_service:notFound');
}

/**
* @expectedException RuntimeException
* @expectedExceptionMessage Callable notFound does not exist
*/
public function testFunctionNotFoundThrowException()
{
$this->expectException(RuntimeException::class);
$this->expectExceptionMessage('Callable notFound does not exist');

/** @var ContainerInterface $container */
$container = $this->containerProphecy->reveal();
$resolver = new CallableResolver($container);
$resolver->resolve('notFound');
}

/**
* @expectedException RuntimeException
* @expectedExceptionMessage Callable notFound does not exist
*/
public function testRouteFunctionNotFoundThrowException()
{
$this->expectException(RuntimeException::class);
$this->expectExceptionMessage('Callable notFound does not exist');

/** @var ContainerInterface $container */
$container = $this->containerProphecy->reveal();
$resolver = new CallableResolver($container);
$resolver->resolveRoute('notFound');
}

/**
* @expectedException RuntimeException
* @expectedExceptionMessage Callable notFound does not exist
*/
public function testMiddlewareFunctionNotFoundThrowException()
{
$this->expectException(RuntimeException::class);
$this->expectExceptionMessage('Callable notFound does not exist');

/** @var ContainerInterface $container */
$container = $this->containerProphecy->reveal();
$resolver = new CallableResolver($container);
$resolver->resolveMiddleware('notFound');
}

/**
* @expectedException RuntimeException
* @expectedExceptionMessage Callable Unknown does not exist
*/
public function testClassNotFoundThrowException()
{
$this->expectException(RuntimeException::class);
$this->expectExceptionMessage('Callable Unknown does not exist');

/** @var ContainerInterface $container */
$container = $this->containerProphecy->reveal();
$resolver = new CallableResolver($container);
$resolver->resolve('Unknown:notFound');
}

/**
* @expectedException RuntimeException
* @expectedExceptionMessage Callable Unknown does not exist
*/
public function testRouteClassNotFoundThrowException()
{
$this->expectException(RuntimeException::class);
$this->expectExceptionMessage('Callable Unknown does not exist');

/** @var ContainerInterface $container */
$container = $this->containerProphecy->reveal();
$resolver = new CallableResolver($container);
$resolver->resolveRoute('Unknown:notFound');
}

/**
* @expectedException RuntimeException
* @expectedExceptionMessage Callable Unknown does not exist
*/
public function testMiddlewareClassNotFoundThrowException()
{
$this->expectException(RuntimeException::class);
$this->expectExceptionMessage('Callable Unknown does not exist');

/** @var ContainerInterface $container */
$container = $this->containerProphecy->reveal();
$resolver = new CallableResolver($container);
$resolver->resolveMiddleware('Unknown:notFound');
}

/**
* @expectedException RuntimeException
* @expectedExceptionMessage is not resolvable
*/
public function testCallableClassNotFoundThrowException()
{
$this->expectException(RuntimeException::class);
$this->expectExceptionMessage('is not resolvable');

/** @var ContainerInterface $container */
$container = $this->containerProphecy->reveal();
$resolver = new CallableResolver($container);
$resolver->resolve(['Unknown', 'notFound']);
}

/**
* @expectedException RuntimeException
* @expectedExceptionMessage is not resolvable
*/
public function testRouteCallableClassNotFoundThrowException()
{
$this->expectException(RuntimeException::class);
$this->expectExceptionMessage('is not resolvable');

/** @var ContainerInterface $container */
$container = $this->containerProphecy->reveal();
$resolver = new CallableResolver($container);
$resolver->resolveRoute(['Unknown', 'notFound']);
}

/**
* @expectedException RuntimeException
* @expectedExceptionMessage is not resolvable
*/
public function testMiddlewareCallableClassNotFoundThrowException()
{
$this->expectException(RuntimeException::class);
$this->expectExceptionMessage('is not resolvable');

/** @var ContainerInterface $container */
$container = $this->containerProphecy->reveal();
$resolver = new CallableResolver($container);
Expand Down
Loading

0 comments on commit 00d6610

Please sign in to comment.