ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
PostDataFromServerRequestTest.php
Go to the documentation of this file.
1 <?php
2 
3 /* Copyright (c) 2017 Richard Klees <richard.klees@concepts-and-training.de> Extended GPL, see docs/LICENSE */
4 
5 require_once(__DIR__ . "/../../../../../../libs/composer/vendor/autoload.php");
6 
7 use \ILIAS\UI\Implementation\Component\Input\Container\Form\PostDataFromServerRequest;
8 
10 
12 {
13  public function setUp()
14  {
15  $request = \Mockery::mock(ServerRequestInterface::class);
16  $request->shouldReceive("getParsedBody")->andReturn(["foo" => "bar"]);
17  $this->post_data = new PostDataFromServerRequest($request);
18  }
19 
20 
21  public function test_get_success()
22  {
23  $this->assertEquals("bar", $this->post_data->get("foo"));
24  }
25 
26 
27  public function test_get_fail()
28  {
29  $raised = false;
30  try {
31  $this->post_data->get("baz");
32  } catch (\LogicException $e) {
33  $raised = true;
34  }
35  $this->assertTrue($raised, "Logic exception was raised.");
36  }
37 
38 
39  public function test_getOr_match()
40  {
41  $this->assertEquals("bar", $this->post_data->getOr("foo", "baz"));
42  }
43 
44 
45  public function test_getOr_no_match()
46  {
47  $this->assertEquals("blaw", $this->post_data->getOr("baz", "blaw"));
48  }
49 }
foreach($paths as $path) $request
Definition: asyncclient.php:32
Implements interaction of input element with post data from psr-7 server request. ...