Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:

strategy:
matrix:
php: [7.1, 7.2, 7.3, 7.4, 8.0]
php: [7.3, 7.4, 8.0]

steps:
- name: Checkout code
Expand Down
56 changes: 29 additions & 27 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,29 +1,31 @@
{
"name":"codeception/module-mezzio",
"description":"Codeception module for Mezzio framework",
"keywords":["codeception", "mezzio"],
"homepage":"http://codeception.com/",
"type":"library",
"license":"MIT",
"authors":[
{
"name":"Gintautas Miselis"
}
],
"minimum-stability": "RC",
"require": {
"php": ">=5.6.0 <9.0",
"codeception/lib-innerbrowser": "^1.0",
"codeception/codeception": "^4.0"
},
"require-dev": {
"codeception/module-rest": "dev-master",
"mezzio/mezzio": "~2.0 | ~3.0"
},
"autoload":{
"classmap": ["src/"]
},
"config": {
"classmap-authoritative": true
}
"name": "codeception/module-mezzio",
"description": "Codeception module for Mezzio framework",
"keywords": [ "codeception", "mezzio" ],
"homepage": "https://codeception.com/",
"type": "library",
"license": "MIT",
"authors": [
{
"name": "Gintautas Miselis"
}
],
"minimum-stability": "RC",
"require": {
"php": "^7.3 || ^8.0",
"codeception/lib-innerbrowser": "^1.0",
"codeception/codeception": "^4.0"
},
"require-dev": {
"codeception/module-rest": "^1.0",
"mezzio/mezzio": "^3.0"
},
"autoload": {
"classmap": [
"src/"
]
},
"config": {
"classmap-authoritative": true
}
}
4 changes: 4 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ A Codeception module for Mezzio framework.
[![Total Downloads](https://poser.pugx.org/codeception/module-mezzio/downloads)](https://packagist.org/packages/codeception/module-mezzio)
[![License](https://poser.pugx.org/codeception/module-mezzio/license)](/LICENSE)

## Requirements

* `PHP 7.3` or higher.

## Installation

```
Expand Down
28 changes: 14 additions & 14 deletions src/Codeception/Lib/Connector/Mezzio.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
<?php

declare(strict_types=1);

namespace Codeception\Lib\Connector;

use Codeception\Configuration;
use Codeception\Lib\Connector\Mezzio\ResponseCollector;
use Exception;
use Interop\Container\ContainerInterface;
use Symfony\Component\BrowserKit\AbstractBrowser as Client;
use Symfony\Component\BrowserKit\Response;
use Symfony\Component\BrowserKit\Request as BrowserKitRequest;
Expand All @@ -23,7 +28,7 @@ class Mezzio extends Client
private $responseCollector;

/**
* @var \Interop\Container\ContainerInterface
* @var ContainerInterface
*/
private $container;

Expand All @@ -34,9 +39,7 @@ class Mezzio extends Client

/**
* @param BrowserKitRequest $request
*
* @return Response
* @throws \Exception
* @throws Exception
*/
public function doRequest($request)
{
Expand Down Expand Up @@ -115,7 +118,7 @@ public function doRequest($request)
);
}

private function convertFiles(array $files)
private function convertFiles(array $files): array
{
$fileObjects = [];
foreach ($files as $fieldName => $file) {
Expand All @@ -136,7 +139,7 @@ private function convertFiles(array $files)
return $fileObjects;
}

private function extractHeaders(BrowserKitRequest $request)
private function extractHeaders(BrowserKitRequest $request): array
{
$headers = [];
$server = $request->getServer();
Expand All @@ -155,7 +158,7 @@ private function extractHeaders(BrowserKitRequest $request)
return $headers;
}

public function initApplication()
public function initApplication(): Application
{
$cwd = getcwd();
$projectDir = Configuration::projectDir();
Expand Down Expand Up @@ -191,7 +194,7 @@ public function initApplication()
return $app;
}

private function initResponseCollector()
private function initResponseCollector(): void
{
if (!method_exists($this->application, 'getEmitter')) {
//Does not exist in Mezzio v3
Expand All @@ -210,21 +213,18 @@ private function initResponseCollector()
$emitterStack->unshift($this->responseCollector);
}

public function getContainer()
public function getContainer(): ContainerInterface
{
return $this->container;
}

/**
* @param Application
*/
public function setApplication(Application $application)
public function setApplication(Application $application): void
{
$this->application = $application;
$this->initResponseCollector();
}

public function setConfig(array $config)
public function setConfig(array $config): void
{
$this->config = $config;
}
Expand Down
10 changes: 7 additions & 3 deletions src/Codeception/Lib/Connector/Mezzio/ResponseCollector.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
<?php

declare(strict_types=1);

namespace Codeception\Lib\Connector\Mezzio;

use LogicException;
use Psr\Http\Message\ResponseInterface;
use Laminas\Diactoros\Response\EmitterInterface;

Expand All @@ -16,15 +20,15 @@ public function emit(ResponseInterface $response)
$this->response = $response;
}

public function getResponse()
public function getResponse(): ResponseInterface
{
if ($this->response === null) {
throw new \LogicException('Response wasn\'t emitted yet');
throw new LogicException('Response wasn\'t emitted yet');
}
return $this->response;
}

public function clearResponse()
public function clearResponse(): void
{
$this->response = null;
}
Expand Down
8 changes: 7 additions & 1 deletion src/Codeception/Module/Mezzio.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
<?php

declare(strict_types=1);

namespace Codeception\Module;

use Codeception\Lib\Framework;
Expand Down Expand Up @@ -31,6 +34,9 @@
*/
class Mezzio extends Framework implements DoctrineProvider
{
/**
* @var array
*/
protected $config = [
'container' => 'config/container.php',
'recreateApplicationBetweenTests' => true,
Expand Down Expand Up @@ -73,7 +79,7 @@ public function _before(TestInterface $test)
if ($this->config['recreateApplicationBetweenTests'] != false && $this->config['recreateApplicationBetweenRequests'] == false) {
$this->application = $this->client->initApplication();
$this->container = $this->client->getContainer();
} elseif (isset($this->application)) {
} elseif ($this->application !== null) {
$this->client->setApplication($this->application);
}
}
Expand Down