ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
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

 setUp ()
 @inheritDoc More...
 
 setUp ()
 @inheritDoc More...
 

Protected Attributes

Factory $refinery
 
array $get = ['key_one' => 1, 'key_two' => 2]
 
array $post = ['key_one' => 1, 'key_two' => 2]
 
array $cookie = ['key_one' => 1, 'key_two' => 2]
 
- 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()

ILIAS\HTTP\WrapperTest::setUp ( )
protected

@inheritDoc

Reimplemented from ILIAS\HTTP\AbstractBaseTestCase.

Definition at line 39 of file WrapperTest.php.

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 \BackgroundTasks Contains several chained tasks and infos about them.

References ILIAS\Repository\refinery().

+ Here is the call graph for this function:

◆ testCookie()

ILIAS\HTTP\WrapperTest::testCookie ( )

Definition at line 126 of file WrapperTest.php.

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->assertSame(['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 }

References ILIAS\HTTP\WrapperTest\$cookie, and ILIAS\Repository\refinery().

+ Here is the call graph for this function:

◆ testPost()

ILIAS\HTTP\WrapperTest::testPost ( )

Definition at line 101 of file WrapperTest.php.

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->assertSame(['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 }

References ILIAS\HTTP\WrapperTest\$post, and ILIAS\Repository\refinery().

+ Here is the call graph for this function:

◆ testQuery()

ILIAS\HTTP\WrapperTest::testQuery ( )

Definition at line 76 of file WrapperTest.php.

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->assertSame(['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 }

References ILIAS\Repository\refinery().

+ 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 ILIAS\HTTP\WrapperTest::$cookie = ['key_one' => 1, 'key_two' => 2]
protected

Definition at line 33 of file WrapperTest.php.

Referenced by ILIAS\HTTP\WrapperTest\testCookie().

◆ $get

array ILIAS\HTTP\WrapperTest::$get = ['key_one' => 1, 'key_two' => 2]
protected

Definition at line 31 of file WrapperTest.php.

◆ $post

array ILIAS\HTTP\WrapperTest::$post = ['key_one' => 1, 'key_two' => 2]
protected

Definition at line 32 of file WrapperTest.php.

Referenced by ILIAS\HTTP\WrapperTest\testPost().

◆ $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: