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