Skip to content

Commit

Permalink
Improve tests.
Browse files Browse the repository at this point in the history
Signed-off-by: Mior Muhammad Zaki <crynobone@gmail.com>
  • Loading branch information
crynobone committed May 4, 2019
1 parent ccedd63 commit 7075750
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion tests/Unit/Server/CheckOriginTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public function it_can_detect_invalid_origin()
}

/** @test */
public function it_can_ignore_origin_if_header_isnt_set()
public function it_can_ignore_checks_if_header_isnt_set()
{
$component = m::mock(MessageComponentInterface::class);
$origins = ['0.0.0.0'];
Expand All @@ -76,6 +76,25 @@ public function it_can_ignore_origin_if_header_isnt_set()
$this->addToAssertionCount(1);
}

/** @test */
public function it_can_ignore_checks_if_origin_isnt_set()
{
$component = m::mock(MessageComponentInterface::class);
$origins = [];
$connection = m::mock(ConnectionInterface::class);
$request = m::mock(RequestInterface::class);

$request->shouldReceive('hasHeader')->once()->with('Origin')->andReturn(true)
->shouldReceive('getHeader')->never()->with('Origin')->andReturn(['127.0.0.1:8080']);

$component->shouldReceive('onOpen')->once()->with($connection, $request);

$checker = new CheckOrigin($component, $origins);
$checker->onOpen($connection, $request);

$this->addToAssertionCount(1);
}

/** @test */
public function it_pass_through_message_request()
{
Expand Down

0 comments on commit 7075750

Please sign in to comment.