/wp-content/plugins/sitepress-multilingual-cms/vendor/wimg/php-compatibility/Tests/Sniffs/PHP/NewFunctionArrayDereferencingSniffTest.php

https://bitbucket.org/wphupp/tmp-passion-sourire · PHP · 91 lines · 35 code · 8 blank · 48 comment · 0 complexity · 0bc3dd7f7d9bd8c326a207519c55f2eb MD5 · raw file

  1. <?php
  2. /**
  3. * New function array dereferencing sniff test file
  4. *
  5. * @package PHPCompatibility
  6. */
  7. /**
  8. * New function array dereferencing sniff tests
  9. *
  10. * @group newFunctionArrayDereferencing
  11. *
  12. * @covers PHPCompatibility_Sniffs_PHP_NewFunctionArrayDereferencingSniff
  13. *
  14. * @uses BaseSniffTest
  15. * @package PHPCompatibility
  16. * @author Wim Godden <wim@cu.be>
  17. */
  18. class NewFunctionArrayDereferencingSniffTest extends BaseSniffTest
  19. {
  20. const TEST_FILE = 'sniff-examples/new_function_array_dereferencing.php';
  21. /**
  22. * testArrayDereferencing
  23. *
  24. * @dataProvider dataArrayDereferencing
  25. *
  26. * @param int $line Line number with valid code.
  27. *
  28. * @return void
  29. */
  30. public function testArrayDereferencing($line)
  31. {
  32. $file = $this->sniffFile(self::TEST_FILE, '5.3');
  33. $this->assertError($file, $line, 'Function array dereferencing is not present in PHP version 5.3 or earlier');
  34. $file = $this->sniffFile(self::TEST_FILE, '5.4');
  35. $this->assertNoViolation($file, $line);
  36. }
  37. /**
  38. * dataArrayDereferencing
  39. *
  40. * @see testArrayDereferencing()
  41. *
  42. * @return array
  43. */
  44. public function dataArrayDereferencing() {
  45. return array(
  46. array(3),
  47. array(14),
  48. array(15),
  49. array(16),
  50. );
  51. }
  52. /**
  53. * testNoViolation
  54. *
  55. * @dataProvider dataNoViolation
  56. *
  57. * @param int $line Line number with valid code.
  58. *
  59. * @return void
  60. */
  61. public function testNoViolation($line)
  62. {
  63. $file = $this->sniffFile(self::TEST_FILE, '5.2');
  64. $this->assertNoViolation($file, $line);
  65. }
  66. /**
  67. * dataNoViolation
  68. *
  69. * @see testNoViolation()
  70. *
  71. * @return array
  72. */
  73. public function dataNoViolation() {
  74. return array(
  75. array(5),
  76. array(8),
  77. array(9),
  78. array(10),
  79. array(11),
  80. array(19),
  81. );
  82. }
  83. }