PageRenderTime 45ms CodeModel.GetById 15ms RepoModel.GetById 1ms app.codeStats 0ms

/tests/ParameterTest.php

http://github.com/llaville/php-compat-info
PHP | 1161 lines | 565 code | 156 blank | 440 comment | 15 complexity | c17c35221351a282c36bc2641510a68d MD5 | raw file
Possible License(s): BSD-3-Clause
  1. <?php
  2. /**
  3. * Unit tests for PHP_CompatInfo package, functions parameters
  4. *
  5. * PHP version 5
  6. *
  7. * @category PHP
  8. * @package PHP_CompatInfo
  9. * @subpackage Tests
  10. * @author Laurent Laville <pear@laurent-laville.org>
  11. * @license http://www.opensource.org/licenses/bsd-license.php BSD License
  12. * @version SVN: $Id$
  13. * @link http://php5.laurent-laville.org/compatinfo/
  14. * @since Class available since Release 2.2.0
  15. */
  16. if (!defined('TEST_FILES_PATH')) {
  17. define(
  18. 'TEST_FILES_PATH',
  19. dirname(__FILE__) . DIRECTORY_SEPARATOR .
  20. '_files' . DIRECTORY_SEPARATOR
  21. );
  22. }
  23. /**
  24. * Tests for the PHP_CompatInfo class, about functions parameters versions
  25. *
  26. * @category PHP
  27. * @package PHP_CompatInfo
  28. * @subpackage Tests
  29. * @author Laurent Laville <pear@laurent-laville.org>
  30. * @license http://www.opensource.org/licenses/bsd-license.php BSD License
  31. * @version Release: @package_version@
  32. * @link http://php5.laurent-laville.org/compatinfo/
  33. */
  34. class PHP_CompatInfo_ParameterTest extends PHPUnit_Framework_TestCase
  35. {
  36. protected $pci;
  37. /**
  38. * Sets up the fixture.
  39. *
  40. * Parse source code to detect different signature versions
  41. *
  42. * @return void
  43. */
  44. protected function setUp()
  45. {
  46. $options = array(
  47. 'cacheDriver' => 'null',
  48. );
  49. $this->pci = new PHP_CompatInfo($options);
  50. }
  51. /**
  52. * signature example with get_browser()
  53. *
  54. * @link http://www.php.net/manual/en/function.get-browser.php
  55. * @return void
  56. */
  57. public function testGetBrowserDefaultSignature()
  58. {
  59. $this->pci->parse(TEST_FILES_PATH . 'source18881-01d.php');
  60. $this->assertSame(
  61. array('4.0.0', ''), $this->pci->getVersions()
  62. );
  63. }
  64. /**
  65. * alternative signature example with get_browser()
  66. *
  67. * @link http://www.php.net/manual/en/function.get-browser.php
  68. * @return void
  69. */
  70. public function testGetBrowserOptionalSignature()
  71. {
  72. $this->pci->parse(TEST_FILES_PATH . 'source18881-01o.php');
  73. $this->assertSame(
  74. array('4.3.2', ''), $this->pci->getVersions()
  75. );
  76. }
  77. /**
  78. * signature example with sha1()
  79. *
  80. * @link http://www.php.net/manual/en/function.sha1.php
  81. * @return void
  82. */
  83. public function testSha1DefaultSignature()
  84. {
  85. $this->pci->parse(TEST_FILES_PATH . 'source18881-02d.php');
  86. $this->assertSame(
  87. array('4.3.0', ''), $this->pci->getVersions()
  88. );
  89. }
  90. /**
  91. * alternative signature example with sha1()
  92. *
  93. * @link http://www.php.net/manual/en/function.sha1.php
  94. * @return void
  95. */
  96. public function testSha1OptionalSignature()
  97. {
  98. $this->pci->parse(TEST_FILES_PATH . 'source18881-02o.php');
  99. $this->assertSame(
  100. array('5.0.0', ''), $this->pci->getVersions()
  101. );
  102. }
  103. /**
  104. * signature example with sha1_file()
  105. *
  106. * @link http://www.php.net/manual/en/function.sha1_file.php
  107. * @return void
  108. */
  109. public function testSha1FileDefaultSignature()
  110. {
  111. $this->pci->parse(TEST_FILES_PATH . 'source18881-03d.php');
  112. $this->assertSame(
  113. array('4.3.0', ''), $this->pci->getVersions()
  114. );
  115. }
  116. /**
  117. * alternative signature example with sha1_file()
  118. *
  119. * @link http://www.php.net/manual/en/function.sha1_file.php
  120. * @return void
  121. */
  122. public function testSha1FileOptionalSignature()
  123. {
  124. $this->pci->parse(TEST_FILES_PATH . 'source18881-03o.php');
  125. $this->assertSame(
  126. array('5.0.0', ''), $this->pci->getVersions()
  127. );
  128. }
  129. /**
  130. * signature example with md5()
  131. *
  132. * @link http://www.php.net/manual/en/function.md5.php
  133. * @return void
  134. */
  135. public function testMd5DefaultSignature()
  136. {
  137. $this->pci->parse(TEST_FILES_PATH . 'source18881-04d.php');
  138. $this->assertSame(
  139. array('4.0.0', ''), $this->pci->getVersions()
  140. );
  141. }
  142. /**
  143. * alternative signature example with md5()
  144. *
  145. * @link http://www.php.net/manual/en/function.md5.php
  146. * @return void
  147. */
  148. public function testMd5OptionalSignature()
  149. {
  150. $this->pci->parse(TEST_FILES_PATH . 'source18881-04o.php');
  151. $this->assertSame(
  152. array('5.0.0', ''), $this->pci->getVersions()
  153. );
  154. }
  155. /**
  156. * example with md5_file()
  157. *
  158. * @link http://www.php.net/manual/en/function.md5-file.php
  159. * @return void
  160. */
  161. public function testMd5FileDefaultSignature()
  162. {
  163. $this->pci->parse(TEST_FILES_PATH . 'source18881-05d.php');
  164. $this->assertSame(
  165. array('4.2.0', ''), $this->pci->getVersions()
  166. );
  167. }
  168. /**
  169. * alternative example with md5_file()
  170. *
  171. * @link http://www.php.net/manual/en/function.md5-file.php
  172. * @return void
  173. */
  174. public function testMd5FileOptionalSignature()
  175. {
  176. $this->pci->parse(TEST_FILES_PATH . 'source18881-05o.php');
  177. $this->assertSame(
  178. array('5.0.0', ''), $this->pci->getVersions()
  179. );
  180. }
  181. /**
  182. * example with mkdir()
  183. *
  184. * @link http://www.php.net/manual/en/function.mkdir.php
  185. * @return void
  186. */
  187. public function testMkdirDefaultSignature()
  188. {
  189. $this->pci->parse(TEST_FILES_PATH . 'source18881-06d.php');
  190. $this->assertSame(
  191. array('4.0.0', ''), $this->pci->getVersions()
  192. );
  193. }
  194. /**
  195. * alternative example with mkdir()
  196. *
  197. * @link http://www.php.net/manual/en/function.mkdir.php
  198. * @return void
  199. */
  200. public function testMkdirOptionalSignature()
  201. {
  202. $this->pci->parse(TEST_FILES_PATH . 'source18881-06o.php');
  203. $this->assertSame(
  204. array('5.0.0', ''), $this->pci->getVersions()
  205. );
  206. }
  207. /**
  208. * example with file()
  209. *
  210. * @link http://www.php.net/manual/en/function.file.php
  211. * @return void
  212. */
  213. public function testFileDefaultSignature()
  214. {
  215. $this->pci->parse(TEST_FILES_PATH . 'source18881-07d.php');
  216. $this->assertSame(
  217. array('4.0.0', ''), $this->pci->getVersions()
  218. );
  219. }
  220. /**
  221. * alternative example with file()
  222. *
  223. * @link http://www.php.net/manual/en/function.file.php
  224. * @return void
  225. */
  226. public function testFileOptionalSignature()
  227. {
  228. $this->pci->parse(TEST_FILES_PATH . 'source18881-07o.php');
  229. $this->assertSame(
  230. array('5.0.0', ''), $this->pci->getVersions()
  231. );
  232. }
  233. /**
  234. * example with str_replace()
  235. *
  236. * @link http://www.php.net/manual/en/function.str-replace.php
  237. * @return void
  238. */
  239. public function testStrReplaceDefaultSignature()
  240. {
  241. $this->pci->parse(TEST_FILES_PATH . 'source18881-08d.php');
  242. $this->assertSame(
  243. array('4.0.0', ''), $this->pci->getVersions()
  244. );
  245. }
  246. /**
  247. * alternative example with str_replace()
  248. *
  249. * @link http://www.php.net/manual/en/function.str-replace.php
  250. * @return void
  251. */
  252. public function testStrReplaceOptionalSignature()
  253. {
  254. $this->pci->parse(TEST_FILES_PATH . 'source18881-08o.php');
  255. $this->assertSame(
  256. array('5.0.0', ''), $this->pci->getVersions()
  257. );
  258. }
  259. /**
  260. * example with fgetss()
  261. *
  262. * @link http://www.php.net/manual/en/function.fgetss.php
  263. * @return void
  264. */
  265. public function testFgetssDefaultSignature()
  266. {
  267. $this->pci->parse(TEST_FILES_PATH . 'source18881-09d.php');
  268. $this->assertSame(
  269. array('4.0.0', ''), $this->pci->getVersions()
  270. );
  271. }
  272. /**
  273. * alternative example with fgetss()
  274. *
  275. * @link http://www.php.net/manual/en/function.fgetss.php
  276. * @return void
  277. */
  278. public function testFgetssOptionalSignature()
  279. {
  280. $this->pci->parse(TEST_FILES_PATH . 'source18881-09o.php');
  281. $this->assertSame(
  282. array('5.0.0', ''), $this->pci->getVersions()
  283. );
  284. }
  285. /**
  286. * example with microtime()
  287. *
  288. * @link http://www.php.net/manual/en/function.microtime.php
  289. * @return void
  290. */
  291. public function testMicrotimeDefaultSignature()
  292. {
  293. $this->pci->parse(TEST_FILES_PATH . 'source18881-10d.php');
  294. $this->assertSame(
  295. array('4.0.0', ''), $this->pci->getVersions()
  296. );
  297. }
  298. /**
  299. * alternative example with microtime()
  300. *
  301. * @link http://www.php.net/manual/en/function.microtime.php
  302. * @return void
  303. */
  304. public function testMicrotimeOptionalSignature()
  305. {
  306. $this->pci->parse(TEST_FILES_PATH . 'source18881-10o.php');
  307. $this->assertSame(
  308. array('5.0.0', ''), $this->pci->getVersions()
  309. );
  310. }
  311. /**
  312. * example with array_keys()
  313. *
  314. * @link http://www.php.net/manual/en/function.array-keys.php
  315. * @return void
  316. */
  317. public function testArrayKeysDefaultSignature()
  318. {
  319. $this->pci->parse(TEST_FILES_PATH . 'source18881-11d.php');
  320. $this->assertSame(
  321. array('4.0.0', ''), $this->pci->getVersions()
  322. );
  323. }
  324. /**
  325. * alternative example with array_keys()
  326. *
  327. * @link http://www.php.net/manual/en/function.array-keys.php
  328. * @return void
  329. */
  330. public function testArrayKeysOptionalSignature()
  331. {
  332. $this->pci->parse(TEST_FILES_PATH . 'source18881-11o.php');
  333. $this->assertSame(
  334. array('5.0.0', ''), $this->pci->getVersions()
  335. );
  336. }
  337. /**
  338. * example with array_slice()
  339. *
  340. * @link http://www.php.net/manual/en/function.array-slice.php
  341. * @return void
  342. */
  343. public function testArraySliceDefaultSignature()
  344. {
  345. $this->pci->parse(TEST_FILES_PATH . 'source18881-12d.php');
  346. $this->assertSame(
  347. array('4.0.0', ''), $this->pci->getVersions()
  348. );
  349. }
  350. /**
  351. * alternative example with array_slice()
  352. *
  353. * @link http://www.php.net/manual/en/function.array-slice.php
  354. * @return void
  355. */
  356. public function testArraySliceOptionalSignature()
  357. {
  358. $this->pci->parse(TEST_FILES_PATH . 'source18881-12o.php');
  359. $this->assertSame(
  360. array('5.0.2', ''), $this->pci->getVersions()
  361. );
  362. }
  363. /**
  364. * example with file_get_contents()
  365. *
  366. * @link http://www.php.net/manual/en/function.file-get-contents.php
  367. * @return void
  368. */
  369. public function testFileGetContentsDefaultSignature()
  370. {
  371. $this->pci->parse(TEST_FILES_PATH . 'source18881-13d.php');
  372. $this->assertSame(
  373. array('4.3.0', ''), $this->pci->getVersions()
  374. );
  375. }
  376. /**
  377. * alternative example with file_get_contents()
  378. *
  379. * @link http://www.php.net/manual/en/function.file-get-contents.php
  380. * @return void
  381. */
  382. public function testFileGetContentsOptionalSignature()
  383. {
  384. $this->pci->parse(TEST_FILES_PATH . 'source18881-13o.php');
  385. $this->assertSame(
  386. array('5.1.0', ''), $this->pci->getVersions()
  387. );
  388. }
  389. /**
  390. * example with stream_get_contents()
  391. *
  392. * @link http://www.php.net/manual/en/function.stream-get-contents.php
  393. * @return void
  394. */
  395. public function testStreamGetContentsDefaultSignature()
  396. {
  397. $this->pci->parse(TEST_FILES_PATH . 'source18881-14d.php');
  398. $this->assertSame(
  399. array('5.0.0', ''), $this->pci->getVersions()
  400. );
  401. }
  402. /**
  403. * alternative example with stream_get_contents()
  404. *
  405. * @link http://www.php.net/manual/en/function.stream-get-contents.php
  406. * @return void
  407. */
  408. public function testStreamGetContentsOptionalSignature()
  409. {
  410. $this->pci->parse(TEST_FILES_PATH . 'source18881-14o.php');
  411. $this->assertSame(
  412. array('5.1.0', ''), $this->pci->getVersions()
  413. );
  414. }
  415. /**
  416. * example with gettimeofday()
  417. *
  418. * @link http://www.php.net/manual/en/function.gettimeofday.php
  419. * @return void
  420. */
  421. public function testGettimeofdayDefaultSignature()
  422. {
  423. $this->pci->parse(TEST_FILES_PATH . 'source18881-15d.php');
  424. $this->assertSame(
  425. array('4.0.0', ''), $this->pci->getVersions()
  426. );
  427. }
  428. /**
  429. * alternative example with gettimeofday()
  430. *
  431. * @link http://www.php.net/manual/en/function.gettimeofday.php
  432. * @return void
  433. */
  434. public function testGettimeofdayOptionalSignature()
  435. {
  436. $this->pci->parse(TEST_FILES_PATH . 'source18881-15o.php');
  437. $this->assertSame(
  438. array('5.1.0', ''), $this->pci->getVersions()
  439. );
  440. }
  441. /**
  442. * example with substr_count()
  443. *
  444. * @link http://www.php.net/manual/en/function.substr-count.php
  445. * @return void
  446. */
  447. public function testSubstrCountDefaultSignature()
  448. {
  449. $this->pci->parse(TEST_FILES_PATH . 'source18881-16d.php');
  450. $this->assertSame(
  451. array('4.0.0', ''), $this->pci->getVersions()
  452. );
  453. }
  454. /**
  455. * alternative example with substr_count()
  456. *
  457. * @link http://www.php.net/manual/en/function.substr-count.php
  458. * @return void
  459. */
  460. public function testSubstrCountOptionalSignature()
  461. {
  462. $this->pci->parse(TEST_FILES_PATH . 'source18881-16o.php');
  463. $this->assertSame(
  464. array('5.1.0', ''), $this->pci->getVersions()
  465. );
  466. }
  467. /**
  468. * example with is_a()
  469. *
  470. * @link http://www.php.net/manual/en/function.is-a.php
  471. * @return void
  472. */
  473. public function testIsADefaultSignature()
  474. {
  475. $this->pci->parse(TEST_FILES_PATH . 'source18881-17d.php');
  476. $this->assertSame(
  477. array('4.2.0', ''), $this->pci->getVersions()
  478. );
  479. }
  480. /**
  481. * alternative example with is_a()
  482. *
  483. * @link http://www.php.net/manual/en/function.is-a.php
  484. * @return void
  485. */
  486. public function testIsAOptionalSignature()
  487. {
  488. $this->pci->parse(TEST_FILES_PATH . 'source18881-17o.php');
  489. $this->assertSame(
  490. array('5.3.9', ''), $this->pci->getVersions()
  491. );
  492. }
  493. /**
  494. * example with jdtojewish()
  495. *
  496. * @link http://www.php.net/manual/en/function.jdtojewish.php
  497. * @return void
  498. */
  499. public function testJdtojewishDefaultSignature()
  500. {
  501. if (!extension_loaded('calendar')) {
  502. $this->markTestSkipped(
  503. "The 'calendar' extension is not available."
  504. );
  505. }
  506. $this->pci->parse(TEST_FILES_PATH . 'source18881-18d.php');
  507. $this->assertSame(
  508. array('4.0.0', ''), $this->pci->getVersions()
  509. );
  510. }
  511. /**
  512. * alternative example with jdtojewish()
  513. *
  514. * @link http://www.php.net/manual/en/function.jdtojewish.php
  515. * @return void
  516. */
  517. public function testJdtojewishOptionalSignature()
  518. {
  519. if (!extension_loaded('calendar')) {
  520. $this->markTestSkipped(
  521. "The 'calendar' extension is not available."
  522. );
  523. }
  524. $this->pci->parse(TEST_FILES_PATH . 'source18881-18o.php');
  525. $this->assertSame(
  526. array('4.3.0', ''), $this->pci->getVersions()
  527. );
  528. }
  529. /**
  530. * example with stream_copy_to_stream()
  531. *
  532. * @link http://www.php.net/manual/en/function.stream-copy-to-stream.php
  533. * @return void
  534. */
  535. public function testStreamCopyToStreamDefaultSignature()
  536. {
  537. $this->pci->parse(TEST_FILES_PATH . 'source18881-19d.php');
  538. $this->assertSame(
  539. array('5.0.0', ''), $this->pci->getVersions()
  540. );
  541. }
  542. /**
  543. * alternative example with stream_copy_to_stream()
  544. *
  545. * @link http://www.php.net/manual/en/function.stream-copy-to-stream.php
  546. * @return void
  547. */
  548. public function testStreamCopyToStreamOptionalSignature()
  549. {
  550. $this->pci->parse(TEST_FILES_PATH . 'source18881-19o.php');
  551. $this->assertSame(
  552. array('5.1.0', ''), $this->pci->getVersions()
  553. );
  554. }
  555. /**
  556. * example with copy()
  557. *
  558. * @link http://www.php.net/manual/en/function.copy.php
  559. * @return void
  560. */
  561. public function testCopyDefaultSignature()
  562. {
  563. $this->pci->parse(TEST_FILES_PATH . 'source18881-20d.php');
  564. $this->assertSame(
  565. array('4.0.0', ''), $this->pci->getVersions()
  566. );
  567. }
  568. /**
  569. * alternative example with copy()
  570. *
  571. * @link http://www.php.net/manual/en/function.copy.php
  572. * @return void
  573. */
  574. public function testCopyOptionalSignature()
  575. {
  576. $this->pci->parse(TEST_FILES_PATH . 'source18881-20o.php');
  577. $this->assertSame(
  578. array('5.3.0', ''), $this->pci->getVersions()
  579. );
  580. }
  581. /**
  582. * example with parse_url()
  583. *
  584. * @link http://www.php.net/manual/en/function.parse-url.php
  585. * @return void
  586. */
  587. public function testParseUrlDefaultSignature()
  588. {
  589. $this->pci->parse(TEST_FILES_PATH . 'source18881-21d.php');
  590. $this->assertSame(
  591. array('4.0.0', ''), $this->pci->getVersions()
  592. );
  593. }
  594. /**
  595. * alternative example with parse_url()
  596. *
  597. * @link http://www.php.net/manual/en/function.parse-url.php
  598. * @return void
  599. */
  600. public function testParseUrlOptionalSignature()
  601. {
  602. $this->pci->parse(TEST_FILES_PATH . 'source18881-21o.php');
  603. $this->assertSame(
  604. array('5.2.0', ''), $this->pci->getVersions()
  605. );
  606. }
  607. /**
  608. * example with memory_get_usage()
  609. *
  610. * @link http://www.php.net/manual/en/function.memory-get-usage.php
  611. * @return void
  612. */
  613. public function testMemoryGetUsageDefaultSignature()
  614. {
  615. $this->pci->parse(TEST_FILES_PATH . 'source18881-22d.php');
  616. $this->assertSame(
  617. array('4.3.2', ''), $this->pci->getVersions()
  618. );
  619. }
  620. /**
  621. * alternative example with memory_get_usage()
  622. *
  623. * @link http://www.php.net/manual/en/function.memory-get-usage.php
  624. * @return void
  625. */
  626. public function testMemoryGetUsageOptionalSignature()
  627. {
  628. $this->pci->parse(TEST_FILES_PATH . 'source18881-22o.php');
  629. $this->assertSame(
  630. array('5.2.0', ''), $this->pci->getVersions()
  631. );
  632. }
  633. /**
  634. * example with htmlspecialchars()
  635. *
  636. * @link http://www.php.net/manual/en/function.htmlspecialchars.php
  637. * @return void
  638. */
  639. public function testHtmlspecialcharsDefaultSignature()
  640. {
  641. $this->pci->parse(TEST_FILES_PATH . 'source18881-23d.php');
  642. $this->assertSame(
  643. array('4.0.0', ''), $this->pci->getVersions()
  644. );
  645. }
  646. /**
  647. * alternative example with htmlspecialchars()
  648. *
  649. * @link http://www.php.net/manual/en/function.htmlspecialchars.php
  650. * @return void
  651. */
  652. public function testHtmlspecialcharsOptionalSignature()
  653. {
  654. $this->pci->parse(TEST_FILES_PATH . 'source18881-23o.php');
  655. $this->assertSame(
  656. array('4.1.0', ''), $this->pci->getVersions()
  657. );
  658. }
  659. /**
  660. * example with htmlentities()
  661. *
  662. * @link http://www.php.net/manual/en/function.htmlentities.php
  663. * @return void
  664. */
  665. public function testHtmlentitiesDefaultSignature()
  666. {
  667. $this->pci->parse(TEST_FILES_PATH . 'source18881-24d.php');
  668. $this->assertSame(
  669. array('4.0.0', ''), $this->pci->getVersions()
  670. );
  671. }
  672. /**
  673. * alternative example with htmlentities()
  674. *
  675. * @link http://www.php.net/manual/en/function.htmlentities.php
  676. * @return void
  677. */
  678. public function testHtmlentitiesOptionalSignature()
  679. {
  680. $this->pci->parse(TEST_FILES_PATH . 'source18881-24o.php');
  681. $this->assertSame(
  682. array('4.0.3', ''), $this->pci->getVersions()
  683. );
  684. }
  685. /**
  686. * example with nl2br()
  687. *
  688. * @link http://www.php.net/manual/en/function.nl2br.php
  689. * @return void
  690. */
  691. public function testNl2brDefaultSignature()
  692. {
  693. $this->pci->parse(TEST_FILES_PATH . 'source18881-25d.php');
  694. $this->assertSame(
  695. array('4.0.0', ''), $this->pci->getVersions()
  696. );
  697. }
  698. /**
  699. * alternative example with nl2br()
  700. *
  701. * @link http://www.php.net/manual/en/function.nl2br.php
  702. * @return void
  703. */
  704. public function testNl2brOptionalSignature()
  705. {
  706. $this->pci->parse(TEST_FILES_PATH . 'source18881-25o.php');
  707. $this->assertSame(
  708. array('5.3.0', ''), $this->pci->getVersions()
  709. );
  710. }
  711. /**
  712. * example with clearstatcache()
  713. *
  714. * @link http://www.php.net/manual/en/function.clearstatcache.php
  715. * @return void
  716. */
  717. public function testClearstatcacheDefaultSignature()
  718. {
  719. $this->pci->parse(TEST_FILES_PATH . 'source18881-26d.php');
  720. $this->assertSame(
  721. array('4.0.0', ''), $this->pci->getVersions()
  722. );
  723. }
  724. /**
  725. * alternative example with clearstatcache()
  726. *
  727. * @link http://www.php.net/manual/en/function.clearstatcache.php
  728. * @return void
  729. */
  730. public function testClearstatcacheOptionalSignature()
  731. {
  732. $this->pci->parse(TEST_FILES_PATH . 'source18881-26o.php');
  733. $this->assertSame(
  734. array('5.3.0', ''), $this->pci->getVersions()
  735. );
  736. }
  737. /**
  738. * example with opendir()
  739. *
  740. * @link http://www.php.net/manual/en/function.opendir.php
  741. * @return void
  742. */
  743. public function testOpendirDefaultSignature()
  744. {
  745. $this->pci->parse(TEST_FILES_PATH . 'source18881-27d.php');
  746. $this->assertSame(
  747. array('4.0.0', ''), $this->pci->getVersions()
  748. );
  749. }
  750. /**
  751. * alternative example with opendir()
  752. *
  753. * @link http://www.php.net/manual/en/function.opendir.php
  754. * @return void
  755. */
  756. public function testOpendirOptionalSignature()
  757. {
  758. $this->pci->parse(TEST_FILES_PATH . 'source18881-27o.php');
  759. $this->assertSame(
  760. array('5.3.0', ''), $this->pci->getVersions()
  761. );
  762. }
  763. /**
  764. * example with json_decode()
  765. *
  766. * @link http://www.php.net/manual/en/function.json-decode.php
  767. * @return void
  768. */
  769. public function testJsonDecodeDefaultSignature()
  770. {
  771. if (!extension_loaded('json')) {
  772. $this->markTestSkipped(
  773. "The 'json' extension is not available."
  774. );
  775. }
  776. $this->pci->parse(TEST_FILES_PATH . 'source18881-29d.php');
  777. $this->assertSame(
  778. array('5.2.0', ''), $this->pci->getVersions()
  779. );
  780. }
  781. /**
  782. * alternative example with json_decode()
  783. *
  784. * @link http://www.php.net/manual/en/function.json-decode.php
  785. * @return void
  786. */
  787. public function testJsonDecodeOptionalSignature()
  788. {
  789. if (!extension_loaded('json')) {
  790. $this->markTestSkipped(
  791. "The 'json' extension is not available."
  792. );
  793. }
  794. $this->pci->parse(TEST_FILES_PATH . 'source18881-29o.php');
  795. $this->assertSame(
  796. array('5.3.0', ''), $this->pci->getVersions()
  797. );
  798. }
  799. /**
  800. * example with openssl_sign()
  801. *
  802. * @link http://www.php.net/manual/en/function.openssl-sign.php
  803. * @return void
  804. */
  805. public function testOpensslDefaultSignature()
  806. {
  807. if (!extension_loaded('openssl')) {
  808. $this->markTestSkipped(
  809. "The 'openssl' extension is not available."
  810. );
  811. }
  812. $this->pci->parse(TEST_FILES_PATH . 'source18881-30d.php');
  813. $this->assertSame(
  814. array('4.0.4', ''), $this->pci->getVersions()
  815. );
  816. }
  817. /**
  818. * alternative example with openssl_sign()
  819. *
  820. * @link http://www.php.net/manual/en/function.openssl-sign.php
  821. * @return void
  822. */
  823. public function testOpensslOptionalSignature()
  824. {
  825. if (!extension_loaded('openssl')) {
  826. $this->markTestSkipped(
  827. "The 'openssl' extension is not available."
  828. );
  829. }
  830. $this->pci->parse(TEST_FILES_PATH . 'source18881-30o.php');
  831. $this->assertSame(
  832. array('5.0.0', ''), $this->pci->getVersions()
  833. );
  834. }
  835. /**
  836. * example with preg_replace()
  837. *
  838. * @link http://www.php.net/manual/en/function.preg-replace.php
  839. * @return void
  840. */
  841. public function testPregReplaceDefaultSignature()
  842. {
  843. if (!extension_loaded('pcre')) {
  844. $this->markTestSkipped(
  845. "The 'pcre' extension is not available."
  846. );
  847. }
  848. $this->pci->parse(TEST_FILES_PATH . 'source18881-31d.php');
  849. $this->assertSame(
  850. array('4.0.0', ''), $this->pci->getVersions()
  851. );
  852. }
  853. /**
  854. * alternative example with preg_replace()
  855. *
  856. * @link http://www.php.net/manual/en/function.preg-replace.php
  857. * @return void
  858. */
  859. public function testPregReplaceOptionalSignature()
  860. {
  861. if (!extension_loaded('pcre')) {
  862. $this->markTestSkipped(
  863. "The 'pcre' extension is not available."
  864. );
  865. }
  866. $this->pci->parse(TEST_FILES_PATH . 'source18881-31o.php');
  867. $this->assertSame(
  868. array('5.1.0', ''), $this->pci->getVersions()
  869. );
  870. }
  871. /**
  872. * example with preg_replace_callback()
  873. *
  874. * @link http://www.php.net/manual/en/function.preg-replace-callback.php
  875. * @return void
  876. */
  877. public function testPregReplaceCallbackDefaultSignature()
  878. {
  879. if (!extension_loaded('pcre')) {
  880. $this->markTestSkipped(
  881. "The 'pcre' extension is not available."
  882. );
  883. }
  884. $this->pci->parse(TEST_FILES_PATH . 'source18881-32d.php');
  885. $this->assertSame(
  886. array('4.0.5', ''), $this->pci->getVersions()
  887. );
  888. }
  889. /**
  890. * alternative example with preg_replace_callback()
  891. *
  892. * @link http://www.php.net/manual/en/function.preg-replace-callback.php
  893. * @return void
  894. */
  895. public function testPregReplaceCallbackOptionalSignature()
  896. {
  897. if (!extension_loaded('pcre')) {
  898. $this->markTestSkipped(
  899. "The 'pcre' extension is not available."
  900. );
  901. }
  902. $this->pci->parse(TEST_FILES_PATH . 'source18881-32o.php');
  903. $this->assertSame(
  904. array('5.1.0', ''), $this->pci->getVersions()
  905. );
  906. }
  907. /**
  908. * example with session_regenerate_id()
  909. *
  910. * @link http://www.php.net/manual/en/function.session-regenerate-id.php
  911. * @return void
  912. */
  913. public function testSessionRegenerateIdDefaultSignature()
  914. {
  915. if (!extension_loaded('session')) {
  916. $this->markTestSkipped(
  917. "The 'session' extension is not available."
  918. );
  919. }
  920. $this->pci->parse(TEST_FILES_PATH . 'source18881-33d.php');
  921. $this->assertSame(
  922. array('4.3.2', ''), $this->pci->getVersions()
  923. );
  924. }
  925. /**
  926. * alternative example with session_regenerate_id()
  927. *
  928. * @link http://www.php.net/manual/en/function.session-regenerate-id.php
  929. * @return void
  930. */
  931. public function testSessionRegenerateIdOptionalSignature()
  932. {
  933. if (!extension_loaded('session')) {
  934. $this->markTestSkipped(
  935. "The 'session' extension is not available."
  936. );
  937. }
  938. $this->pci->parse(TEST_FILES_PATH . 'source18881-33o.php');
  939. $this->assertSame(
  940. array('5.1.0', ''), $this->pci->getVersions()
  941. );
  942. }
  943. /**
  944. * example with sqlite_fetch_column_types()
  945. *
  946. * @link http://www.php.net/manual/en/function.sqlite-fetch-column-types.php
  947. * @return void
  948. */
  949. public function testSqliteFetchColumnTypesDefaultSignature()
  950. {
  951. if (!extension_loaded('sqlite')) {
  952. $this->markTestSkipped(
  953. "The 'sqlite' extension is not available."
  954. );
  955. }
  956. $this->pci->parse(TEST_FILES_PATH . 'source18881-34d.php');
  957. $this->assertSame(
  958. array('5.0.0', ''), $this->pci->getVersions()
  959. );
  960. }
  961. /**
  962. * alternative example with sqlite_fetch_column_types()
  963. *
  964. * @link http://www.php.net/manual/en/function.sqlite-fetch-column-types.php
  965. * @return void
  966. */
  967. public function testSqliteFetchColumnTypesOptionalSignature()
  968. {
  969. if (!extension_loaded('sqlite')) {
  970. $this->markTestSkipped(
  971. "The 'sqlite' extension is not available."
  972. );
  973. }
  974. $this->pci->parse(TEST_FILES_PATH . 'source18881-34o.php');
  975. $this->assertSame(
  976. array('5.1.0', ''), $this->pci->getVersions()
  977. );
  978. }
  979. /**
  980. * example with getopt()
  981. *
  982. * @link http://www.php.net/manual/en/function.getopt.php
  983. * @return void
  984. */
  985. public function testGetoptDefaultSignature()
  986. {
  987. $this->pci->parse(TEST_FILES_PATH . 'source18881-35d.php');
  988. $this->assertSame(
  989. array('4.3.0', ''), $this->pci->getVersions()
  990. );
  991. }
  992. /**
  993. * alternative example with getopt()
  994. *
  995. * @link http://www.php.net/manual/en/function.getopt.php
  996. * @return void
  997. */
  998. public function testGetoptOptionalSignature()
  999. {
  1000. $this->pci->parse(TEST_FILES_PATH . 'source18881-35o.php');
  1001. $this->assertSame(
  1002. array('5.3.0', ''), $this->pci->getVersions()
  1003. );
  1004. }
  1005. }