Skip to content

Commit

Permalink
new version
Browse files Browse the repository at this point in the history
  • Loading branch information
oscarotero committed Dec 3, 2020
1 parent adb701a commit 03a08e6
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 12 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).

## [2.0.1] - 2020-12-03
### Added
- Support for PHP 8.0

## [2.0.0] - 2019-11-29
### Removed
- Support for PHP 7.0 and 7.1
Expand Down Expand Up @@ -80,6 +84,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
## 0.1.0 - 2017-04-19
First version

[2.0.1]: https://github.com/middlewares/request-handler/compare/v2.0.0...v2.0.1
[2.0.0]: https://github.com/middlewares/request-handler/compare/v1.4.0...v2.0.0
[1.4.0]: https://github.com/middlewares/request-handler/compare/v1.3.0...v1.4.0
[1.3.0]: https://github.com/middlewares/request-handler/compare/v1.2.0...v1.3.0
Expand Down
37 changes: 25 additions & 12 deletions tests/RequestHandlerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,19 @@ class RequestHandlerTest extends TestCase
{
use ProphecyTrait;

/**
* phpunit 8 support
*/
public static function assertMatchesRegularExpression(string $pattern, string $string, string $message = ''): void
{
if (method_exists(parent::class, 'assertMatchesRegularExpression')) {
parent::assertMatchesRegularExpression($pattern, $string, $message);
return;
}

self::assertRegExp($pattern, $string, $message);
}

public static function handleRequest(ServerRequestInterface $request): ResponseInterface
{
return Factory::createResponse();
Expand All @@ -36,7 +49,7 @@ public function testString()
Factory::createServerRequest('GET', '/')->withAttribute('request-handler', __CLASS__.'::handleRequest')
);

$this->assertSame(200, $response->getStatusCode());
self::assertSame(200, $response->getStatusCode());
}

public function testCustomAttribute()
Expand All @@ -48,7 +61,7 @@ public function testCustomAttribute()
Factory::createServerRequest('GET', '/')->withAttribute('custom', __CLASS__.'::handleRequest')
);

$this->assertSame(200, $response->getStatusCode());
self::assertSame(200, $response->getStatusCode());
}

public function testInvalidHandler()
Expand Down Expand Up @@ -79,7 +92,7 @@ public function testCustomContainer()
Factory::createServerRequest('GET', '/')->withAttribute('request-handler', 'IndexController')
);

$this->assertSame(200, $response->getStatusCode());
self::assertSame(200, $response->getStatusCode());
}

public function testArrayHandler()
Expand All @@ -94,7 +107,7 @@ public function testArrayHandler()
$request
);

$this->assertSame('Ok', (string) $response->getBody());
self::assertSame('Ok', (string) $response->getBody());
}

public function testRequestHandler()
Expand All @@ -109,8 +122,8 @@ public function testRequestHandler()
}))
);

$this->assertSame(200, $response->getStatusCode());
$this->assertSame('Bar', $response->getHeaderLine('X-Foo'));
self::assertSame(200, $response->getStatusCode());
self::assertSame('Bar', $response->getHeaderLine('X-Foo'));
}

public function testClosure()
Expand All @@ -125,8 +138,8 @@ public function testClosure()
})
);

$this->assertSame(200, $response->getStatusCode());
$this->assertSame('Bar', $response->getHeaderLine('X-Foo'));
self::assertSame(200, $response->getStatusCode());
self::assertSame('Bar', $response->getHeaderLine('X-Foo'));
}

public function testContinueOnEmptyClosure()
Expand All @@ -140,8 +153,8 @@ function () {
]
);

$this->assertSame(200, $response->getStatusCode());
$this->assertSame('Fallback', (string) $response->getBody());
self::assertSame(200, $response->getStatusCode());
self::assertSame('Fallback', (string) $response->getBody());
}

public function testThrowExceptionOnEmpty()
Expand All @@ -164,7 +177,7 @@ function () {
]
);

$this->assertSame('Empty request handler', (string) $response->getBody());
self::assertSame('Empty request handler', (string) $response->getBody());
}

public function testThrowExceptionOnInvalidHandler()
Expand All @@ -189,6 +202,6 @@ function () {
->withAttribute('request-handler', ['--invalid--'])
);

$this->assertSame('Invalid request handler: array', (string) $response->getBody());
self::assertSame('Invalid request handler: array', (string) $response->getBody());
}
}

0 comments on commit 03a08e6

Please sign in to comment.