Skip to content

Commit

Permalink
Merge pull request #2 from rstgroup/improve_testing
Browse files Browse the repository at this point in the history
Update phpunit, drop support php 5.5, better testing, add psr-11
  • Loading branch information
snapshotpl authored May 24, 2017
2 parents f94aaeb + a3ac15e commit 5fff27d
Show file tree
Hide file tree
Showing 11 changed files with 40 additions and 37 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
/vendor/
composer.lock
/nbproject/private/
22 changes: 12 additions & 10 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
language: php

matrix:
fast_finish: true
include:
- php: 5.5
- php: 5.6
- php: 7
- php: hhvm
php:
- 5.6
- 7.0
- 7.1

install:
- travis_retry composer install --no-interaction --ignore-platform-reqs --prefer-source
- composer info -i
env:
- DEPS=lowest
- DEPS=latest

before_script:
- phpenv config-rm xdebug.ini
- if [[ $DEPS == 'lowest' ]]; then composer update --prefer-stable --no-interaction --prefer-lowest ; fi
- if [[ $DEPS == 'latest' ]]; then composer update --prefer-stable --no-interaction ; fi

script:
- ./vendor/bin/phpunit
3 changes: 0 additions & 3 deletions Module.php

This file was deleted.

8 changes: 2 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,8 @@ cannot send non-standard methods like ie. `LINK`. It can be used as PSR-7 middew

## Installation

