ILIAS  trunk Revision v11.0_alpha-1851-ga8564da6fed
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator 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\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
MockObject $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 28 of file WrapperTest.php.

Member Function Documentation

◆ setUp()

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

Definition at line 39 of file WrapperTest.php.

References ILIAS\Repository\refinery().

39  : void
40  {
41  parent::setUp();
42  $language = $this->getMockBuilder('\ilLanguage')
43  ->disableOriginalConstructor()
44  ->getMock();
45 
46  $this->refinery = new Factory(new \ILIAS\Data\Factory(), $language);
47  }
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 126 of file WrapperTest.php.

References ILIAS\Repository\refinery().

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

◆ testPost()

ILIAS\HTTP\WrapperTest::testPost ( )

Definition at line 101 of file WrapperTest.php.

References ILIAS\Repository\refinery().

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

◆ testQuery()

ILIAS\HTTP\WrapperTest::testQuery ( )

Definition at line 76 of file WrapperTest.php.

References ILIAS\Repository\refinery().

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

◆ testWrapperfactory()

ILIAS\HTTP\WrapperTest::testWrapperfactory ( )

Definition at line 50 of file WrapperTest.php.

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

Field Documentation

◆ $cookie

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

Definition at line 33 of file WrapperTest.php.

◆ $get

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

Definition at line 31 of file WrapperTest.php.

◆ $post

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

Definition at line 32 of file WrapperTest.php.

◆ $refinery

Factory ILIAS\HTTP\WrapperTest::$refinery
protected

Definition at line 30 of file WrapperTest.php.


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