oauth2-server/tests/unit/AbstractServerTest.php

27 lines
907 B
PHP
Raw Normal View History

2014-01-16 16:51:06 +00:00
<?php
namespace LeagueTests;
use LeagueTests\Stubs\StubAbstractServer;
2014-05-03 10:55:25 +01:00
class AbstractServerTest extends \PHPUnit_Framework_TestCase
2014-01-16 16:51:06 +00:00
{
2014-05-03 10:55:25 +01:00
public function testSetGet()
2014-01-16 16:51:06 +00:00
{
$server = new StubAbstractServer();
2014-07-12 12:07:46 +01:00
$var = 0;
2014-11-08 18:26:12 +00:00
$server->addEventListener('event.name', function () use ($var) {
2014-07-12 12:07:46 +01:00
$var++;
$this->assertSame(1, $var);
});
$server->getEventEmitter()->emit('event.name');
2014-01-16 16:51:06 +00:00
$this->assertTrue($server->getRequest() instanceof \Symfony\Component\HttpFoundation\Request);
2014-07-12 12:07:46 +01:00
$this->assertTrue($server->getEventEmitter() instanceof \League\Event\Emitter);
2014-01-16 16:51:06 +00:00
$server2 = new StubAbstractServer();
2014-11-08 18:26:12 +00:00
$server2->setRequest((new \Symfony\Component\HttpFoundation\Request()));
2014-07-12 12:07:46 +01:00
$server2->setEventEmitter(1);
2014-01-16 16:51:06 +00:00
$this->assertTrue($server2->getRequest() instanceof \Symfony\Component\HttpFoundation\Request);
}
2014-05-03 10:55:25 +01:00
}