Zend Expressive abstract test case
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
config
src
test
.gitignore
.travis.yml
LICENSE
README.md
composer.json
phpcs.xml.dist
phpunit.xml.dist

README.md

Zend expressive handler test

Build Status Coverage Status Latest Stable Version

Zend Expressive abstract test case for PHPUnit.

Zend Expressive 使用 PHPUnit 单元抽象测试工具

Installation / 安装使用

Install via composer.

composer require zfegg/expressive-test --dev

Usage / 使用


use Psr\Http\Message\ResponseInterface;
use Zfegg\ExpressiveTest\AbstractActionTestCase;

class HomePageTest extend AbstractActionTestCase {

    public function testHome() {
        $response = $this->runApp(
            'POST',
            '/?test=1',
            ['body' => '2'],
            ['HTTP_CONTENT_TYPE' => 'application/json'],
            '{"a":"b"}',
            ['cookie' => '3']
        );

        $this->assertInstanceOf(ResponseInterface::class, $response);
    }

    public function testPassMiddlewareOrMockService() {
    
        
        $this->container->setService('some middleware', new PassMiddleware());
        
        $mock = $this->createMock(SomeService::class);
        $this->container->setService('mock some service', $mock);

        $response = $this->runApp(
            'POST',
            '/?test=1',
            ['body' => '2'],
            ['HTTP_CONTENT_TYPE' => 'application/json'],
            '{"a":"b"}',
            ['cookie' => '3']
        );

        $this->assertInstanceOf(ResponseInterface::class, $response);
    }
}