DereferenceShortcodeVarsTest

The Contact Form DB DereferenceShortcodeVarsTest class.

Defined (1)

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

/phpunit/DereferenceShortcodeVarsTest.php  
  1. class DereferenceShortcodeVarsTest extends PHPUnit_Framework_TestCase { 
  2.  
  3. public function test() { 
  4. $dref = new DereferenceShortcodeVars; 
  5. $this->assertEquals('stuff', $dref->extractParamName('_POST', '$_POST(\'stuff\')')); 
  6.  
  7. public function testf() { 
  8. $dref = new DereferenceShortcodeVars; 
  9. $this->assertEquals('', $dref->extractParamName('_POST', '$_POSTxxxx(\'stuff\')')); 
  10.  
  11. public function test_doublequotes() { 
  12. $dref = new DereferenceShortcodeVars; 
  13. $this->assertEquals('stuff', $dref->extractParamName('_POST', '$_POST("stuff")')); 
  14.  
  15. public function testf_doublequotes() { 
  16. $dref = new DereferenceShortcodeVars; 
  17. $this->assertEquals('', $dref->extractParamName('_POST', '$_POSTx("stuff")')); 
  18.  
  19. public function test_noquotes() { 
  20. $dref = new DereferenceShortcodeVars; 
  21. $this->assertEquals('stuff', $dref->extractParamName('_POST', '$_POST(stuff)')); 
  22.  
  23. public function test_mixedQuotes() { 
  24. $dref = new DereferenceShortcodeVars; 
  25. $this->assertEquals('"stuff\'', $dref->extractParamName('_POST', '$_POST("stuff\')')); 
  26.  
  27. public function test_empty1() { 
  28. $dref = new DereferenceShortcodeVars; 
  29. $this->assertEquals('', $dref->extractParamName('_POST', '$_POST("")')); 
  30.  
  31. public function test_empty2() { 
  32. $dref = new DereferenceShortcodeVars; 
  33. $this->assertEquals('', $dref->extractParamName('_POST', '$_POST(\'\')')); 
  34.  
  35.  
  36.  
  37.  
  38. public function test_getMatches_in_middle() { 
  39. $dref = new DereferenceShortcodeVars; 
  40. $matches = $dref->getMatches('_POST', 'blah blah $_POST(mike1)blah'); 
  41. print_r($matches); 
  42. $this->assertEquals(1, count($matches)); 
  43. $this->assertEquals('$_POST(mike1)', $matches[0]); 
  44.  
  45. $this->assertEquals('mike1', $dref->extractParamName('_POST', $matches[0])); 
  46.  
  47. public function test_getMatches_multi_in_middle_1_noquotes() { 
  48. $dref = new DereferenceShortcodeVars; 
  49. $matches = $dref->getMatches('_POST', 'blah blah $_POST(mike2)blah$_POST(oya)'); 
  50. print_r($matches); 
  51. $this->assertEquals(2, count($matches)); 
  52. $this->assertEquals('$_POST(mike2)', $matches[0]); 
  53. $this->assertEquals('$_POST(oya)', $matches[1]); 
  54.  
  55. $this->assertEquals('mike2', $dref->extractParamName('_POST', $matches[0])); 
  56. $this->assertEquals('oya', $dref->extractParamName('_POST', $matches[1])); 
  57.  
  58. public function test_getMatches_multi_in_middle_1_quotes() { 
  59. $dref = new DereferenceShortcodeVars; 
  60. $matches = $dref->getMatches('_POST', 'blah blah $_POST("mike2")blah$_POST("oya")'); 
  61. print_r($matches); 
  62. $this->assertEquals(2, count($matches)); 
  63. $this->assertEquals('$_POST("mike2")', $matches[0]); 
  64. $this->assertEquals('$_POST("oya")', $matches[1]); 
  65.  
  66. $this->assertEquals('mike2', $dref->extractParamName('_POST', $matches[0])); 
  67. $this->assertEquals('oya', $dref->extractParamName('_POST', $matches[1])); 
  68.  
  69.  
  70. public function test_getMatches_multi_in_middle_2_quotes() { 
  71. $dref = new DereferenceShortcodeVars; 
  72. $matches = $dref->getMatches('_POST', 'blah blah $_POST(\'mike3\')blah$_POST(oya)'); 
  73. print_r($matches); 
  74. $this->assertEquals(2, count($matches)); 
  75. $this->assertEquals('$_POST(\'mike3\')', $matches[0]); 
  76. $this->assertEquals('$_POST(oya)', $matches[1]); 
  77.  
  78. $this->assertEquals('mike3', $dref->extractParamName('_POST', $matches[0])); 
  79. $this->assertEquals('oya', $dref->extractParamName('_POST', $matches[1])); 
  80.  
  81.  
  82. public function test_getMatches_multi_in_middle_4_spaceBeforeOpenParen() { 
  83. $dref = new DereferenceShortcodeVars; 
  84. $matches = $dref->getMatches('_POST', 'blah blah $_POST (\'mike4\')blah$_POST (oya4)'); 
  85. print_r($matches); 
  86. $this->assertEquals(2, count($matches)); 
  87. $this->assertEquals('$_POST (\'mike4\')', $matches[0]); 
  88. $this->assertEquals('$_POST (oya4)', $matches[1]); 
  89.  
  90. $this->assertEquals('mike4', $dref->extractParamName('_POST', $matches[0])); 
  91. $this->assertEquals('oya4', $dref->extractParamName('_POST', $matches[1])); 
  92.  
  93. public function test_getMatches_multi_in_middle_5_spaceBeforeCloseParen() { 
  94. $dref = new DereferenceShortcodeVars; 
  95. $matches = $dref->getMatches('_POST', 'blah blah $_POST (\'mike5\' )blah$_POST (oya5 )'); 
  96. print_r($matches); 
  97. $this->assertEquals(2, count($matches)); 
  98. $this->assertEquals('$_POST (\'mike5\' )', $matches[0]); 
  99. $this->assertEquals('$_POST (oya5 )', $matches[1]); 
  100.  
  101. $this->assertEquals('mike5', $dref->extractParamName('_POST', $matches[0])); 
  102. $this->assertEquals('oya5 ', $dref->extractParamName('_POST', $matches[1])); 
  103.  
  104.  
  105.  
  106. public function test_getMatches_multi_in_middle_6_spacesAfterOpenParen() { 
  107. $dref = new DereferenceShortcodeVars; 
  108. $matches = $dref->getMatches('_POST', 'blah blah $_POST ( \'mike6\' )blah$_POST ( oya )'); 
  109. print_r($matches); 
  110. $this->assertEquals(2, count($matches)); 
  111. $this->assertEquals('$_POST ( \'mike6\' )', $matches[0]); 
  112. $this->assertEquals('$_POST ( oya )', $matches[1]); 
  113.  
  114. $this->assertEquals('mike6', $dref->extractParamName('_POST', $matches[0])); 
  115. $this->assertEquals(' oya ', $dref->extractParamName('_POST', $matches[1])); 
  116.  
  117. public function test_qname() { 
  118. $dref = new DereferenceShortcodeVars; 
  119. $this->assertEquals('qname', $dref->extractParamName('_POST', '$_POST(qname)')); 
  120.  
  121. public function testConvert() { 
  122. $dref = new DereferenceShortcodeVars; 
  123. $string = $dref->convert('your-name=$_POST(aname)&&your-subject=$_POST(subject)'); 
  124. $this->assertEquals('your-name=&&your-subject=', $string); 
  125.