ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
All Data Structures Namespaces Files Functions Variables Modules Pages
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 
11 
13 {
14  public function setUp() : void
15  {
16  $request = \Mockery::mock(ServerRequestInterface::class);
17  $request->shouldReceive("getParsedBody")->andReturn(["foo" => "bar"]);
18  $this->post_data = new PostDataFromServerRequest($request);
19  }
20 
21 
22  public function test_get_success()
23  {
24  $this->assertEquals("bar", $this->post_data->get("foo"));
25  }
26 
27 
28  public function test_get_fail()
29  {
30  $raised = false;
31  try {
32  $this->post_data->get("baz");
33  } catch (\LogicException $e) {
34  $raised = true;
35  }
36  $this->assertTrue($raised, "Logic exception was raised.");
37  }
38 
39 
40  public function test_getOr_match()
41  {
42  $this->assertEquals("bar", $this->post_data->getOr("foo", "baz"));
43  }
44 
45 
46  public function test_getOr_no_match()
47  {
48  $this->assertEquals("blaw", $this->post_data->getOr("baz", "blaw"));
49  }
50 }
Implements interaction of input element with post data from psr-7 server request. ...