```json
{
"require": {
"rstgroup/http-method-override": "^1.0"
}
}
```
composer require rstgroup/http-method-override
```

Check suggested dependencies in [composer.json](composer.json) and add it to your dependencies.
Expand Down
5 changes: 3 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,12 @@
"module"
],
"require": {
"php": "^5.5 || ^7.0"
"php": ">=5.6",
"psr/container": "^1.0"
},
"require-dev": {
"psr/http-message": "^1.0",
"phpunit/phpunit": "^4.8.21",
"phpunit/phpunit": "^5.6 || ^6.0",
"zendframework/zend-http": "^2.4",
"zendframework/zend-eventmanager": "^2.4",
"zendframework/zend-mvc": "^2.4",
Expand Down
4 changes: 3 additions & 1 deletion src/HttpMethodOverrideListenerFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@

namespace RstGroup\HttpMethodOverride;

use Psr\Container\ContainerInterface;

/**
* @codeCoverageIgnore
*/
final class HttpMethodOverrideListenerFactory
{
public function __invoke($services)
public function __invoke(ContainerInterface $services)
{
$service = $services->get(HttpMethodOverrideService::class);

Expand Down
4 changes: 3 additions & 1 deletion src/HttpMethodOverrideMiddlewareFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@

namespace RstGroup\HttpMethodOverride;

use Psr\Container\ContainerInterface;

/**
* @codeCoverageIgnore
*/
final class HttpMethodOverrideMiddlewareFactory
{
public function __invoke($services)
public function __invoke(ContainerInterface $services)
{
$service = $services->get(HttpMethodOverrideService::class);

Expand Down
4 changes: 3 additions & 1 deletion src/HttpMethodOverrideServiceFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@

namespace RstGroup\HttpMethodOverride;

use Psr\Container\ContainerInterface;

/**
* @codeCoverageIgnore
*/
final class HttpMethodOverrideServiceFactory
{
public function __invoke($services)
public function __invoke(ContainerInterface $services)
{
$config = $services->get('config')['rst_group']['http_method_override'];

Expand Down
8 changes: 4 additions & 4 deletions test/HttpMethodOverrideListenerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@

namespace RstGroup\HttpMethodOverride\Test;

use PHPUnit_Framework_TestCase;
use PHPUnit\Framework\TestCase;
use RstGroup\HttpMethodOverride\HttpMethodOverrideListener;
use RstGroup\HttpMethodOverride\HttpMethodOverrideService;
use Zend\EventManager\EventManagerInterface;
use Zend\Http\Request;
use Zend\Mvc\MvcEvent;
use Zend\Stdlib\RequestInterface;

class HttpMethodOverrideListenerTest extends PHPUnit_Framework_TestCase
class HttpMethodOverrideListenerTest extends TestCase
{
protected $listener;

Expand Down Expand Up @@ -53,7 +53,7 @@ public function testNotOverride()

public function testNoneHtmlRequest()
{
$request = $this->getMock(RequestInterface::class);
$request = $this->createMock(RequestInterface::class);

$event = new MvcEvent();
$event->setRequest($request);
Expand All @@ -67,7 +67,7 @@ public function testNoneHtmlRequest()

public function testAttach()
{
$eventManager = $this->getMock(EventManagerInterface::class);
$eventManager = $this->createMock(EventManagerInterface::class);
$eventManager->expects($this->once())->method('attach')->willReturnCallback(function($name, $callback){
$this->assertTrue(is_callable($callback));
});
Expand Down
12 changes: 6 additions & 6 deletions test/HttpMethodOverrideMiddlewareTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@

namespace RstGroup\HttpMethodOverride\Test;

use PHPUnit_Framework_TestCase;
use PHPUnit\Framework\TestCase;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
use RstGroup\HttpMethodOverride\HttpMethodOverrideMiddleware;
use RstGroup\HttpMethodOverride\HttpMethodOverrideService;
use Zend\Diactoros\ServerRequest;

class HttpMethodOverrideMiddlewareTest extends PHPUnit_Framework_TestCase
class HttpMethodOverrideMiddlewareTest extends TestCase
{
protected $middleware;

Expand All @@ -22,8 +22,8 @@ protected function setUp()

public function testCallNext()
{
$request = $this->getMock(ServerRequestInterface::class);
$response = $this->getMock(ResponseInterface::class);
$request = $this->createMock(ServerRequestInterface::class);
$response = $this->createMock(ResponseInterface::class);

$next = function(ServerRequestInterface $request, ResponseInterface $response) {
return $response;
Expand All @@ -40,7 +40,7 @@ public function testOverride()
$request = $request->withHeader(HttpMethodOverrideService::OVERRIDE_HEADER, 'PUT');
$request = $request->withMethod('POST');

$response = $this->getMock(ResponseInterface::class);
$response = $this->createMock(ResponseInterface::class);

$next = function(ServerRequestInterface $request) {
$this->assertSame('PUT', $request->getMethod());
Expand All @@ -55,7 +55,7 @@ public function testNotOverride()
$request = $request->withHeader(HttpMethodOverrideService::OVERRIDE_HEADER, 'GET');
$request = $request->withMethod('POST');

$response = $this->getMock(ResponseInterface::class);
$response = $this->createMock(ResponseInterface::class);

$next = function(ServerRequestInterface $request) {
$this->assertSame('POST', $request->getMethod());
Expand Down
6 changes: 3 additions & 3 deletions test/HttpMethodOverrideServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
namespace RstGroup\HttpMethodOverride\Test;

use InvalidArgumentException;
use PHPUnit_Framework_TestCase;
use PHPUnit\Framework\TestCase;
use RstGroup\HttpMethodOverride\HttpMethodOverrideService;

class HttpMethodOverrideServiceTest extends PHPUnit_Framework_TestCase
class HttpMethodOverrideServiceTest extends TestCase
{
/**
* @dataProvider notmethodInMapProvider
Expand Down Expand Up @@ -74,7 +74,7 @@ public function testMapIsNotAnArray()
{
$object = new HttpMethodOverrideService(['POST' => 'NONE']);

$this->setExpectedException(InvalidArgumentException::class);
$this->expectException(InvalidArgumentException::class);

$object->getOverridedMethod('POST', [
HttpMethodOverrideService::OVERRIDE_HEADER_GOOGLE => 'NONE',
Expand Down

0 comments on commit 5fff27d

Please sign in to comment.