oauth2-server/tests/unit/AbstractServerTest.php

36 lines
1.1 KiB
PHP
Raw Normal View History

2014-01-16 22:21:06 +05:30
<?php
namespace LeagueTests;
use LeagueTests\Stubs\StubAbstractServer;
2014-05-03 15:25:25 +05:30
class AbstractServerTest extends \PHPUnit_Framework_TestCase
2014-01-16 22:21:06 +05:30
{
2014-05-03 15:25:25 +05:30
public function testSetGet()
2014-01-16 22:21:06 +05:30
{
$server = new StubAbstractServer();
2014-07-12 16:37:46 +05:30
$var = 0;
$server->addEventListener('event.name', function() use ($var) {
$var++;
$this->assertSame(1, $var);
});
$server->getEventEmitter()->emit('event.name');
2014-01-16 22:21:06 +05:30
$this->assertTrue($server->getRequest() instanceof \Symfony\Component\HttpFoundation\Request);
2014-07-12 16:37:46 +05:30
$this->assertTrue($server->getEventEmitter() instanceof \League\Event\Emitter);
2014-01-16 22:21:06 +05:30
$server2 = new StubAbstractServer();
$server2->setRequest((new \Symfony\Component\HttpFoundation\Request));
2014-07-12 16:37:46 +05:30
$server2->setEventEmitter(1);
2014-01-16 22:21:06 +05:30
$this->assertTrue($server2->getRequest() instanceof \Symfony\Component\HttpFoundation\Request);
2014-07-12 16:37:46 +05:30
2014-01-16 22:21:06 +05:30
}
2014-05-03 15:25:25 +05:30
public function testGetStorageException()
2014-01-16 22:21:06 +05:30
{
$this->setExpectedException('League\OAuth2\Server\Exception\ServerErrorException');
2014-01-16 22:21:06 +05:30
$server = new StubAbstractServer();
$server->getStorage('foobar');
}
2014-05-03 15:25:25 +05:30
}