GFMFI_GformGetFormFilterTest

The Gravity Forms: Multiple Form Instances GFMFI GformGetFormFilterTest class.

Defined (1)

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

/tests/unit-tests/GFMFI_GformGetFormFilterTest.php  
  1. class GFMFI_GformGetFormFilterTest extends WP_UnitTestCase { 
  2.  
  3. public function gform_multiple_instances_strings( $strings ) { 
  4. $strings['fooBar'] = 'barFoo'; 
  5. return $strings; 
  6.  
  7. public function setUp() { 
  8. $this->gfmfi = $this->getMock('Gravity_Forms_Multiple_Form_Instances', null); 
  9. $this->form = array( 'id' => 123 ); 
  10. $this->randomId = mt_rand(); 
  11.  
  12. $_POST['gform_random_id'] = $this->randomId; 
  13.  
  14. public function tearDown() { 
  15. unset( $this->gfmfi ); 
  16. unset( $this->form ); 
  17. unset( $this->randomId ); 
  18.  
  19. /** 
  20. * @covers Gravity_Forms_Multiple_Form_Instances::gform_get_form_filter 
  21. */ 
  22. public function testOriginalFormIdAddition() { 
  23. $input = ' gform_wrapper '; 
  24. $expected = ' gform_wrapper gform_wrapper_original_id_' . $this->form['id'] . ' '; 
  25. $actual = $this->gfmfi->gform_get_form_filter( $input, $this->form ); 
  26.  
  27. $this->assertSame( $expected, $actual ); 
  28.  
  29. /** 
  30. * @covers Gravity_Forms_Multiple_Form_Instances::gform_get_form_filter 
  31. */ 
  32. public function testForChoiceReplacement() { 
  33. $input = "<label for='choice_123'>"; 
  34. $expected = "<label for='choice_" . $this->randomId . "_123'>"; 
  35. $actual = $this->gfmfi->gform_get_form_filter( $input, $this->form ); 
  36.  
  37. $this->assertSame( $expected, $actual ); 
  38.  
  39. /** 
  40. * @covers Gravity_Forms_Multiple_Form_Instances::gform_get_form_filter 
  41. */ 
  42. public function testIdChoiceReplacement() { 
  43. $input = "<label id='choice_123'>"; 
  44. $expected = "<label id='choice_" . $this->randomId . "_123'>"; 
  45. $actual = $this->gfmfi->gform_get_form_filter( $input, $this->form ); 
  46.  
  47. $this->assertSame( $expected, $actual ); 
  48.  
  49. /** 
  50. * @covers Gravity_Forms_Multiple_Form_Instances::gform_get_form_filter 
  51. */ 
  52. public function testIdLabelReplacement() { 
  53. $input = "<label id='label_123'>"; 
  54. $expected = "<label id='label_" . $this->randomId . "_123'>"; 
  55. $actual = $this->gfmfi->gform_get_form_filter( $input, $this->form ); 
  56.  
  57. $this->assertSame( $expected, $actual ); 
  58.  
  59. /** 
  60. * @covers Gravity_Forms_Multiple_Form_Instances::gform_get_form_filter 
  61. */ 
  62. public function testGformWrapperReplacement() { 
  63. $input = "'gform_wrapper_" . $this->form['id'] . "'"; 
  64. $expected = "'gform_wrapper_" . $this->randomId . "'"; 
  65. $actual = $this->gfmfi->gform_get_form_filter( $input, $this->form ); 
  66.  
  67. $this->assertSame( $expected, $actual ); 
  68.  
  69. /** 
  70. * @covers Gravity_Forms_Multiple_Form_Instances::gform_get_form_filter 
  71. */ 
  72. public function testGfReplacement() { 
  73. $input = "'gf_" . $this->form['id'] . "'"; 
  74. $expected = "'gf_" . $this->randomId . "'"; 
  75. $actual = $this->gfmfi->gform_get_form_filter( $input, $this->form ); 
  76.  
  77. $this->assertSame( $expected, $actual ); 
  78.  
  79. /** 
  80. * @covers Gravity_Forms_Multiple_Form_Instances::gform_get_form_filter 
  81. */ 
  82. public function testGformReplacement() { 
  83. $input = "'gform_" . $this->form['id'] . "'"; 
  84. $expected = "'gform_" . $this->randomId . "'"; 
  85. $actual = $this->gfmfi->gform_get_form_filter( $input, $this->form ); 
  86.  
  87. $this->assertSame( $expected, $actual ); 
  88.  
  89. /** 
  90. * @covers Gravity_Forms_Multiple_Form_Instances::gform_get_form_filter 
  91. */ 
  92. public function testGformAjaxFrameReplacement() { 
  93. $input = "'gform_ajax_frame_" . $this->form['id'] . "'"; 
  94. $expected = "'gform_ajax_frame_" . $this->randomId . "'"; 
  95. $actual = $this->gfmfi->gform_get_form_filter( $input, $this->form ); 
  96.  
  97. $this->assertSame( $expected, $actual ); 
  98.  
  99. /** 
  100. * @covers Gravity_Forms_Multiple_Form_Instances::gform_get_form_filter 
  101. */ 
  102. public function testHashGfReplacement() { 
  103. $input = "#gf_" . $this->form['id'] . "'"; 
  104. $expected = "#gf_" . $this->randomId . "'"; 
  105. $actual = $this->gfmfi->gform_get_form_filter( $input, $this->form ); 
  106.  
  107. $this->assertSame( $expected, $actual ); 
  108.  
  109. /** 
  110. * @covers Gravity_Forms_Multiple_Form_Instances::gform_get_form_filter 
  111. */ 
  112. public function testGformFieldsReplacement() { 
  113. $input = "'gform_fields_" . $this->form['id'] . "'"; 
  114. $expected = "'gform_fields_" . $this->randomId . "'"; 
  115. $actual = $this->gfmfi->gform_get_form_filter( $input, $this->form ); 
  116.  
  117. $this->assertSame( $expected, $actual ); 
  118.  
  119. /** 
  120. * @covers Gravity_Forms_Multiple_Form_Instances::gform_get_form_filter 
  121. */ 
  122. public function testIdFieldReplacement() { 
  123. $input = "id='field_" . $this->form['id'] . '_'; 
  124. $expected = "id='field_" . $this->randomId . '_'; 
  125. $actual = $this->gfmfi->gform_get_form_filter( $input, $this->form ); 
  126.  
  127. $this->assertSame( $expected, $actual ); 
  128.  
  129. /** 
  130. * @covers Gravity_Forms_Multiple_Form_Instances::gform_get_form_filter 
  131. */ 
  132. public function testForInputReplacement() { 
  133. $input = "for='input_" . $this->form['id'] . '_'; 
  134. $expected = "for='input_" . $this->randomId . '_'; 
  135. $actual = $this->gfmfi->gform_get_form_filter( $input, $this->form ); 
  136.  
  137. $this->assertSame( $expected, $actual ); 
  138.  
  139. /** 
  140. * @covers Gravity_Forms_Multiple_Form_Instances::gform_get_form_filter 
  141. */ 
  142. public function testIdInputReplacement() { 
  143. $input = "id='input_" . $this->form['id'] . '_'; 
  144. $expected = "id='input_" . $this->randomId . '_'; 
  145. $actual = $this->gfmfi->gform_get_form_filter( $input, $this->form ); 
  146.  
  147. $this->assertSame( $expected, $actual ); 
  148.  
  149. /** 
  150. * @covers Gravity_Forms_Multiple_Form_Instances::gform_get_form_filter 
  151. */ 
  152. public function testGformSubmitButtonReplacement() { 
  153. $input = "'gform_submit_button_" . $this->form['id'] . "'"; 
  154. $expected = "'gform_submit_button_" . $this->randomId . "'"; 
  155. $actual = $this->gfmfi->gform_get_form_filter( $input, $this->form ); 
  156.  
  157. $this->assertSame( $expected, $actual ); 
  158.  
  159. /** 
  160. * @covers Gravity_Forms_Multiple_Form_Instances::gform_get_form_filter 
  161. */ 
  162. public function testGfSubmittingDoubleQuoteReplacement() { 
  163. $input = '"gf_submitting_' . $this->form['id'] . '"'; 
  164. $expected = '"gf_submitting_' . $this->randomId . '"'; 
  165. $actual = $this->gfmfi->gform_get_form_filter( $input, $this->form ); 
  166.  
  167. $this->assertSame( $expected, $actual ); 
  168.  
  169. /** 
  170. * @covers Gravity_Forms_Multiple_Form_Instances::gform_get_form_filter 
  171. */ 
  172. public function testGfSubmittingSingleQuoteReplacement() { 
  173. $input = "'gf_submitting_" . $this->form['id'] . "'"; 
  174. $expected = "'gf_submitting_" . $this->randomId . "'"; 
  175. $actual = $this->gfmfi->gform_get_form_filter( $input, $this->form ); 
  176.  
  177. $this->assertSame( $expected, $actual ); 
  178.  
  179. /** 
  180. * @covers Gravity_Forms_Multiple_Form_Instances::gform_get_form_filter 
  181. */ 
  182. public function testHashGformAjaxFrameReplacement() { 
  183. $input = '#gform_ajax_frame_' . $this->form['id']; 
  184. $expected = '#gform_ajax_frame_' . $this->randomId; 
  185. $actual = $this->gfmfi->gform_get_form_filter( $input, $this->form ); 
  186.  
  187. $this->assertSame( $expected, $actual ); 
  188.  
  189. /** 
  190. * @covers Gravity_Forms_Multiple_Form_Instances::gform_get_form_filter 
  191. */ 
  192. public function testHashGformWrapperReplacement() { 
  193. $input = '#gform_wrapper_' . $this->form['id']; 
  194. $expected = '#gform_wrapper_' . $this->randomId; 
  195. $actual = $this->gfmfi->gform_get_form_filter( $input, $this->form ); 
  196.  
  197. $this->assertSame( $expected, $actual ); 
  198.  
  199. /** 
  200. * @covers Gravity_Forms_Multiple_Form_Instances::gform_get_form_filter 
  201. */ 
  202. public function testHashGformReplacement() { 
  203. $input = '#gform_' . $this->form['id']; 
  204. $expected = '#gform_' . $this->randomId; 
  205. $actual = $this->gfmfi->gform_get_form_filter( $input, $this->form ); 
  206.  
  207. $this->assertSame( $expected, $actual ); 
  208.  
  209. /** 
  210. * @covers Gravity_Forms_Multiple_Form_Instances::gform_get_form_filter 
  211. */ 
  212. public function testTriggerGformPostRenderReplacement() { 
  213. $input = "trigger('gform_post_render', [" . $this->form['id']; 
  214. $expected = "trigger('gform_post_render', [" . $this->randomId; 
  215. $actual = $this->gfmfi->gform_get_form_filter( $input, $this->form ); 
  216.  
  217. $this->assertSame( $expected, $actual ); 
  218.  
  219. /** 
  220. * @covers Gravity_Forms_Multiple_Form_Instances::gform_get_form_filter 
  221. */ 
  222. public function testGformInitSpinnerReplacement() { 
  223. $input = 'gformInitSpinner( ' . $this->form['id'] . ', '; 
  224. $expected = 'gformInitSpinner( ' . $this->randomId . ', '; 
  225. $actual = $this->gfmfi->gform_get_form_filter( $input, $this->form ); 
  226.  
  227. $this->assertSame( $expected, $actual ); 
  228.  
  229. /** 
  230. * @covers Gravity_Forms_Multiple_Form_Instances::gform_get_form_filter 
  231. */ 
  232. public function testTriggerGformPageLoadedReplacement() { 
  233. $input = "trigger('gform_page_loaded', [" . $this->form['id']; 
  234. $expected = "trigger('gform_page_loaded', [" . $this->randomId; 
  235. $actual = $this->gfmfi->gform_get_form_filter( $input, $this->form ); 
  236.  
  237. $this->assertSame( $expected, $actual ); 
  238.  
  239. /** 
  240. * @covers Gravity_Forms_Multiple_Form_Instances::gform_get_form_filter 
  241. */ 
  242. public function testGformConfirmationLoadedReplacement() { 
  243. $input = "'gform_confirmation_loaded', [" . $this->form['id'] . ']'; 
  244. $expected = "'gform_confirmation_loaded', [" . $this->randomId . ']'; 
  245. $actual = $this->gfmfi->gform_get_form_filter( $input, $this->form ); 
  246.  
  247. $this->assertSame( $expected, $actual ); 
  248.  
  249. /** 
  250. * @covers Gravity_Forms_Multiple_Form_Instances::gform_get_form_filter 
  251. */ 
  252. public function testGfApplyRulesReplacement() { 
  253. $input = 'gf_apply_rules(' . $this->form['id'] . ', '; 
  254. $expected = 'gf_apply_rules(' . $this->randomId . ', '; 
  255. $actual = $this->gfmfi->gform_get_form_filter( $input, $this->form ); 
  256.  
  257. $this->assertSame( $expected, $actual ); 
  258.  
  259. /** 
  260. * @covers Gravity_Forms_Multiple_Form_Instances::gform_get_form_filter 
  261. */ 
  262. public function testGformConfirmationWrapperReplacement() { 
  263. $input = 'gform_confirmation_wrapper_' . $this->form['id']; 
  264. $expected = 'gform_confirmation_wrapper_' . $this->randomId; 
  265. $actual = $this->gfmfi->gform_get_form_filter( $input, $this->form ); 
  266.  
  267. $this->assertSame( $expected, $actual ); 
  268.  
  269. /** 
  270. * @covers Gravity_Forms_Multiple_Form_Instances::gform_get_form_filter 
  271. */ 
  272. public function testGformsConfirmationMessageReplacement() { 
  273. $input = 'gforms_confirmation_message_' . $this->form['id']; 
  274. $expected = 'gforms_confirmation_message_' . $this->randomId; 
  275. $actual = $this->gfmfi->gform_get_form_filter( $input, $this->form ); 
  276.  
  277. $this->assertSame( $expected, $actual ); 
  278.  
  279. /** 
  280. * @covers Gravity_Forms_Multiple_Form_Instances::gform_get_form_filter 
  281. */ 
  282. public function testGformConfirmationMessageReplacement() { 
  283. $input = 'gform_confirmation_message_' . $this->form['id']; 
  284. $expected = 'gform_confirmation_message_' . $this->randomId; 
  285. $actual = $this->gfmfi->gform_get_form_filter( $input, $this->form ); 
  286.  
  287. $this->assertSame( $expected, $actual ); 
  288.  
  289. /** 
  290. * @covers Gravity_Forms_Multiple_Form_Instances::gform_get_form_filter 
  291. */ 
  292. public function testIfFormIdReplacement() { 
  293. $input = 'if(formId == ' . $this->form['id'] . ')'; 
  294. $expected = 'if(formId == ' . $this->randomId . ')'; 
  295. $actual = $this->gfmfi->gform_get_form_filter( $input, $this->form ); 
  296.  
  297. $this->assertSame( $expected, $actual ); 
  298.  
  299. /** 
  300. * @covers Gravity_Forms_Multiple_Form_Instances::gform_get_form_filter 
  301. */ 
  302. public function testWindowGfFormConditionalLogicReplacement() { 
  303. $input = "window['gf_form_conditional_logic'][" . $this->form['id'] . ']'; 
  304. $expected = "window['gf_form_conditional_logic'][" . $this->randomId . ']'; 
  305. $actual = $this->gfmfi->gform_get_form_filter( $input, $this->form ); 
  306.  
  307. $this->assertSame( $expected, $actual ); 
  308.  
  309. /** 
  310. * @covers Gravity_Forms_Multiple_Form_Instances::gform_get_form_filter 
  311. */ 
  312. public function testTriggerGformPostConditionalLogicReplacement() { 
  313. $input = "trigger('gform_post_conditional_logic', [" . $this->form['id'] . ', '; 
  314. $expected = "trigger('gform_post_conditional_logic', [" . $this->randomId . ', '; 
  315. $actual = $this->gfmfi->gform_get_form_filter( $input, $this->form ); 
  316.  
  317. $this->assertSame( $expected, $actual ); 
  318.  
  319. /** 
  320. * @covers Gravity_Forms_Multiple_Form_Instances::gform_get_form_filter 
  321. */ 
  322. public function testGformShowPasswordStrengthInputReplacement() { 
  323. $input = 'gformShowPasswordStrength("input_' . $this->form['id'] . '_'; 
  324. $expected = 'gformShowPasswordStrength("input_' . $this->randomId . '_'; 
  325. $actual = $this->gfmfi->gform_get_form_filter( $input, $this->form ); 
  326.  
  327. $this->assertSame( $expected, $actual ); 
  328.  
  329. /** 
  330. * @covers Gravity_Forms_Multiple_Form_Instances::gform_get_form_filter 
  331. */ 
  332. public function testGformInitChosenFieldsInputReplacement() { 
  333. $input = "gformInitChosenFields('#input_" . $this->form['id'] . '_'; 
  334. $expected = "gformInitChosenFields('#input_" . $this->randomId . '_'; 
  335. $actual = $this->gfmfi->gform_get_form_filter( $input, $this->form ); 
  336.  
  337. $this->assertSame( $expected, $actual ); 
  338.  
  339. /** 
  340. * @covers Gravity_Forms_Multiple_Form_Instances::gform_get_form_filter 
  341. */ 
  342. public function testJqueryHashInputReplacement() { 
  343. $input = "jQuery('#input_" . $this->form['id'] . '_'; 
  344. $expected = "jQuery('#input_" . $this->randomId . '_'; 
  345. $actual = $this->gfmfi->gform_get_form_filter( $input, $this->form ); 
  346.  
  347. $this->assertSame( $expected, $actual ); 
  348.  
  349. /** 
  350. * @covers Gravity_Forms_Multiple_Form_Instances::gform_get_form_filter 
  351. */ 
  352. public function testGformsCalendarIconInputReplacement() { 
  353. $input = 'gforms_calendar_icon_input_' . $this->form['id'] . '_'; 
  354. $expected = 'gforms_calendar_icon_input_' . $this->randomId . '_'; 
  355. $actual = $this->gfmfi->gform_get_form_filter( $input, $this->form ); 
  356.  
  357. $this->assertSame( $expected, $actual ); 
  358.  
  359. /** 
  360. * @covers Gravity_Forms_Multiple_Form_Instances::gform_get_form_filter 
  361. */ 
  362. public function testIdGinputBasePriceReplacement() { 
  363. $input = "id='ginput_base_price_" . $this->form['id'] . '_'; 
  364. $expected = "id='ginput_base_price_" . $this->randomId . '_'; 
  365. $actual = $this->gfmfi->gform_get_form_filter( $input, $this->form ); 
  366.  
  367. $this->assertSame( $expected, $actual ); 
  368.  
  369. /** 
  370. * @covers Gravity_Forms_Multiple_Form_Instances::gform_get_form_filter 
  371. */ 
  372. public function testIdGinputQuantityReplacement() { 
  373. $input = "id='ginput_quantity_" . $this->form['id'] . '_'; 
  374. $expected = "id='ginput_quantity_" . $this->randomId . '_'; 
  375. $actual = $this->gfmfi->gform_get_form_filter( $input, $this->form ); 
  376.  
  377. $this->assertSame( $expected, $actual ); 
  378.  
  379. /** 
  380. * @covers Gravity_Forms_Multiple_Form_Instances::gform_get_form_filter 
  381. */ 
  382. public function testGfieldPriceReplacement() { 
  383. $input = 'gfield_price_' . $this->form['id'] . '_'; 
  384. $expected = 'gfield_price_' . $this->randomId . '_'; 
  385. $actual = $this->gfmfi->gform_get_form_filter( $input, $this->form ); 
  386.  
  387. $this->assertSame( $expected, $actual ); 
  388.  
  389. /** 
  390. * @covers Gravity_Forms_Multiple_Form_Instances::gform_get_form_filter 
  391. */ 
  392. public function testGfieldQuantityReplacement() { 
  393. $input = 'gfield_quantity_' . $this->form['id'] . '_'; 
  394. $expected = 'gfield_quantity_' . $this->randomId . '_'; 
  395. $actual = $this->gfmfi->gform_get_form_filter( $input, $this->form ); 
  396.  
  397. $this->assertSame( $expected, $actual ); 
  398.  
  399. /** 
  400. * @covers Gravity_Forms_Multiple_Form_Instances::gform_get_form_filter 
  401. */ 
  402. public function testGfieldProductReplacement() { 
  403. $input = 'gfield_product_' . $this->form['id'] . '_'; 
  404. $expected = 'gfield_product_' . $this->randomId . '_'; 
  405. $actual = $this->gfmfi->gform_get_form_filter( $input, $this->form ); 
  406.  
  407. $this->assertSame( $expected, $actual ); 
  408.  
  409. /** 
  410. * @covers Gravity_Forms_Multiple_Form_Instances::gform_get_form_filter 
  411. */ 
  412. public function testGinputTotalReplacement() { 
  413. $input = 'ginput_total_' . $this->form['id']; 
  414. $expected = 'ginput_total_' . $this->randomId; 
  415. $actual = $this->gfmfi->gform_get_form_filter( $input, $this->form ); 
  416.  
  417. $this->assertSame( $expected, $actual ); 
  418.  
  419. /** 
  420. * @covers Gravity_Forms_Multiple_Form_Instances::gform_get_form_filter 
  421. */ 
  422. public function testGfCalcReplacement() { 
  423. $input = 'GFCalc(' . $this->form['id'] . ', '; 
  424. $expected = 'GFCalc(' . $this->randomId . ', '; 
  425. $actual = $this->gfmfi->gform_get_form_filter( $input, $this->form ); 
  426.  
  427. $this->assertSame( $expected, $actual ); 
  428.  
  429. /** 
  430. * @covers Gravity_Forms_Multiple_Form_Instances::gform_get_form_filter 
  431. */ 
  432. public function testGfGlobalNumberFormatsReplacement() { 
  433. $input = 'gf_global["number_formats"][' . $this->form['id'] . ']'; 
  434. $expected = 'gf_global["number_formats"][' . $this->randomId . ']'; 
  435. $actual = $this->gfmfi->gform_get_form_filter( $input, $this->form ); 
  436.  
  437. $this->assertSame( $expected, $actual ); 
  438.  
  439. /** 
  440. * @covers Gravity_Forms_Multiple_Form_Instances::gform_get_form_filter 
  441. */ 
  442. public function testGformNextButtonReplacement() { 
  443. $input = 'gform_next_button_' . $this->form['id'] . '_'; 
  444. $expected = 'gform_next_button_' . $this->randomId . '_'; 
  445. $actual = $this->gfmfi->gform_get_form_filter( $input, $this->form ); 
  446.  
  447. $this->assertSame( $expected, $actual ); 
  448.  
  449. /** 
  450. * @covers Gravity_Forms_Multiple_Form_Instances::gform_get_form_filter 
  451. */ 
  452. public function testHiddenFieldAddition() { 
  453. $input = "<input type='hidden' name='gform_field_values'"; 
  454. $expected = "<input type='hidden' name='gform_random_id' value='" . $this->randomId . "' />" . $input; 
  455. $actual = $this->gfmfi->gform_get_form_filter( $input, $this->form ); 
  456.  
  457. $this->assertSame( $expected, $actual ); 
  458.  
  459. /** 
  460. * @covers Gravity_Forms_Multiple_Form_Instances::gform_get_form_filter 
  461. */ 
  462. public function testGformMultipleInstancesStringsFilter() { 
  463. add_filter( 'gform_multiple_instances_strings', array($this, 'gform_multiple_instances_strings') ); 
  464.  
  465. $input = "fooBar"; 
  466. $expected = "barFoo"; 
  467. $actual = $this->gfmfi->gform_get_form_filter( $input, $this->form ); 
  468.  
  469. $this->assertSame( $expected, $actual ); 
  470.  
  471. remove_filter( 'gform_multiple_instances_strings', array($this, 'gform_multiple_instances_strings') ); 
  472.