diff options
Diffstat (limited to 'vendor/sabre/dav/tests/Sabre/DAV/Auth/PluginTest.php')
-rw-r--r-- | vendor/sabre/dav/tests/Sabre/DAV/Auth/PluginTest.php | 68 |
1 files changed, 31 insertions, 37 deletions
diff --git a/vendor/sabre/dav/tests/Sabre/DAV/Auth/PluginTest.php b/vendor/sabre/dav/tests/Sabre/DAV/Auth/PluginTest.php index 743446127..03c8a4624 100644 --- a/vendor/sabre/dav/tests/Sabre/DAV/Auth/PluginTest.php +++ b/vendor/sabre/dav/tests/Sabre/DAV/Auth/PluginTest.php @@ -1,58 +1,57 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\Auth; use Sabre\DAV; use Sabre\HTTP; -class PluginTest extends \PHPUnit_Framework_TestCase { - - function testInit() { - +class PluginTest extends \PHPUnit\Framework\TestCase +{ + public function testInit() + { $fakeServer = new DAV\Server(new DAV\SimpleCollection('bla')); $plugin = new Plugin(new Backend\Mock()); $this->assertTrue($plugin instanceof Plugin); $fakeServer->addPlugin($plugin); $this->assertEquals($plugin, $fakeServer->getPlugin('auth')); $this->assertInternalType('array', $plugin->getPluginInfo()); - } /** * @depends testInit */ - function testAuthenticate() { - + public function testAuthenticate() + { $fakeServer = new DAV\Server(new DAV\SimpleCollection('bla')); $plugin = new Plugin(new Backend\Mock()); $fakeServer->addPlugin($plugin); $this->assertTrue( - $fakeServer->emit('beforeMethod', [new HTTP\Request(), new HTTP\Response()]) + $fakeServer->emit('beforeMethod:GET', [new HTTP\Request('GET', '/'), new HTTP\Response()]) ); - } /** * @depends testInit - * @expectedException Sabre\DAV\Exception\NotAuthenticated + * @expectedException \Sabre\DAV\Exception\NotAuthenticated */ - function testAuthenticateFail() { - + public function testAuthenticateFail() + { $fakeServer = new DAV\Server(new DAV\SimpleCollection('bla')); $backend = new Backend\Mock(); $backend->fail = true; $plugin = new Plugin($backend); $fakeServer->addPlugin($plugin); - $fakeServer->emit('beforeMethod', [new HTTP\Request(), new HTTP\Response()]); - + $fakeServer->emit('beforeMethod:GET', [new HTTP\Request('GET', '/'), new HTTP\Response()]); } /** * @depends testAuthenticateFail */ - function testAuthenticateFailDontAutoRequire() { - + public function testAuthenticateFailDontAutoRequire() + { $fakeServer = new DAV\Server(new DAV\SimpleCollection('bla')); $backend = new Backend\Mock(); $backend->fail = true; @@ -61,17 +60,16 @@ class PluginTest extends \PHPUnit_Framework_TestCase { $plugin->autoRequireLogin = false; $fakeServer->addPlugin($plugin); $this->assertTrue( - $fakeServer->emit('beforeMethod', [new HTTP\Request(), new HTTP\Response()]) + $fakeServer->emit('beforeMethod:GET', [new HTTP\Request('GET', '/'), new HTTP\Response()]) ); $this->assertEquals(1, count($plugin->getLoginFailedReasons())); - } /** * @depends testAuthenticate */ - function testMultipleBackend() { - + public function testMultipleBackend() + { $fakeServer = new DAV\Server(new DAV\SimpleCollection('bla')); $backend1 = new Backend\Mock(); $backend2 = new Backend\Mock(); @@ -82,52 +80,48 @@ class PluginTest extends \PHPUnit_Framework_TestCase { $plugin->addBackend($backend2); $fakeServer->addPlugin($plugin); - $fakeServer->emit('beforeMethod', [new HTTP\Request(), new HTTP\Response()]); + $fakeServer->emit('beforeMethod:GET', [new HTTP\Request('GET', '/'), new HTTP\Response()]); $this->assertEquals('principals/admin', $plugin->getCurrentPrincipal()); - } /** * @depends testInit - * @expectedException Sabre\DAV\Exception + * @expectedException \Sabre\DAV\Exception */ - function testNoAuthBackend() { - + public function testNoAuthBackend() + { $fakeServer = new DAV\Server(new DAV\SimpleCollection('bla')); $plugin = new Plugin(); $fakeServer->addPlugin($plugin); - $fakeServer->emit('beforeMethod', [new HTTP\Request(), new HTTP\Response()]); - + $fakeServer->emit('beforeMethod:GET', [new HTTP\Request('GET', '/'), new HTTP\Response()]); } + /** * @depends testInit - * @expectedException Sabre\DAV\Exception + * @expectedException \Sabre\DAV\Exception */ - function testInvalidCheckResponse() { - + public function testInvalidCheckResponse() + { $fakeServer = new DAV\Server(new DAV\SimpleCollection('bla')); $backend = new Backend\Mock(); $backend->invalidCheckResponse = true; $plugin = new Plugin($backend); $fakeServer->addPlugin($plugin); - $fakeServer->emit('beforeMethod', [new HTTP\Request(), new HTTP\Response()]); - + $fakeServer->emit('beforeMethod:GET', [new HTTP\Request('GET', '/'), new HTTP\Response()]); } /** * @depends testAuthenticate */ - function testGetCurrentPrincipal() { - + public function testGetCurrentPrincipal() + { $fakeServer = new DAV\Server(new DAV\SimpleCollection('bla')); $plugin = new Plugin(new Backend\Mock()); $fakeServer->addPlugin($plugin); - $fakeServer->emit('beforeMethod', [new HTTP\Request(), new HTTP\Response()]); + $fakeServer->emit('beforeMethod:GET', [new HTTP\Request('GET', '/'), new HTTP\Response()]); $this->assertEquals('principals/admin', $plugin->getCurrentPrincipal()); - } - } |