ILIAS  release_10 Revision v10.1-43-ga1241a92c2f
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\AbstractBaseTestCase
 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\AbstractBaseTestCase
 $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 25 of file WrapperTest.php.

Member Function Documentation

◆ setUp()

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

Definition at line 35 of file WrapperTest.php.

References ILIAS\Repository\refinery().

35  : void
36  {
37  parent::setUp();
38  $language = $this->getMockBuilder('\ilLanguage')
39  ->disableOriginalConstructor()
40  ->getMock();
41 
42  $this->refinery = new Factory(new \ILIAS\Data\Factory(), $language);
43  }
Interface Observer Contains several chained tasks and infos about them.
+ 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  $this->assertEquals(['key_one', 'key_two'], $cookie->keys());
136 
137  $string_trafo = $this->refinery->kindlyTo()->string();
138  $int_trafo = $this->refinery->kindlyTo()->int();
139 
140  $this->assertEquals("1", $cookie->retrieve('key_one', $string_trafo));
141  $this->assertIsString($cookie->retrieve('key_one', $string_trafo));
142 
143  $this->assertEquals(1, $cookie->retrieve('key_one', $string_trafo));
144  $this->assertIsInt($cookie->retrieve('key_one', $int_trafo));
145  }
array array array $cookie
Definition: WrapperTest.php:30
+ Here is the call graph for this function:

◆ testPost()

ILIAS\HTTP\WrapperTest::testPost ( )

Definition at line 97 of file WrapperTest.php.

References ILIAS\Repository\refinery().

97  : void
98  {
99  $wrapper_factory = new WrapperFactory($this->request_interface);
100 
101  $this->request_interface->expects($this->once())
102  ->method('getParsedBody')
103  ->willReturn($this->post);
104 
105  $post = $wrapper_factory->post();
106 
107  $this->assertTrue($post->has('key_one'));
108  $this->assertTrue($post->has('key_two'));
109  $this->assertFalse($post->has('key_three'));
110  $this->assertEquals(['key_one', 'key_two'], $post->keys());
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 72 of file WrapperTest.php.

References ILIAS\Repository\refinery().

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

◆ testWrapperfactory()

ILIAS\HTTP\WrapperTest::testWrapperfactory ( )

Definition at line 46 of file WrapperTest.php.

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

Field Documentation

◆ $cookie

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

Definition at line 30 of file WrapperTest.php.

◆ $get

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

Definition at line 28 of file WrapperTest.php.

◆ $post

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

Definition at line 29 of file WrapperTest.php.

◆ $refinery

Factory ILIAS\HTTP\WrapperTest::$refinery
protected

Definition at line 27 of file WrapperTest.php.


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