ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
Sabre\DAV\ServerEventsTest Class Reference
+ Inheritance diagram for Sabre\DAV\ServerEventsTest:
+ Collaboration diagram for Sabre\DAV\ServerEventsTest:

Public Member Functions

 testAfterBind ()
 
 afterBindHandler ($path)
 
 testAfterResponse ()
 
 testBeforeBindCancel ()
 
 beforeBindCancelHandler ($path)
 
 testException ()
 
 exceptionHandler (Exception $exception)
 
 testMethod ()
 
- Public Member Functions inherited from Sabre\DAV\AbstractServer
 setUp ()
 
 tearDown ()
 

Private Attributes

 $tempPath
 
 $exception
 

Additional Inherited Members

- Protected Member Functions inherited from Sabre\DAV\AbstractServer
 getRootNode ()
 
- Protected Attributes inherited from Sabre\DAV\AbstractServer
 $response
 
 $request
 
 $server
 
 $tempDir = SABRE_TEMPDIR
 

Detailed Description

Definition at line 9 of file ServerEventsTest.php.

Member Function Documentation

◆ afterBindHandler()

Sabre\DAV\ServerEventsTest::afterBindHandler (   $path)

Definition at line 26 of file ServerEventsTest.php.

References $path.

26  {
27 
28  $this->tempPath = $path;
29 
30  }
$path
Definition: aliased.php:25

◆ beforeBindCancelHandler()

Sabre\DAV\ServerEventsTest::beforeBindCancelHandler (   $path)

Definition at line 68 of file ServerEventsTest.php.

68  {
69 
70  return false;
71 
72  }

◆ exceptionHandler()

Sabre\DAV\ServerEventsTest::exceptionHandler ( Exception  $exception)

Definition at line 89 of file ServerEventsTest.php.

References Sabre\DAV\ServerEventsTest\$exception.

89  {
90 
91  $this->exception = $exception;
92 
93  }

◆ testAfterBind()

Sabre\DAV\ServerEventsTest::testAfterBind ( )

Definition at line 15 of file ServerEventsTest.php.

15  {
16 
17  $this->server->on('afterBind', [$this, 'afterBindHandler']);
18  $newPath = 'afterBind';
19 
20  $this->tempPath = '';
21  $this->server->createFile($newPath, 'body');
22  $this->assertEquals($newPath, $this->tempPath);
23 
24  }

◆ testAfterResponse()

Sabre\DAV\ServerEventsTest::testAfterResponse ( )

Definition at line 32 of file ServerEventsTest.php.

References Sabre\HTTP\Sapi\createFromServerArray(), and Sabre\Event\once().

32  {
33 
34  $mock = $this->getMockBuilder('stdClass')
35  ->setMethods(['afterResponseCallback'])
36  ->getMock();
37  $mock->expects($this->once())->method('afterResponseCallback');
38 
39  $this->server->on('afterResponse', [$mock, 'afterResponseCallback']);
40 
41  $this->server->httpRequest = HTTP\Sapi::createFromServerArray([
42  'REQUEST_METHOD' => 'GET',
43  'REQUEST_URI' => '/test.txt',
44  ]);
45 
46  $this->server->exec();
47 
48  }
once($eventName, callable $callBack, $priority=100)
Subscribe to an event exactly once.
static createFromServerArray(array $serverArray)
This static method will create a new Request object, based on a PHP $_SERVER array.
Definition: Sapi.php:107
+ Here is the call graph for this function:

◆ testBeforeBindCancel()

Sabre\DAV\ServerEventsTest::testBeforeBindCancel ( )

Definition at line 50 of file ServerEventsTest.php.

References $req, and Sabre\HTTP\Sapi\createFromServerArray().

50  {
51 
52  $this->server->on('beforeBind', [$this, 'beforeBindCancelHandler']);
53  $this->assertFalse($this->server->createFile('bla', 'body'));
54 
55  // Also testing put()
57  'REQUEST_METHOD' => 'PUT',
58  'REQUEST_URI' => '/barbar',
59  ]);
60 
61  $this->server->httpRequest = $req;
62  $this->server->exec();
63 
64  $this->assertEquals(500, $this->server->httpResponse->getStatus());
65 
66  }
$req
Definition: getUserInfo.php:20
static createFromServerArray(array $serverArray)
This static method will create a new Request object, based on a PHP $_SERVER array.
Definition: Sapi.php:107
+ Here is the call graph for this function:

◆ testException()

Sabre\DAV\ServerEventsTest::testException ( )

Definition at line 74 of file ServerEventsTest.php.

References $req, and Sabre\HTTP\Sapi\createFromServerArray().

74  {
75 
76  $this->server->on('exception', [$this, 'exceptionHandler']);
77 
79  'REQUEST_METHOD' => 'GET',
80  'REQUEST_URI' => '/not/exisitng',
81  ]);
82  $this->server->httpRequest = $req;
83  $this->server->exec();
84 
85  $this->assertInstanceOf('Sabre\\DAV\\Exception\\NotFound', $this->exception);
86 
87  }
$req
Definition: getUserInfo.php:20
static createFromServerArray(array $serverArray)
This static method will create a new Request object, based on a PHP $_SERVER array.
Definition: Sapi.php:107
+ Here is the call graph for this function:

◆ testMethod()

Sabre\DAV\ServerEventsTest::testMethod ( )

Definition at line 95 of file ServerEventsTest.php.

References Sabre\DAV\AbstractServer\$request, and Sabre\DAV\AbstractServer\$response.

95  {
96 
97  $k = 1;
98  $this->server->on('method', function($request, $response) use (&$k) {
99 
100  $k += 1;
101 
102  return false;
103 
104  });
105  $this->server->on('method', function($request, $response) use (&$k) {
106 
107  $k += 2;
108 
109  return false;
110 
111  });
112 
113  try {
114  $this->server->invokeMethod(
115  new HTTP\Request('BLABLA', '/'),
116  new HTTP\Response(),
117  false
118  );
119  } catch (Exception $e) {}
120 
121  // Fun fact, PHP 7.1 changes the order when sorting-by-callback.
122  $this->assertTrue($k >= 2 && $k <= 3);
123 
124  }

Field Documentation

◆ $exception

Sabre\DAV\ServerEventsTest::$exception
private

Definition at line 13 of file ServerEventsTest.php.

Referenced by Sabre\DAV\ServerEventsTest\exceptionHandler().

◆ $tempPath

Sabre\DAV\ServerEventsTest::$tempPath
private

Definition at line 11 of file ServerEventsTest.php.


The documentation for this class was generated from the following file: