@@ -34,19 +34,11 @@ class HttpBindingFactoryTest extends TestCase
3434
3535 private HttpBindingFactory $ factory ;
3636
37- private Request |Mockery \Mock $ request ;
38-
39- private ParameterBag |Mockery \Mock $ bag ;
40-
4137 public function setUp (): void
4238 {
4339 $ redirectBinding = Mockery::mock (RedirectBinding::class);
4440 $ postBinding = Mockery::mock (PostBinding::class);
4541 $ this ->factory = new HttpBindingFactory ($ redirectBinding , $ postBinding );
46- $ this ->request = Mockery::mock (Request::class);
47- $ this ->bag = Mockery::mock (ParameterBag::class);
48- $ this ->request ->request = $ this ->bag ;
49- $ this ->request ->query = $ this ->bag ;
5042 }
5143
5244 /**
@@ -55,16 +47,15 @@ public function setUp(): void
5547 */
5648 public function a_redirect_binding_can_be_built (): void
5749 {
58- $ this ->request
59- ->shouldReceive ('getMethod ' )
60- ->andReturn (Request::METHOD_GET );
61-
62- $ this ->request ->query
63- ->shouldReceive ('has ' )
64- ->with ('SAMLRequest ' )
65- ->andReturn (true );
66-
67- $ binding = $ this ->factory ->build ($ this ->request );
50+ $ request = new Request (
51+ ['SAMLRequest ' => true ], // request parameters
52+ [], // query parameters
53+ [], // attributes
54+ [], // cookies
55+ [], // files
56+ ['REQUEST_METHOD ' => Request::METHOD_GET ] // server parameters
57+ );
58+ $ binding = $ this ->factory ->build ($ request );
6859
6960 $ this ->assertInstanceOf (RedirectBinding::class, $ binding );
7061 }
@@ -75,16 +66,15 @@ public function a_redirect_binding_can_be_built(): void
7566 */
7667 public function a_post_binding_can_be_built (): void
7768 {
78- $ this ->request
79- ->shouldReceive ('getMethod ' )
80- ->andReturn (Request::METHOD_POST );
81-
82- $ this ->bag
83- ->shouldReceive ('has ' )
84- ->with ('SAMLRequest ' )
85- ->andReturn (true );
86-
87- $ binding = $ this ->factory ->build ($ this ->request );
69+ $ request = new Request (
70+ [], // query parameters
71+ ['SAMLRequest ' => true ], // request parameters
72+ [], // attributes
73+ [], // cookies
74+ [], // files
75+ ['REQUEST_METHOD ' => Request::METHOD_POST ] // server parameters
76+ );
77+ $ binding = $ this ->factory ->build ($ request );
8878
8979 $ this ->assertInstanceOf (PostBinding::class, $ binding );
9080 }
@@ -97,11 +87,16 @@ public function a_put_binding_can_not_be_built(): void
9787 {
9888 $ this ->expectExceptionMessage ("Request type of \"PUT \" is not supported. " );
9989 $ this ->expectException (InvalidArgumentException::class);
100- $ this ->request
101- ->shouldReceive ('getMethod ' )
102- ->andReturn (Request::METHOD_PUT );
103-
104- $ this ->factory ->build ($ this ->request );
90+ $ request = new Request (
91+ [], // query parameters
92+ ['SAMLRequest ' => true ], // request parameters
93+ [], // attributes
94+ [], // cookies
95+ [], // files
96+ ['REQUEST_METHOD ' => Request::METHOD_PUT ] // server parameters
97+ );
98+
99+ $ this ->factory ->build ($ request );
105100 }
106101
107102 /**
@@ -112,16 +107,16 @@ public function an_invalid_post_authn_request_is_rejected(): void
112107 {
113108 $ this ->expectExceptionMessage ("POST-binding is supported for SAMLRequest. " );
114109 $ this ->expectException (InvalidArgumentException::class);
115- $ this -> request
116- -> shouldReceive ( ' getMethod ' )
117- -> andReturn (Request:: METHOD_POST );
118-
119- $ this -> bag
120- -> shouldReceive ( ' has ' )
121- -> with ( ' SAMLRequest ' )
122- -> andReturn ( false );
123-
124- $ this ->factory ->build ($ this -> request );
110+ $ request = new Request (
111+ [], // query parameters
112+ [], // request parameters
113+ [], // attributes
114+ [], // cookies
115+ [], // files
116+ [ ' REQUEST_METHOD ' => Request:: METHOD_POST ] // server parameters
117+ );
118+
119+ $ this ->factory ->build ($ request );
125120 }
126121
127122 /**
@@ -132,19 +127,15 @@ public function an_invalid_get_authn_request_is_rejected(): void
132127 {
133128 $ this ->expectExceptionMessage ("Redirect binding is supported for SAMLRequest and Response. " );
134129 $ this ->expectException (InvalidArgumentException::class);
135- $ this ->request
136- ->shouldReceive ('getMethod ' )
137- ->andReturn (Request::METHOD_GET );
138-
139- $ this ->bag
140- ->shouldReceive ('has ' )
141- ->with ('SAMLRequest ' )
142- ->andReturn (false );
143- $ this ->bag
144- ->shouldReceive ('has ' )
145- ->with ('SAMLResponse ' )
146- ->andReturn (false );
147-
148- $ this ->factory ->build ($ this ->request );
130+ $ request = new Request (
131+ [], // query parameters
132+ [], // request parameters
133+ [], // attributes
134+ [], // cookies
135+ [], // files
136+ ['REQUEST_METHOD ' => Request::METHOD_GET ] // server parameters
137+ );
138+
139+ $ this ->factory ->build ($ request );
149140 }
150141}
0 commit comments