OAuthTestUnitCommonHttpUriUriTest

The Gravity Forms Salesforce Add-On OAuthTest Unit Common Http Uri UriTest class.

Defined (1)

The class is defined in the following location(s).

/lib/PHPoAuthLib/tests/Unit/Common/Http/Uri/UriTest.php  
  1. class UriTest extends \PHPUnit_Framework_TestCase 
  2. /** 
  3. * @covers OAuth\Common\Http\Uri\Uri::__construct 
  4. */ 
  5. public function testConstructCorrectInterfaceWithoutUri() 
  6. $uri = new Uri(); 
  7.  
  8. $this->assertInstanceOf('\\OAuth\\Common\\Http\\Uri\\UriInterface', $uri); 
  9.  
  10. /** 
  11. * @covers OAuth\Common\Http\Uri\Uri::__construct 
  12. * @covers OAuth\Common\Http\Uri\Uri::parseUri 
  13. */ 
  14. public function testConstructThrowsExceptionOnInvalidUri() 
  15. $this->setExpectedException('\\InvalidArgumentException'); 
  16.  
  17. // http://lxr.php.net/xref/PHP_5_4/ext/standard/tests/url/urls.inc#92 
  18. $uri = new Uri('http://@:/'); 
  19.  
  20. /** 
  21. * @covers OAuth\Common\Http\Uri\Uri::__construct 
  22. * @covers OAuth\Common\Http\Uri\Uri::parseUri 
  23. */ 
  24. public function testConstructThrowsExceptionOnUriWithoutScheme() 
  25. $this->setExpectedException('\\InvalidArgumentException'); 
  26.  
  27. $uri = new Uri('www.pieterhordijk.com'); 
  28.  
  29. /** 
  30. * @covers OAuth\Common\Http\Uri\Uri::__construct 
  31. * @covers OAuth\Common\Http\Uri\Uri::parseUri 
  32. * @covers OAuth\Common\Http\Uri\Uri::getScheme 
  33. */ 
  34. public function testGetScheme() 
  35. $uri = new Uri('http://example.com'); 
  36.  
  37. $this->assertSame('http', $uri->getScheme()); 
  38.  
  39. /** 
  40. * @covers OAuth\Common\Http\Uri\Uri::__construct 
  41. * @covers OAuth\Common\Http\Uri\Uri::parseUri 
  42. * @covers OAuth\Common\Http\Uri\Uri::setUserInfo 
  43. * @covers OAuth\Common\Http\Uri\Uri::protectUserInfo 
  44. * @covers OAuth\Common\Http\Uri\Uri::getUserInfo 
  45. */ 
  46. public function testGetUserInfo() 
  47. $uri = new Uri('http://peehaa@example.com'); 
  48.  
  49. $this->assertSame('peehaa', $uri->getUserInfo()); 
  50.  
  51. /** 
  52. * @covers OAuth\Common\Http\Uri\Uri::__construct 
  53. * @covers OAuth\Common\Http\Uri\Uri::parseUri 
  54. * @covers OAuth\Common\Http\Uri\Uri::setUserInfo 
  55. * @covers OAuth\Common\Http\Uri\Uri::protectUserInfo 
  56. * @covers OAuth\Common\Http\Uri\Uri::getUserInfo 
  57. */ 
  58. public function testGetUserInfoWithPass() 
  59. $uri = new Uri('http://peehaa:pass@example.com'); 
  60.  
  61. $this->assertSame('peehaa:********', $uri->getUserInfo()); 
  62.  
  63. /** 
  64. * @covers OAuth\Common\Http\Uri\Uri::__construct 
  65. * @covers OAuth\Common\Http\Uri\Uri::parseUri 
  66. * @covers OAuth\Common\Http\Uri\Uri::setUserInfo 
  67. * @covers OAuth\Common\Http\Uri\Uri::protectUserInfo 
  68. * @covers OAuth\Common\Http\Uri\Uri::getRawUserInfo 
  69. */ 
  70. public function testGetRawUserInfo() 
  71. $uri = new Uri('http://peehaa@example.com'); 
  72.  
  73. $this->assertSame('peehaa', $uri->getRawUserInfo()); 
  74.  
  75. /** 
  76. * @covers OAuth\Common\Http\Uri\Uri::__construct 
  77. * @covers OAuth\Common\Http\Uri\Uri::parseUri 
  78. * @covers OAuth\Common\Http\Uri\Uri::setUserInfo 
  79. * @covers OAuth\Common\Http\Uri\Uri::protectUserInfo 
  80. * @covers OAuth\Common\Http\Uri\Uri::getRawUserInfo 
  81. */ 
  82. public function testGetRawUserInfoWithPass() 
  83. $uri = new Uri('http://peehaa:pass@example.com'); 
  84.  
  85. $this->assertSame('peehaa:pass', $uri->getRawUserInfo()); 
  86.  
  87. /** 
  88. * @covers OAuth\Common\Http\Uri\Uri::__construct 
  89. * @covers OAuth\Common\Http\Uri\Uri::parseUri 
  90. * @covers OAuth\Common\Http\Uri\Uri::getHost 
  91. */ 
  92. public function testGetHost() 
  93. $uri = new Uri('http://example.com'); 
  94.  
  95. $this->assertSame('example.com', $uri->getHost()); 
  96.  
  97. /** 
  98. * @covers OAuth\Common\Http\Uri\Uri::__construct 
  99. * @covers OAuth\Common\Http\Uri\Uri::parseUri 
  100. * @covers OAuth\Common\Http\Uri\Uri::getPort 
  101. */ 
  102. public function testGetPortImplicitHttp() 
  103. $uri = new Uri('http://example.com'); 
  104.  
  105. $this->assertSame(80, $uri->getPort()); 
  106.  
  107. /** 
  108. * @covers OAuth\Common\Http\Uri\Uri::__construct 
  109. * @covers OAuth\Common\Http\Uri\Uri::parseUri 
  110. * @covers OAuth\Common\Http\Uri\Uri::getPort 
  111. */ 
  112. public function testGetPortImplicitHttps() 
  113. $uri = new Uri('https://example.com'); 
  114.  
  115. $this->assertSame(443, $uri->getPort()); 
  116.  
  117. /** 
  118. * @covers OAuth\Common\Http\Uri\Uri::__construct 
  119. * @covers OAuth\Common\Http\Uri\Uri::parseUri 
  120. * @covers OAuth\Common\Http\Uri\Uri::getPort 
  121. */ 
  122. public function testGetPortExplicit() 
  123. $uri = new Uri('http://example.com:21'); 
  124.  
  125. $this->assertSame(21, $uri->getPort()); 
  126.  
  127. /** 
  128. * @covers OAuth\Common\Http\Uri\Uri::__construct 
  129. * @covers OAuth\Common\Http\Uri\Uri::parseUri 
  130. * @covers OAuth\Common\Http\Uri\Uri::getPath 
  131. */ 
  132. public function testGetPathNotSupplied() 
  133. $uri = new Uri('http://example.com'); 
  134.  
  135. $this->assertSame('/', $uri->getPath()); 
  136.  
  137. /** 
  138. * @covers OAuth\Common\Http\Uri\Uri::__construct 
  139. * @covers OAuth\Common\Http\Uri\Uri::parseUri 
  140. * @covers OAuth\Common\Http\Uri\Uri::getPath 
  141. */ 
  142. public function testGetPathSlash() 
  143. $uri = new Uri('http://example.com/'); 
  144.  
  145. $this->assertSame('/', $uri->getPath()); 
  146.  
  147. /** 
  148. * @covers OAuth\Common\Http\Uri\Uri::__construct 
  149. * @covers OAuth\Common\Http\Uri\Uri::parseUri 
  150. * @covers OAuth\Common\Http\Uri\Uri::getPath 
  151. */ 
  152. public function testGetPath() 
  153. $uri = new Uri('http://example.com/foo'); 
  154.  
  155. $this->assertSame('/foo', $uri->getPath()); 
  156.  
  157. /** 
  158. * @covers OAuth\Common\Http\Uri\Uri::__construct 
  159. * @covers OAuth\Common\Http\Uri\Uri::parseUri 
  160. * @covers OAuth\Common\Http\Uri\Uri::getQuery 
  161. */ 
  162. public function testGetQueryWithParams() 
  163. $uri = new Uri('http://example.com?param1=first¶m2=second'); 
  164.  
  165. $this->assertSame('param1=first¶m2=second', $uri->getQuery()); 
  166.  
  167. /** 
  168. * @covers OAuth\Common\Http\Uri\Uri::__construct 
  169. * @covers OAuth\Common\Http\Uri\Uri::parseUri 
  170. * @covers OAuth\Common\Http\Uri\Uri::getQuery 
  171. */ 
  172. public function testGetQueryWithoutParams() 
  173. $uri = new Uri('http://example.com'); 
  174.  
  175. $this->assertSame('', $uri->getQuery()); 
  176.  
  177. /** 
  178. * @covers OAuth\Common\Http\Uri\Uri::__construct 
  179. * @covers OAuth\Common\Http\Uri\Uri::parseUri 
  180. * @covers OAuth\Common\Http\Uri\Uri::getFragment 
  181. */ 
  182. public function testGetFragmentExists() 
  183. $uri = new Uri('http://example.com#foo'); 
  184.  
  185. $this->assertSame('foo', $uri->getFragment()); 
  186.  
  187. /** 
  188. * @covers OAuth\Common\Http\Uri\Uri::__construct 
  189. * @covers OAuth\Common\Http\Uri\Uri::parseUri 
  190. * @covers OAuth\Common\Http\Uri\Uri::getFragment 
  191. */ 
  192. public function testGetFragmentNotExists() 
  193. $uri = new Uri('http://example.com'); 
  194.  
  195. $this->assertSame('', $uri->getFragment()); 
  196.  
  197. /** 
  198. * @covers OAuth\Common\Http\Uri\Uri::__construct 
  199. * @covers OAuth\Common\Http\Uri\Uri::parseUri 
  200. * @covers OAuth\Common\Http\Uri\Uri::getAuthority 
  201. */ 
  202. public function testGetAuthorityWithoutUserInfo() 
  203. $uri = new Uri('http://example.com'); 
  204.  
  205. $this->assertSame('example.com', $uri->getAuthority()); 
  206.  
  207. /** 
  208. * @covers OAuth\Common\Http\Uri\Uri::__construct 
  209. * @covers OAuth\Common\Http\Uri\Uri::parseUri 
  210. * @covers OAuth\Common\Http\Uri\Uri::getAuthority 
  211. */ 
  212. public function testGetAuthorityWithoutUserInfoWithExplicitPort() 
  213. $uri = new Uri('http://example.com:21'); 
  214.  
  215. $this->assertSame('example.com:21', $uri->getAuthority()); 
  216.  
  217. /** 
  218. * @covers OAuth\Common\Http\Uri\Uri::__construct 
  219. * @covers OAuth\Common\Http\Uri\Uri::parseUri 
  220. * @covers OAuth\Common\Http\Uri\Uri::setUserInfo 
  221. * @covers OAuth\Common\Http\Uri\Uri::protectUserInfo 
  222. * @covers OAuth\Common\Http\Uri\Uri::getAuthority 
  223. */ 
  224. public function testGetAuthorityWithUsernameWithExplicitPort() 
  225. $uri = new Uri('http://peehaa@example.com:21'); 
  226.  
  227. $this->assertSame('peehaa@example.com:21', $uri->getAuthority()); 
  228.  
  229. /** 
  230. * @covers OAuth\Common\Http\Uri\Uri::__construct 
  231. * @covers OAuth\Common\Http\Uri\Uri::parseUri 
  232. * @covers OAuth\Common\Http\Uri\Uri::setUserInfo 
  233. * @covers OAuth\Common\Http\Uri\Uri::protectUserInfo 
  234. * @covers OAuth\Common\Http\Uri\Uri::getAuthority 
  235. */ 
  236. public function testGetAuthorityWithUsernameAndPassWithExplicitPort() 
  237. $uri = new Uri('http://peehaa:pass@example.com:21'); 
  238.  
  239. $this->assertSame('peehaa:********@example.com:21', $uri->getAuthority()); 
  240.  
  241. /** 
  242. * @covers OAuth\Common\Http\Uri\Uri::__construct 
  243. * @covers OAuth\Common\Http\Uri\Uri::parseUri 
  244. * @covers OAuth\Common\Http\Uri\Uri::setUserInfo 
  245. * @covers OAuth\Common\Http\Uri\Uri::protectUserInfo 
  246. * @covers OAuth\Common\Http\Uri\Uri::getAuthority 
  247. */ 
  248. public function testGetAuthorityWithUsernameAndPassWithoutExplicitPort() 
  249. $uri = new Uri('http://peehaa:pass@example.com'); 
  250.  
  251. $this->assertSame('peehaa:********@example.com', $uri->getAuthority()); 
  252.  
  253. /** 
  254. * @covers OAuth\Common\Http\Uri\Uri::__construct 
  255. * @covers OAuth\Common\Http\Uri\Uri::parseUri 
  256. * @covers OAuth\Common\Http\Uri\Uri::getRawAuthority 
  257. */ 
  258. public function testGetRawAuthorityWithoutUserInfo() 
  259. $uri = new Uri('http://example.com'); 
  260.  
  261. $this->assertSame('example.com', $uri->getRawAuthority()); 
  262.  
  263. /** 
  264. * @covers OAuth\Common\Http\Uri\Uri::__construct 
  265. * @covers OAuth\Common\Http\Uri\Uri::parseUri 
  266. * @covers OAuth\Common\Http\Uri\Uri::getRawAuthority 
  267. */ 
  268. public function testGetRawAuthorityWithoutUserInfoWithExplicitPort() 
  269. $uri = new Uri('http://example.com:21'); 
  270.  
  271. $this->assertSame('example.com:21', $uri->getRawAuthority()); 
  272.  
  273. /** 
  274. * @covers OAuth\Common\Http\Uri\Uri::__construct 
  275. * @covers OAuth\Common\Http\Uri\Uri::parseUri 
  276. * @covers OAuth\Common\Http\Uri\Uri::setUserInfo 
  277. * @covers OAuth\Common\Http\Uri\Uri::protectUserInfo 
  278. * @covers OAuth\Common\Http\Uri\Uri::getRawAuthority 
  279. */ 
  280. public function testGetRawAuthorityWithUsernameWithExplicitPort() 
  281. $uri = new Uri('http://peehaa@example.com:21'); 
  282.  
  283. $this->assertSame('peehaa@example.com:21', $uri->getRawAuthority()); 
  284.  
  285. /** 
  286. * @covers OAuth\Common\Http\Uri\Uri::__construct 
  287. * @covers OAuth\Common\Http\Uri\Uri::parseUri 
  288. * @covers OAuth\Common\Http\Uri\Uri::setUserInfo 
  289. * @covers OAuth\Common\Http\Uri\Uri::protectUserInfo 
  290. * @covers OAuth\Common\Http\Uri\Uri::getRawAuthority 
  291. */ 
  292. public function testGetRawAuthorityWithUsernameAndPassWithExplicitPort() 
  293. $uri = new Uri('http://peehaa:pass@example.com:21'); 
  294.  
  295. $this->assertSame('peehaa:pass@example.com:21', $uri->getRawAuthority()); 
  296.  
  297. /** 
  298. * @covers OAuth\Common\Http\Uri\Uri::__construct 
  299. * @covers OAuth\Common\Http\Uri\Uri::parseUri 
  300. * @covers OAuth\Common\Http\Uri\Uri::setUserInfo 
  301. * @covers OAuth\Common\Http\Uri\Uri::protectUserInfo 
  302. * @covers OAuth\Common\Http\Uri\Uri::getRawAuthority 
  303. */ 
  304. public function testGetRawAuthorityWithUsernameAndPassWithoutExplicitPort() 
  305. $uri = new Uri('http://peehaa:pass@example.com'); 
  306.  
  307. $this->assertSame('peehaa:pass@example.com', $uri->getRawAuthority()); 
  308.  
  309. /** 
  310. * @covers OAuth\Common\Http\Uri\Uri::__construct 
  311. * @covers OAuth\Common\Http\Uri\Uri::parseUri 
  312. * @covers OAuth\Common\Http\Uri\Uri::getAbsoluteUri 
  313. */ 
  314. public function testGetAbsoluteUriBare() 
  315. $uri = new Uri('http://example.com'); 
  316.  
  317. $this->assertSame('http://example.com', $uri->getAbsoluteUri()); 
  318.  
  319. /** 
  320. * @covers OAuth\Common\Http\Uri\Uri::__construct 
  321. * @covers OAuth\Common\Http\Uri\Uri::parseUri 
  322. * @covers OAuth\Common\Http\Uri\Uri::setUserInfo 
  323. * @covers OAuth\Common\Http\Uri\Uri::protectUserInfo 
  324. * @covers OAuth\Common\Http\Uri\Uri::getRawAuthority 
  325. * @covers OAuth\Common\Http\Uri\Uri::getAbsoluteUri 
  326. */ 
  327. public function testGetAbsoluteUriWithAuthority() 
  328. $uri = new Uri('http://peehaa:pass@example.com'); 
  329.  
  330. $this->assertSame('http://peehaa:pass@example.com', $uri->getAbsoluteUri()); 
  331.  
  332. /** 
  333. * @covers OAuth\Common\Http\Uri\Uri::__construct 
  334. * @covers OAuth\Common\Http\Uri\Uri::parseUri 
  335. * @covers OAuth\Common\Http\Uri\Uri::getAbsoluteUri 
  336. */ 
  337. public function testGetAbsoluteUriWithPath() 
  338. $uri = new Uri('http://example.com/foo'); 
  339.  
  340. $this->assertSame('http://example.com/foo', $uri->getAbsoluteUri()); 
  341.  
  342. /** 
  343. * @covers OAuth\Common\Http\Uri\Uri::__construct 
  344. * @covers OAuth\Common\Http\Uri\Uri::parseUri 
  345. * @covers OAuth\Common\Http\Uri\Uri::getAbsoluteUri 
  346. */ 
  347. public function testGetAbsoluteUriWithoutPath() 
  348. $uri = new Uri('http://example.com'); 
  349.  
  350. $this->assertSame('http://example.com', $uri->getAbsoluteUri()); 
  351.  
  352. /** 
  353. * @covers OAuth\Common\Http\Uri\Uri::__construct 
  354. * @covers OAuth\Common\Http\Uri\Uri::parseUri 
  355. * @covers OAuth\Common\Http\Uri\Uri::getAbsoluteUri 
  356. */ 
  357. public function testGetAbsoluteUriWithoutPathExplicitTrailingSlash() 
  358. $uri = new Uri('http://example.com/'); 
  359.  
  360. $this->assertSame('http://example.com/', $uri->getAbsoluteUri()); 
  361.  
  362. /** 
  363. * @covers OAuth\Common\Http\Uri\Uri::__construct 
  364. * @covers OAuth\Common\Http\Uri\Uri::parseUri 
  365. * @covers OAuth\Common\Http\Uri\Uri::getAbsoluteUri 
  366. */ 
  367. public function testGetAbsoluteUriWithQuery() 
  368. $uri = new Uri('http://example.com?param1=value1'); 
  369.  
  370. $this->assertSame('http://example.com?param1=value1', $uri->getAbsoluteUri()); 
  371.  
  372. /** 
  373. * @covers OAuth\Common\Http\Uri\Uri::__construct 
  374. * @covers OAuth\Common\Http\Uri\Uri::parseUri 
  375. * @covers OAuth\Common\Http\Uri\Uri::getAbsoluteUri 
  376. */ 
  377. public function testGetAbsoluteUriWithFragment() 
  378. $uri = new Uri('http://example.com#foo'); 
  379.  
  380. $this->assertSame('http://example.com#foo', $uri->getAbsoluteUri()); 
  381.  
  382. /** 
  383. * @covers OAuth\Common\Http\Uri\Uri::__construct 
  384. * @covers OAuth\Common\Http\Uri\Uri::parseUri 
  385. * @covers OAuth\Common\Http\Uri\Uri::getRelativeUri 
  386. */ 
  387. public function testGetRelativeUriWithoutPath() 
  388. $uri = new Uri('http://example.com'); 
  389.  
  390. $this->assertSame('', $uri->getRelativeUri()); 
  391.  
  392. /** 
  393. * @covers OAuth\Common\Http\Uri\Uri::__construct 
  394. * @covers OAuth\Common\Http\Uri\Uri::parseUri 
  395. * @covers OAuth\Common\Http\Uri\Uri::getRelativeUri 
  396. */ 
  397. public function testGetRelativeUriWithPath() 
  398. $uri = new Uri('http://example.com/foo'); 
  399.  
  400. $this->assertSame('/foo', $uri->getRelativeUri()); 
  401.  
  402. /** 
  403. * @covers OAuth\Common\Http\Uri\Uri::__construct 
  404. * @covers OAuth\Common\Http\Uri\Uri::parseUri 
  405. * @covers OAuth\Common\Http\Uri\Uri::getRelativeUri 
  406. */ 
  407. public function testGetRelativeUriWithExplicitTrailingSlash() 
  408. $uri = new Uri('http://example.com/'); 
  409.  
  410. $this->assertSame('/', $uri->getRelativeUri()); 
  411.  
  412. /** 
  413. * @covers OAuth\Common\Http\Uri\Uri::__construct 
  414. * @covers OAuth\Common\Http\Uri\Uri::parseUri 
  415. * @covers OAuth\Common\Http\Uri\Uri::__toString 
  416. */ 
  417. public function testToStringBare() 
  418. $uri = new Uri('http://example.com'); 
  419.  
  420. $this->assertSame('http://example.com', (string) $uri); 
  421.  
  422. /** 
  423. * @covers OAuth\Common\Http\Uri\Uri::__construct 
  424. * @covers OAuth\Common\Http\Uri\Uri::parseUri 
  425. * @covers OAuth\Common\Http\Uri\Uri::setUserInfo 
  426. * @covers OAuth\Common\Http\Uri\Uri::protectUserInfo 
  427. * @covers OAuth\Common\Http\Uri\Uri::getRawAuthority 
  428. * @covers OAuth\Common\Http\Uri\Uri::__toString 
  429. */ 
  430. public function testToStringWithAuthority() 
  431. $uri = new Uri('http://peehaa:pass@example.com'); 
  432.  
  433. $this->assertSame('http://peehaa:********@example.com', (string) $uri); 
  434.  
  435. /** 
  436. * @covers OAuth\Common\Http\Uri\Uri::__construct 
  437. * @covers OAuth\Common\Http\Uri\Uri::parseUri 
  438. * @covers OAuth\Common\Http\Uri\Uri::__toString 
  439. */ 
  440. public function testToStringWithPath() 
  441. $uri = new Uri('http://example.com/foo'); 
  442.  
  443. $this->assertSame('http://example.com/foo', (string) $uri); 
  444.  
  445. /** 
  446. * @covers OAuth\Common\Http\Uri\Uri::__construct 
  447. * @covers OAuth\Common\Http\Uri\Uri::parseUri 
  448. * @covers OAuth\Common\Http\Uri\Uri::__toString 
  449. */ 
  450. public function testToStringWithoutPath() 
  451. $uri = new Uri('http://example.com'); 
  452.  
  453. $this->assertSame('http://example.com', (string) $uri); 
  454.  
  455. /** 
  456. * @covers OAuth\Common\Http\Uri\Uri::__construct 
  457. * @covers OAuth\Common\Http\Uri\Uri::parseUri 
  458. * @covers OAuth\Common\Http\Uri\Uri::__toString 
  459. */ 
  460. public function testToStringWithoutPathExplicitTrailingSlash() 
  461. $uri = new Uri('http://example.com/'); 
  462.  
  463. $this->assertSame('http://example.com/', (string) $uri); 
  464.  
  465. /** 
  466. * @covers OAuth\Common\Http\Uri\Uri::__construct 
  467. * @covers OAuth\Common\Http\Uri\Uri::parseUri 
  468. * @covers OAuth\Common\Http\Uri\Uri::__toString 
  469. */ 
  470. public function testToStringWithQuery() 
  471. $uri = new Uri('http://example.com?param1=value1'); 
  472.  
  473. $this->assertSame('http://example.com?param1=value1', (string) $uri); 
  474.  
  475. /** 
  476. * @covers OAuth\Common\Http\Uri\Uri::__construct 
  477. * @covers OAuth\Common\Http\Uri\Uri::parseUri 
  478. * @covers OAuth\Common\Http\Uri\Uri::__toString 
  479. */ 
  480. public function testToStringWithFragment() 
  481. $uri = new Uri('http://example.com#foo'); 
  482.  
  483. $this->assertSame('http://example.com#foo', (string) $uri); 
  484.  
  485. /** 
  486. * @covers OAuth\Common\Http\Uri\Uri::__construct 
  487. * @covers OAuth\Common\Http\Uri\Uri::parseUri 
  488. * @covers OAuth\Common\Http\Uri\Uri::setPath 
  489. * @covers OAuth\Common\Http\Uri\Uri::getAbsoluteUri 
  490. */ 
  491. public function testSetPathEmpty() 
  492. $uri = new Uri('http://example.com'); 
  493. $uri->setPath(''); 
  494.  
  495. $this->assertSame('http://example.com', $uri->getAbsoluteUri()); 
  496.  
  497. /** 
  498. * @covers OAuth\Common\Http\Uri\Uri::__construct 
  499. * @covers OAuth\Common\Http\Uri\Uri::parseUri 
  500. * @covers OAuth\Common\Http\Uri\Uri::setPath 
  501. * @covers OAuth\Common\Http\Uri\Uri::getAbsoluteUri 
  502. */ 
  503. public function testSetPathWithPath() 
  504. $uri = new Uri('http://example.com'); 
  505. $uri->setPath('/foo'); 
  506.  
  507. $this->assertSame('http://example.com/foo', $uri->getAbsoluteUri()); 
  508.  
  509. /** 
  510. * @covers OAuth\Common\Http\Uri\Uri::__construct 
  511. * @covers OAuth\Common\Http\Uri\Uri::parseUri 
  512. * @covers OAuth\Common\Http\Uri\Uri::setPath 
  513. * @covers OAuth\Common\Http\Uri\Uri::getAbsoluteUri 
  514. */ 
  515. public function testSetPathWithOnlySlash() 
  516. $uri = new Uri('http://example.com'); 
  517. $uri->setPath('/'); 
  518.  
  519. $this->assertSame('http://example.com/', $uri->getAbsoluteUri()); 
  520.  
  521. /** 
  522. * @covers OAuth\Common\Http\Uri\Uri::__construct 
  523. * @covers OAuth\Common\Http\Uri\Uri::parseUri 
  524. * @covers OAuth\Common\Http\Uri\Uri::setQuery 
  525. * @covers OAuth\Common\Http\Uri\Uri::getAbsoluteUri 
  526. */ 
  527. public function testSetQueryEmpty() 
  528. $uri = new Uri('http://example.com'); 
  529. $uri->setQuery(''); 
  530.  
  531. $this->assertSame('http://example.com', $uri->getAbsoluteUri()); 
  532.  
  533. /** 
  534. * @covers OAuth\Common\Http\Uri\Uri::__construct 
  535. * @covers OAuth\Common\Http\Uri\Uri::parseUri 
  536. * @covers OAuth\Common\Http\Uri\Uri::setQuery 
  537. * @covers OAuth\Common\Http\Uri\Uri::getAbsoluteUri 
  538. */ 
  539. public function testSetQueryFilled() 
  540. $uri = new Uri('http://example.com'); 
  541. $uri->setQuery('param1=value1¶m2=value2'); 
  542.  
  543. $this->assertSame('http://example.com?param1=value1¶m2=value2', $uri->getAbsoluteUri()); 
  544.  
  545. /** 
  546. * @covers OAuth\Common\Http\Uri\Uri::__construct 
  547. * @covers OAuth\Common\Http\Uri\Uri::parseUri 
  548. * @covers OAuth\Common\Http\Uri\Uri::addToQuery 
  549. * @covers OAuth\Common\Http\Uri\Uri::getAbsoluteUri 
  550. */ 
  551. public function testAddToQueryAppend() 
  552. $uri = new Uri('http://example.com?param1=value1'); 
  553. $uri->addToQuery('param2', 'value2'); 
  554.  
  555. $this->assertSame('http://example.com?param1=value1¶m2=value2', $uri->getAbsoluteUri()); 
  556.  
  557. /** 
  558. * @covers OAuth\Common\Http\Uri\Uri::__construct 
  559. * @covers OAuth\Common\Http\Uri\Uri::parseUri 
  560. * @covers OAuth\Common\Http\Uri\Uri::addToQuery 
  561. * @covers OAuth\Common\Http\Uri\Uri::getAbsoluteUri 
  562. */ 
  563. public function testAddToQueryCreate() 
  564. $uri = new Uri('http://example.com'); 
  565. $uri->addToQuery('param1', 'value1'); 
  566.  
  567. $this->assertSame('http://example.com?param1=value1', $uri->getAbsoluteUri()); 
  568.  
  569. /** 
  570. * @covers OAuth\Common\Http\Uri\Uri::__construct 
  571. * @covers OAuth\Common\Http\Uri\Uri::parseUri 
  572. * @covers OAuth\Common\Http\Uri\Uri::setFragment 
  573. * @covers OAuth\Common\Http\Uri\Uri::getAbsoluteUri 
  574. */ 
  575. public function testSetFragmentEmpty() 
  576. $uri = new Uri('http://example.com'); 
  577. $uri->setFragment(''); 
  578.  
  579. $this->assertSame('http://example.com', $uri->getAbsoluteUri()); 
  580.  
  581. /** 
  582. * @covers OAuth\Common\Http\Uri\Uri::__construct 
  583. * @covers OAuth\Common\Http\Uri\Uri::parseUri 
  584. * @covers OAuth\Common\Http\Uri\Uri::setFragment 
  585. * @covers OAuth\Common\Http\Uri\Uri::getAbsoluteUri 
  586. */ 
  587. public function testSetFragmentWithData() 
  588. $uri = new Uri('http://example.com'); 
  589. $uri->setFragment('foo'); 
  590.  
  591. $this->assertSame('http://example.com#foo', $uri->getAbsoluteUri()); 
  592.  
  593. /** 
  594. * @covers OAuth\Common\Http\Uri\Uri::__construct 
  595. * @covers OAuth\Common\Http\Uri\Uri::parseUri 
  596. * @covers OAuth\Common\Http\Uri\Uri::setScheme 
  597. * @covers OAuth\Common\Http\Uri\Uri::getAbsoluteUri 
  598. */ 
  599. public function testSetSchemeWithEmpty() 
  600. $uri = new Uri('http://example.com'); 
  601. $uri->setScheme(''); 
  602.  
  603. $this->assertSame('://example.com', $uri->getAbsoluteUri()); 
  604.  
  605. /** 
  606. * @covers OAuth\Common\Http\Uri\Uri::__construct 
  607. * @covers OAuth\Common\Http\Uri\Uri::parseUri 
  608. * @covers OAuth\Common\Http\Uri\Uri::setScheme 
  609. * @covers OAuth\Common\Http\Uri\Uri::getAbsoluteUri 
  610. */ 
  611. public function testSetSchemeWithData() 
  612. $uri = new Uri('http://example.com'); 
  613. $uri->setScheme('foo'); 
  614.  
  615. $this->assertSame('foo://example.com', $uri->getAbsoluteUri()); 
  616.  
  617. /** 
  618. * @covers OAuth\Common\Http\Uri\Uri::__construct 
  619. * @covers OAuth\Common\Http\Uri\Uri::parseUri 
  620. * @covers OAuth\Common\Http\Uri\Uri::setUserInfo 
  621. * @covers OAuth\Common\Http\Uri\Uri::getAbsoluteUri 
  622. */ 
  623. public function testSetUserInfoEmpty() 
  624. $uri = new Uri('http://example.com'); 
  625. $uri->setUserInfo(''); 
  626.  
  627. $this->assertSame('http://example.com', $uri->getAbsoluteUri()); 
  628.  
  629. /** 
  630. * @covers OAuth\Common\Http\Uri\Uri::__construct 
  631. * @covers OAuth\Common\Http\Uri\Uri::parseUri 
  632. * @covers OAuth\Common\Http\Uri\Uri::setUserInfo 
  633. * @covers OAuth\Common\Http\Uri\Uri::protectUserInfo 
  634. * @covers OAuth\Common\Http\Uri\Uri::getAbsoluteUri 
  635. */ 
  636. public function testSetUserInfoWithData() 
  637. $uri = new Uri('http://example.com'); 
  638. $uri->setUserInfo('foo:bar'); 
  639.  
  640. $this->assertSame('http://foo:bar@example.com', $uri->getAbsoluteUri()); 
  641.  
  642. /** 
  643. * @covers OAuth\Common\Http\Uri\Uri::__construct 
  644. * @covers OAuth\Common\Http\Uri\Uri::parseUri 
  645. * @covers OAuth\Common\Http\Uri\Uri::setPort 
  646. * @covers OAuth\Common\Http\Uri\Uri::getAbsoluteUri 
  647. */ 
  648. public function testSetPortCustom() 
  649. $uri = new Uri('http://example.com'); 
  650. $uri->setPort('21'); 
  651.  
  652. $this->assertSame('http://example.com:21', $uri->getAbsoluteUri()); 
  653.  
  654. /** 
  655. * @covers OAuth\Common\Http\Uri\Uri::__construct 
  656. * @covers OAuth\Common\Http\Uri\Uri::parseUri 
  657. * @covers OAuth\Common\Http\Uri\Uri::setPort 
  658. * @covers OAuth\Common\Http\Uri\Uri::getAbsoluteUri 
  659. */ 
  660. public function testSetPortHttpImplicit() 
  661. $uri = new Uri('http://example.com'); 
  662. $uri->setPort(80); 
  663.  
  664. $this->assertSame('http://example.com', $uri->getAbsoluteUri()); 
  665.  
  666. /** 
  667. * @covers OAuth\Common\Http\Uri\Uri::__construct 
  668. * @covers OAuth\Common\Http\Uri\Uri::parseUri 
  669. * @covers OAuth\Common\Http\Uri\Uri::setPort 
  670. * @covers OAuth\Common\Http\Uri\Uri::getAbsoluteUri 
  671. */ 
  672. public function testSetPortHttpsImplicit() 
  673. $uri = new Uri('https://example.com'); 
  674. $uri->setPort(443); 
  675.  
  676. $this->assertSame('https://example.com', $uri->getAbsoluteUri()); 
  677.  
  678. /** 
  679. * @covers OAuth\Common\Http\Uri\Uri::__construct 
  680. * @covers OAuth\Common\Http\Uri\Uri::parseUri 
  681. * @covers OAuth\Common\Http\Uri\Uri::setPort 
  682. * @covers OAuth\Common\Http\Uri\Uri::getAbsoluteUri 
  683. */ 
  684. public function testSetPortHttpExplicit() 
  685. $uri = new Uri('http://example.com'); 
  686. $uri->setPort(443); 
  687.  
  688. $this->assertSame('http://example.com:443', $uri->getAbsoluteUri()); 
  689.  
  690. /** 
  691. * @covers OAuth\Common\Http\Uri\Uri::__construct 
  692. * @covers OAuth\Common\Http\Uri\Uri::parseUri 
  693. * @covers OAuth\Common\Http\Uri\Uri::setPort 
  694. * @covers OAuth\Common\Http\Uri\Uri::getAbsoluteUri 
  695. */ 
  696. public function testSetPortHttpsExplicit() 
  697. $uri = new Uri('https://example.com'); 
  698. $uri->setPort(80); 
  699.  
  700. $this->assertSame('https://example.com:80', $uri->getAbsoluteUri()); 
  701.  
  702. /** 
  703. * @covers OAuth\Common\Http\Uri\Uri::__construct 
  704. * @covers OAuth\Common\Http\Uri\Uri::parseUri 
  705. * @covers OAuth\Common\Http\Uri\Uri::setHost 
  706. * @covers OAuth\Common\Http\Uri\Uri::getAbsoluteUri 
  707. */ 
  708. public function testSetHost() 
  709. $uri = new Uri('http://example.com'); 
  710. $uri->setHost('pieterhordijk.com'); 
  711.  
  712. $this->assertSame('http://pieterhordijk.com', $uri->getAbsoluteUri()); 
  713.  
  714. /** 
  715. * @covers OAuth\Common\Http\Uri\Uri::__construct 
  716. * @covers OAuth\Common\Http\Uri\Uri::parseUri 
  717. * @covers OAuth\Common\Http\Uri\Uri::hasExplicitTrailingHostSlash 
  718. */ 
  719. public function testHasExplicitTrailingHostSlashTrue() 
  720. $uri = new Uri('http://example.com/'); 
  721.  
  722. $this->assertTrue($uri->hasExplicitTrailingHostSlash()); 
  723.  
  724. /** 
  725. * @covers OAuth\Common\Http\Uri\Uri::__construct 
  726. * @covers OAuth\Common\Http\Uri\Uri::parseUri 
  727. * @covers OAuth\Common\Http\Uri\Uri::hasExplicitTrailingHostSlash 
  728. */ 
  729. public function testHasExplicitTrailingHostSlashFalse() 
  730. $uri = new Uri('http://example.com/foo'); 
  731.  
  732. $this->assertFalse($uri->hasExplicitTrailingHostSlash()); 
  733.  
  734. /** 
  735. * @covers OAuth\Common\Http\Uri\Uri::__construct 
  736. * @covers OAuth\Common\Http\Uri\Uri::parseUri 
  737. * @covers OAuth\Common\Http\Uri\Uri::hasExplicitPortSpecified 
  738. */ 
  739. public function testHasExplicitPortSpecifiedTrue() 
  740. $uri = new Uri('http://example.com:8080'); 
  741.  
  742. $this->assertTrue($uri->hasExplicitPortSpecified()); 
  743.  
  744. /** 
  745. * @covers OAuth\Common\Http\Uri\Uri::__construct 
  746. * @covers OAuth\Common\Http\Uri\Uri::parseUri 
  747. * @covers OAuth\Common\Http\Uri\Uri::hasExplicitPortSpecified 
  748. */ 
  749. public function testHasExplicitPortSpecifiedFalse() 
  750. $uri = new Uri('http://example.com'); 
  751.  
  752. $this->assertFalse($uri->hasExplicitPortSpecified());