ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
ILIAS\HTTP\WrapperTest Class Reference

Class WrapperTest. More...

+ Inheritance diagram for ILIAS\HTTP\WrapperTest:
+ Collaboration diagram for ILIAS\HTTP\WrapperTest:

Public Member Functions

 testWrapperfactory ()
 
 testQuery ()
 
 testPost ()
 
 testCookie ()
 

Protected Member Functions

array array array setUp ()
 
- Protected Member Functions inherited from ILIAS\HTTP\AbstractBaseTest
 setUp ()
 

Protected Attributes

Factory $refinery
 
array $get = ['key_one' => 1
 
array array $post = ['key_one' => 1
 
array array array $cookie = ['key_one' => 1
 
- Protected Attributes inherited from ILIAS\HTTP\AbstractBaseTest
 $request_interface
 

Detailed Description

Class WrapperTest.

Author
Fabian Schmid fs@st.nosp@m.uder.nosp@m.-raim.nosp@m.ann..nosp@m.ch

Definition at line 27 of file WrapperTest.php.

Member Function Documentation

◆ setUp()

array array array ILIAS\HTTP\WrapperTest::setUp ( )
protected

Definition at line 37 of file WrapperTest.php.

References ILIAS\Repository\refinery().

37  : void
38  {
39  parent::setUp();
40  $language = $this->getMockBuilder('\ilLanguage')
41  ->disableOriginalConstructor()
42  ->getMock();
43 
44  $this->refinery = new Factory(new \ILIAS\Data\Factory(), $language);
45  }
Class ChatMainBarProvider .
+ Here is the call graph for this function:

◆ testCookie()

ILIAS\HTTP\WrapperTest::testCookie ( )

Definition at line 122 of file WrapperTest.php.

References ILIAS\Repository\refinery().

122  : void
123  {
124  $wrapper_factory = new WrapperFactory($this->request_interface);
125 
126  $this->request_interface->expects($this->once())
127  ->method('getCookieParams')
128  ->willReturn($this->cookie);
129 
130  $cookie = $wrapper_factory->cookie();
131 
132  $this->assertTrue($cookie->has('key_one'));
133  $this->assertTrue($cookie->has('key_two'));
134  $this->assertFalse($cookie->has('key_three'));
135 
136  $string_trafo = $this->refinery->kindlyTo()->string();
137  $int_trafo = $this->refinery->kindlyTo()->int();
138 
139  $this->assertEquals("1", $cookie->retrieve('key_one', $string_trafo));
140  $this->assertIsString($cookie->retrieve('key_one', $string_trafo));
141 
142  $this->assertEquals(1, $cookie->retrieve('key_one', $string_trafo));
143  $this->assertIsInt($cookie->retrieve('key_one', $int_trafo));
144  }
array array array $cookie
Definition: WrapperTest.php:32
+ Here is the call graph for this function:

◆ testPost()

ILIAS\HTTP\WrapperTest::testPost ( )

Definition at line 98 of file WrapperTest.php.

References ILIAS\Repository\refinery().

98  : void
99  {
100  $wrapper_factory = new WrapperFactory($this->request_interface);
101 
102  $this->request_interface->expects($this->once())
103  ->method('getParsedBody')
104  ->willReturn($this->post);
105 
106  $post = $wrapper_factory->post();
107 
108  $this->assertTrue($post->has('key_one'));
109  $this->assertTrue($post->has('key_two'));
110  $this->assertFalse($post->has('key_three'));
111 
112  $string_trafo = $this->refinery->kindlyTo()->string();
113  $int_trafo = $this->refinery->kindlyTo()->int();
114 
115  $this->assertEquals("1", $post->retrieve('key_one', $string_trafo));
116  $this->assertIsString($post->retrieve('key_one', $string_trafo));
117 
118  $this->assertEquals(1, $post->retrieve('key_one', $string_trafo));
119  $this->assertIsInt($post->retrieve('key_one', $int_trafo));
120  }
+ Here is the call graph for this function:

◆ testQuery()

ILIAS\HTTP\WrapperTest::testQuery ( )

Definition at line 74 of file WrapperTest.php.

References $query, and ILIAS\Repository\refinery().

74  : void
75  {
76  $wrapper_factory = new WrapperFactory($this->request_interface);
77 
78  $this->request_interface->expects($this->once())
79  ->method('getQueryParams')
80  ->willReturn($this->get);
81 
82  $query = $wrapper_factory->query();
83 
84  $this->assertTrue($query->has('key_one'));
85  $this->assertTrue($query->has('key_two'));
86  $this->assertFalse($query->has('key_three'));
87 
88  $string_trafo = $this->refinery->kindlyTo()->string();
89  $int_trafo = $this->refinery->kindlyTo()->int();
90 
91  $this->assertEquals("1", $query->retrieve('key_one', $string_trafo));
92  $this->assertIsString($query->retrieve('key_one', $string_trafo));
93 
94  $this->assertEquals(1, $query->retrieve('key_one', $string_trafo));
95  $this->assertIsInt($query->retrieve('key_one', $int_trafo));
96  }
$query
+ Here is the call graph for this function:

◆ testWrapperfactory()

ILIAS\HTTP\WrapperTest::testWrapperfactory ( )

Definition at line 48 of file WrapperTest.php.

48  : void
49  {
50  $wrapper_factory = new WrapperFactory($this->request_interface);
51 
52  // Query
53  $this->request_interface->expects($this->once())
54  ->method('getQueryParams')
55  ->willReturn([]);
56 
57  $wrapper_factory->query();
58 
59  // Post
60  $this->request_interface->expects($this->once())
61  ->method('getParsedBody')
62  ->willReturn([]);
63 
64  $wrapper_factory->post();
65 
66  // Cookie
67  $this->request_interface->expects($this->once())
68  ->method('getCookieParams')
69  ->willReturn([]);
70 
71  $wrapper_factory->cookie();
72  }

Field Documentation

◆ $cookie

array array array ILIAS\HTTP\WrapperTest::$cookie = ['key_one' => 1
protected

Definition at line 32 of file WrapperTest.php.

◆ $get

array ILIAS\HTTP\WrapperTest::$get = ['key_one' => 1
protected

Definition at line 30 of file WrapperTest.php.

◆ $post

array array ILIAS\HTTP\WrapperTest::$post = ['key_one' => 1
protected

Definition at line 31 of file WrapperTest.php.

◆ $refinery

Factory ILIAS\HTTP\WrapperTest::$refinery
protected

Definition at line 29 of file WrapperTest.php.


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