1<?php
2
3namespace Sabre\DAV\Auth\Backend;
4
5use
6    Sabre\DAV\Server,
7    Sabre\HTTP\Sapi,
8    Sabre\HTTP\Response;
9
10class BasicCallBackTest extends \PHPUnit_Framework_TestCase {
11
12    function testCallBack() {
13
14        $args = [];
15        $callBack = function($user, $pass) use (&$args) {
16
17            $args = [$user, $pass];
18            return true;
19
20        };
21
22        $backend = new BasicCallBack($callBack);
23
24        $request = Sapi::createFromServerArray([
25            'HTTP_AUTHORIZATION' => 'Basic ' . base64_encode('foo:bar'),
26        ]);
27        $response = new Response();
28
29        $this->assertEquals(
30            [true, 'principals/foo'],
31            $backend->check($request, $response)
32        );
33
34        $this->assertEquals(['foo','bar'], $args);
35
36    }
37
38}
39