Skip to content

Commit

Permalink
Migrate to laminas (#11)
Browse files Browse the repository at this point in the history
* Migrate to laminas
  • Loading branch information
snapshotpl authored May 31, 2021
1 parent 9688980 commit b29beeb
Show file tree
Hide file tree
Showing 8 changed files with 49 additions and 46 deletions.
1 change: 0 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ matrix:
env:
- DEPS=latest


install:
- if [[ $DEPS == 'latest' ]]; then travis_retry composer update --no-interaction ; fi
- if [[ $DEPS == 'lowest' ]]; then travis_retry composer update --no-interaction --prefer-lowest ; fi
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Change Log

## [3.0.0] - 2021-05-31
### Added
- Migrate to Laminas

## [2.0.0] - 2016-02-08
### Added
- Support for php 7.3
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

[![Build Status](https://travis-ci.org/rstgroup/request-id-module.svg?branch=master)](https://travis-ci.org/rstgroup/request-id-module)

This module provide integration possibility to generate and add `request id` to request/response's header.
This module provide integration possibility to generate and add `request id` to request/response's header in Laminas applications.
If you want more information, how `request id` is generating, check dependent project [php-middleware/request-id](https://github.com/php-middleware/request-id).

## Installation
Expand All @@ -12,7 +12,7 @@ composer require rstgroup/request-id-module
```


In your ZF2 application config add to module list
In your Laminas application config add to module list

```php
return [
Expand Down
30 changes: 15 additions & 15 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
{
"name": "rstgroup/request-id-module",
"require": {
"php": "^7.1",
"zendframework/zend-eventmanager": "^3",
"zendframework/zend-http": "^2.4",
"zendframework/zend-mvc": "^3",
"zendframework/zend-servicemanager": "^3.3",
"zendframework/zend-stdlib": "^3.2.1",
"zendframework/zend-psr7bridge": "^1.0",
"php": "^7.1 || ^8.0",
"laminas/laminas-eventmanager": "^3",
"laminas/laminas-http": "^2.4",
"laminas/laminas-mvc": "^3",
"laminas/laminas-servicemanager": "^3.3",
"laminas/laminas-stdlib": "^3.2.1",
"laminas/laminas-psr7bridge": "^1.0",
"php-middleware/request-id": "^4.0"
},
"require-dev": {
"phpunit/phpunit": "^7.5.20",
"zendframework/zend-modulemanager": "^2.4",
"zendframework/zend-config": "^2.4 | ^3.0",
"zendframework/zend-i18n": "^2.4",
"zendframework/zend-log": "^2.4",
"zendframework/zend-serializer": "^2.4",
"zendframework/zend-session": "^2.4",
"zendframework/zend-test": "^3"
"phpunit/phpunit": "^7.5.20 || ^8.5.15",
"laminas/laminas-modulemanager": "^2.9.0",
"laminas/laminas-config": "^3.3",
"laminas/laminas-i18n": "^2.4",
"laminas/laminas-log": "^2.4",
"laminas/laminas-serializer": "^2.4",
"laminas/laminas-session": "^2.4",
"laminas/laminas-test": "^3"
},
"autoload": {
"psr-4": {
Expand Down
16 changes: 8 additions & 8 deletions src/RequestIdListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@
use PhpMiddleware\RequestId\Exception\MissingRequestId;
use PhpMiddleware\RequestId\Generator\GeneratorInterface;
use PhpMiddleware\RequestId\RequestIdProviderInterface;
use Zend\EventManager\AbstractListenerAggregate;
use Zend\EventManager\EventManagerInterface;
use Zend\Http\Request as HttpRequest;
use Zend\Mvc\MvcEvent;
use Laminas\EventManager\AbstractListenerAggregate;
use Laminas\EventManager\EventManagerInterface;
use Laminas\Http\Request as HttpRequest;
use Laminas\Mvc\MvcEvent;
use PhpMiddleware\RequestId\RequestIdProviderFactoryInterface;
use Zend\Http\Header\GenericHeader;
use Zend\Http\Response as HttpResponse;
use Zend\Psr7Bridge\Psr7ServerRequest;
use Laminas\Http\Header\GenericHeader;
use Laminas\Http\Response as HttpResponse;
use Laminas\Psr7Bridge\Psr7ServerRequest;

final class RequestIdListener extends AbstractListenerAggregate implements RequestIdProviderInterface
{
Expand Down Expand Up @@ -43,7 +43,7 @@ public function loadRequestId(MvcEvent $event): ?string
$request = $event->getRequest();

if ($request instanceof HttpRequest) {
$psr7Request = Psr7ServerRequest::fromZend($request);
$psr7Request = Psr7ServerRequest::fromLaminas($request);
$requestIdProvider = $this->requestIdProviderFactory->create($psr7Request);
$this->requestId = $requestIdProvider->getRequestId();

Expand Down
24 changes: 12 additions & 12 deletions test/RequestIdIntegrationTest.php
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
<?php
namespace RstGroup\RequestIdModule\Test;

use Zend\Http\Response;
use Zend\Mvc\Controller\ControllerManager;
use Zend\Mvc\Router\RouteStackInterface;
use Zend\Stdlib\ArrayUtils;
use Zend\Stdlib\DispatchableInterface;
use Zend\Stdlib\RequestInterface;
use Zend\Stdlib\ResponseInterface;
use Zend\Test\PHPUnit\Controller\AbstractHttpControllerTestCase;
use Laminas\Http\Response;
use Laminas\Mvc\Controller\ControllerManager;
use Laminas\Mvc\Router\RouteStackInterface;
use Laminas\Stdlib\ArrayUtils;
use Laminas\Stdlib\DispatchableInterface;
use Laminas\Stdlib\RequestInterface;
use Laminas\Stdlib\ResponseInterface;
use Laminas\Test\PHPUnit\Controller\AbstractHttpControllerTestCase;

class RequestIdIntegrationTest extends AbstractHttpControllerTestCase
{
protected $traceError = false;

protected function setUp()
protected function setUp(): void
{
parent::setUp();

Expand All @@ -31,11 +31,11 @@ protected function setUp()
]);
}

public function tearDown()
public function tearDown(): void
{
unset($_SERVER['HTTP_X_REQUEST_ID']);

return parent::tearDown();
parent::tearDown();
}

/**
Expand Down Expand Up @@ -194,7 +194,7 @@ protected function assertHasRequestHeader($header)
* Get response header by key
*
* @param string $header
* @return \Zend\Http\Header\HeaderInterface|false
* @return \Laminas\Http\Header\HeaderInterface|false
*/
protected function getRegeustHeader($header)
{
Expand Down
12 changes: 6 additions & 6 deletions test/RequestIdListenerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,19 @@
use PhpMiddleware\RequestId\RequestIdProviderInterface;
use PHPUnit\Framework\TestCase;
use RstGroup\RequestIdModule\RequestIdListener;
use Zend\Console\Response as ConsoleResponse;
use Zend\Console\Request as ConsoleRequest;
use Zend\Http\Request as HttpRequest;
use Zend\Http\Response as HttpResponse;
use Zend\Mvc\MvcEvent;
use Laminas\Console\Response as ConsoleResponse;
use Laminas\Console\Request as ConsoleRequest;
use Laminas\Http\Request as HttpRequest;
use Laminas\Http\Response as HttpResponse;
use Laminas\Mvc\MvcEvent;

class RequestIdListenerTest extends TestCase
{
protected $requestIdProviderFactoryInterface;

protected $requestIdProviderInterface;

public function setUp()
public function setUp(): void
{
$this->requestIdProviderFactoryInterface = $this->createMock(RequestIdProviderFactoryInterface::class);
$this->requestIdProviderInterface = $this->createMock(RequestIdProviderInterface::class);
Expand Down
4 changes: 2 additions & 2 deletions test/TestAsset/application.config.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@
],
];

if (class_exists(\Zend\Router\Module::class)) {
$config['modules'][] = 'Zend\Router';
if (class_exists(\Laminas\Router\Module::class)) {
$config['modules'][] = \Laminas\Router\Module::class;
}

return $config;

0 comments on commit b29beeb

Please sign in to comment.