| 
									
										
										
										
											2012-11-22 16:24:21 +00:00
										 |  |  | <?php | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | use Mockery as m; | 
					
						
							| 
									
										
										
										
											2013-02-11 14:02:14 +00:00
										 |  |  | use JacobKiers\OAuth\Request\Request; | 
					
						
							| 
									
										
										
										
											2012-11-22 16:24:21 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | class RequestTest extends PHPUnit_Framework_TestCase | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     public function tearDown() | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         m::close(); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-11-19 21:12:51 +01:00
										 |  |  |     /** | 
					
						
							|  |  |  |      * @expectedException \JacobKiers\OAuth\OAuthException | 
					
						
							|  |  |  |      */ | 
					
						
							|  |  |  |     public function testRequestThrowsExceptionWhenNoOAuthConsumerKeyIsPresent() | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         $request = new Request('POST', 'http://example.com', array()); | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2012-11-22 16:24:21 +00:00
										 |  |  |     public function testHttpMethodCanBeNormalized() | 
					
						
							|  |  |  |     { | 
					
						
							| 
									
										
										
										
											2013-11-19 21:12:51 +01:00
										 |  |  |         $request = new Request('foo', 'bar', array('oauth_consumer_key' => 'bar')); | 
					
						
							| 
									
										
										
										
											2012-11-22 16:24:21 +00:00
										 |  |  |         $this->assertEquals('FOO', $request->getNormalizedHttpMethod()); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     public function testHttpUrlCanBeNormalized() | 
					
						
							|  |  |  |     { | 
					
						
							| 
									
										
										
										
											2013-11-19 21:12:51 +01:00
										 |  |  |         $request = new Request('foo', 'bar', array('oauth_consumer_key' => 'bar')); | 
					
						
							| 
									
										
										
										
											2012-11-22 16:24:21 +00:00
										 |  |  |         $this->assertEquals('http://bar', $request->getNormalizedHttpUrl()); | 
					
						
							| 
									
										
										
										
											2013-11-19 21:12:51 +01:00
										 |  |  |         $request = new Request('foo', 'example.com:80', array('oauth_consumer_key' => 'bar')); | 
					
						
							| 
									
										
										
										
											2012-11-22 16:24:21 +00:00
										 |  |  |         $this->assertEquals('http://example.com', $request->getNormalizedHttpUrl()); | 
					
						
							| 
									
										
										
										
											2013-11-19 21:12:51 +01:00
										 |  |  |         $request = new Request('foo', 'example.com:81', array('oauth_consumer_key' => 'bar')); | 
					
						
							| 
									
										
										
										
											2012-11-22 16:24:21 +00:00
										 |  |  |         $this->assertEquals('http://example.com:81', $request->getNormalizedHttpUrl()); | 
					
						
							| 
									
										
										
										
											2013-11-19 21:12:51 +01:00
										 |  |  |         $request = new Request('foo', 'https://example.com', array('oauth_consumer_key' => 'bar')); | 
					
						
							| 
									
										
										
										
											2012-11-22 16:24:21 +00:00
										 |  |  |         $this->assertEquals('https://example.com', $request->getNormalizedHttpUrl()); | 
					
						
							| 
									
										
										
										
											2013-11-19 21:12:51 +01:00
										 |  |  |         $request = new Request('foo', 'https://example.com:443', array('oauth_consumer_key' => 'bar')); | 
					
						
							| 
									
										
										
										
											2012-11-22 16:24:21 +00:00
										 |  |  |         $this->assertEquals('https://example.com', $request->getNormalizedHttpUrl()); | 
					
						
							| 
									
										
										
										
											2013-11-19 21:12:51 +01:00
										 |  |  |         $request = new Request('foo', 'http://example.com/foobar', array('oauth_consumer_key' => 'bar')); | 
					
						
							| 
									
										
										
										
											2012-11-22 16:24:21 +00:00
										 |  |  |         $this->assertEquals('http://example.com/foobar', $request->getNormalizedHttpUrl()); | 
					
						
							| 
									
										
										
										
											2013-11-19 21:12:51 +01:00
										 |  |  |         $request = new Request('foo', 'example.org:80/foobar', array('oauth_consumer_key' => 'bar')); | 
					
						
							| 
									
										
										
										
											2012-11-22 16:24:21 +00:00
										 |  |  |         $this->assertEquals('http://example.org/foobar', $request->getNormalizedHttpUrl()); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | } |