Skip to content

Commit

Permalink
add and fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
Prasetyo committed Aug 10, 2015
1 parent 1d29524 commit f757d77
Show file tree
Hide file tree
Showing 3 changed files with 82 additions and 5 deletions.
4 changes: 3 additions & 1 deletion spec/ApplicationSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,8 @@ public function it_should_throw_exception_when_server_is_not_exist(ContainerInte
public function it_should_able_to_run(
ContainerInterface $container,
RouteCollector $collector,
ServerInterface $server
ServerInterface $server,
EventDispatcherInterface $event
) {
/**
* predictions
Expand All @@ -208,6 +209,7 @@ public function it_should_able_to_run(
]]);
$container->offsetGet('Server')->willReturn($server);
$container->offsetGet('RouteCollector')->willReturn($collector);
$container->offsetGet('EventDispatcher')->willReturn($event);

/**
* test method
Expand Down
11 changes: 7 additions & 4 deletions spec/Lib/Server/Swoole/ServerRequestHandlerSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
use Relay\RelayBuilder;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Vinnige\Contracts\ContainerInterface;
use Vinnige\Contracts\ServerResponderInterface;
use Vinnige\Lib\ErrorHandler\ErrorHandler;

class ServerRequestHandlerSpec extends ObjectBehavior
{
public function let(ContainerInterface $container)
public function let(ContainerInterface $container, EventDispatcherInterface $event)
{
$this->beConstructedWith($container);
$this->beConstructedWith($container, $event);
}

public function it_is_initializable()
Expand All @@ -30,7 +30,8 @@ public function it_should_able_handle_incoming_request(
ResponseInterface $response,
RelayBuilder $relayBuilder,
ContainerInterface $container,
ServerResponderInterface $serverResponder
ServerResponderInterface $serverResponder,
EventDispatcherInterface $event
) {
unset($GLOBALS['_COOKIE']);
unset($GLOBALS['_GET']);
Expand All @@ -46,6 +47,8 @@ public function it_should_able_handle_incoming_request(

$container->offsetGet('Middlewares')->willReturn([]);

$container->offsetGet('EventDispatcher')->willReturn($event);

$relayBuilder->newInstance([])->willReturn(
function (ServerRequestInterface $req, ResponseInterface $res) {
return $res;
Expand Down
72 changes: 72 additions & 0 deletions spec/Providers/KernelServiceProviderSpec.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
<?php

namespace spec\Vinnige\Providers;

use Illuminate\Container\Container;
use PHPixie\HTTP;
use PHPixie\HTTP\Messages\Message\Response;
use PHPixie\HTTP\Messages\Stream\StringStream;
use PhpSpec\ObjectBehavior;
use Prophecy\Argument;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Vinnige\Contracts\ContainerInterface;
use Vinnige\Lib\Config\Config;
use Vinnige\Lib\Container\LaravelContainer;

class KernelServiceProviderSpec extends ObjectBehavior
{
private $container;

public function let()
{
$this->container = new LaravelContainer(new Container());
$this->container['Config'] = new Config([
'http.streams' => [
StringStream::class => ''
],
'http.response' => [
'class' => Response::class,
'protocol.version' => '1.1',
'header' => [],
'stream' => StringStream::class
],
]);

$this->beConstructedWith();

$this->register($this->container);
}

public function it_is_initializable()
{
$this->shouldHaveType('Vinnige\Providers\KernelServiceProvider');
}

public function it_should_return_http_message()
{
$this->container['Http'];
}

public function it_should_return_request(HTTP $http)
{
$this->container['Http'] = $http;
$this->container['Request'];
}

public function it_should_return_response()
{
$this->container['Response'];
}

public function it_should_return_event_dispatcher()
{
$this->container['EventDispatcher'];
}

public function it_should_able_to_register_event_listener(
ContainerInterface $container,
EventDispatcherInterface $event
) {
$this->subscribe($container, $event);
}
}

0 comments on commit f757d77

Please sign in to comment.