Fixed Session unit tests from PSR-7

This commit is contained in:
Chris Boden 2016-02-11 18:30:35 -05:00
parent 524f879954
commit 1523f39956
2 changed files with 12 additions and 6 deletions

View File

@ -38,7 +38,7 @@ class SessionProvider implements HttpServerInterface {
protected $_serializer;
/**
* @param \Ratchet\HttpServerInterface $app
* @param \Ratchet\Http\HttpServerInterface $app
* @param \SessionHandlerInterface $handler
* @param array $options
* @param \Ratchet\Session\Serialize\HandlerInterface $serializer
@ -80,7 +80,7 @@ class SessionProvider implements HttpServerInterface {
$crumbs = $this->parseCookie($cookie);
return isset($crumbs[$sessionName]) ? $crumbs[$sessionName] : false;
return isset($crumbs['cookies'][$sessionName]) ? $crumbs['cookies'][$sessionName] : false;
}, false);
if (null === $request || false === $id) {

View File

@ -1,7 +1,6 @@
<?php
namespace Ratchet\Session;
use Ratchet\AbstractMessageComponentTestCase;
use Ratchet\Mock\MemorySessionHandler;
use Symfony\Component\HttpFoundation\Session\Storage\Handler\PdoSessionHandler;
use Symfony\Component\HttpFoundation\Session\Storage\Handler\NullSessionHandler;
@ -83,8 +82,8 @@ class SessionProviderTest extends AbstractMessageComponentTestCase {
$component = new SessionProvider($this->getMock($this->getComponentClassString()), $pdoHandler, array('auto_start' => 1));
$connection = $this->getMock('Ratchet\\ConnectionInterface');
$headers = $this->getMock('Guzzle\\Http\\Message\\Request', array('getCookie'), array('POST', '/', array()));
$headers->expects($this->once())->method('getCookie', array(ini_get('session.name')))->will($this->returnValue($sessionId));
$headers = $this->getMock('Psr\Http\Message\RequestInterface');
$headers->expects($this->once())->method('getHeader')->will($this->returnValue([ini_get('session.name') . "={$sessionId};"]));
$component->onOpen($connection, $headers);
@ -94,7 +93,7 @@ class SessionProviderTest extends AbstractMessageComponentTestCase {
protected function newConn() {
$conn = $this->getMock('Ratchet\ConnectionInterface');
$headers = $this->getMock('Guzzle\Http\Message\Request', array('getCookie'), array('POST', '/', array()));
$headers = $this->getMock('Psr\Http\Message\Request', array('getCookie'), array('POST', '/', array()));
$headers->expects($this->once())->method('getCookie', array(ini_get('session.name')))->will($this->returnValue(null));
return $conn;
@ -115,4 +114,11 @@ class SessionProviderTest extends AbstractMessageComponentTestCase {
$this->setExpectedException('\RuntimeException');
new SessionProvider($this->getMock($this->getComponentClassString()), $this->getMock('\SessionHandlerInterface'));
}
protected function doOpen($conn) {
$request = $this->getMock('Psr\Http\Message\RequestInterface');
$request->expects($this->any())->method('getHeader')->will($this->returnValue([]));
$this->_serv->onOpen($conn, $request);
}
}