diff options
author | Andrew Manning <tamanning@zoho.com> | 2016-05-11 05:54:20 -0400 |
---|---|---|
committer | Andrew Manning <tamanning@zoho.com> | 2016-05-11 05:54:20 -0400 |
commit | d968fc51eab8b0fb259ecbeae517056b99554017 (patch) | |
tree | 10e551cff9fefbefbfd7e5031b57320116bb7fce /vendor/sabre/dav/tests/Sabre/DAVACL/PluginAdminTest.php | |
parent | c7698e4dc388b7d9a9db368672cb057c1d4d3a01 (diff) | |
parent | 4dd3839c41e18d9724855e7955d8737b6f52dcd6 (diff) | |
download | volse-hubzilla-d968fc51eab8b0fb259ecbeae517056b99554017.tar.gz volse-hubzilla-d968fc51eab8b0fb259ecbeae517056b99554017.tar.bz2 volse-hubzilla-d968fc51eab8b0fb259ecbeae517056b99554017.zip |
Merge remote-tracking branch 'upstream/dev' into plugin-repo
Diffstat (limited to 'vendor/sabre/dav/tests/Sabre/DAVACL/PluginAdminTest.php')
-rw-r--r-- | vendor/sabre/dav/tests/Sabre/DAVACL/PluginAdminTest.php | 49 |
1 files changed, 23 insertions, 26 deletions
diff --git a/vendor/sabre/dav/tests/Sabre/DAVACL/PluginAdminTest.php b/vendor/sabre/dav/tests/Sabre/DAVACL/PluginAdminTest.php index 23c4b6e85..fb7516a78 100644 --- a/vendor/sabre/dav/tests/Sabre/DAVACL/PluginAdminTest.php +++ b/vendor/sabre/dav/tests/Sabre/DAVACL/PluginAdminTest.php @@ -11,7 +11,9 @@ require_once 'Sabre/HTTP/ResponseMock.php'; class PluginAdminTest extends \PHPUnit_Framework_TestCase { - function testNoAdminAccess() { + public $server; + + function setUp() { $principalBackend = new PrincipalBackend\Mock(); @@ -20,13 +22,18 @@ class PluginAdminTest extends \PHPUnit_Framework_TestCase { new PrincipalCollection($principalBackend), ); - $fakeServer = new DAV\Server($tree); - $plugin = new DAV\Auth\Plugin(new DAV\Auth\Backend\Mock(),'realm'); - $fakeServer->addPlugin($plugin); + $this->server = new DAV\Server($tree); + $this->server->sapi = new HTTP\SapiMock(); + $plugin = new DAV\Auth\Plugin(new DAV\Auth\Backend\Mock()); + $this->server->addPlugin($plugin); + } + + function testNoAdminAccess() { + $plugin = new Plugin(); - $fakeServer->addPlugin($plugin); + $this->server->addPlugin($plugin); - $request = new HTTP\Request(array( + $request = HTTP\Sapi::createFromServerArray(array( 'REQUEST_METHOD' => 'OPTIONS', 'HTTP_DEPTH' => 1, 'REQUEST_URI' => '/adminonly', @@ -34,12 +41,12 @@ class PluginAdminTest extends \PHPUnit_Framework_TestCase { $response = new HTTP\ResponseMock(); - $fakeServer->httpRequest = $request; - $fakeServer->httpResponse = $response; + $this->server->httpRequest = $request; + $this->server->httpResponse = $response; - $fakeServer->exec(); + $this->server->exec(); - $this->assertEquals('HTTP/1.1 403 Forbidden', $response->status); + $this->assertEquals(403, $response->status); } @@ -48,23 +55,13 @@ class PluginAdminTest extends \PHPUnit_Framework_TestCase { */ function testAdminAccess() { - $principalBackend = new PrincipalBackend\Mock(); - - $tree = array( - new MockACLNode('adminonly', array()), - new PrincipalCollection($principalBackend), - ); - - $fakeServer = new DAV\Server($tree); - $plugin = new DAV\Auth\Plugin(new DAV\Auth\Backend\Mock(),'realm'); - $fakeServer->addPlugin($plugin); $plugin = new Plugin(); $plugin->adminPrincipals = array( 'principals/admin', ); - $fakeServer->addPlugin($plugin); + $this->server->addPlugin($plugin); - $request = new HTTP\Request(array( + $request = HTTP\Sapi::createFromServerArray(array( 'REQUEST_METHOD' => 'OPTIONS', 'HTTP_DEPTH' => 1, 'REQUEST_URI' => '/adminonly', @@ -72,12 +69,12 @@ class PluginAdminTest extends \PHPUnit_Framework_TestCase { $response = new HTTP\ResponseMock(); - $fakeServer->httpRequest = $request; - $fakeServer->httpResponse = $response; + $this->server->httpRequest = $request; + $this->server->httpResponse = $response; - $fakeServer->exec(); + $this->server->exec(); - $this->assertEquals('HTTP/1.1 200 OK', $response->status); + $this->assertEquals(200, $response->status); } } |