@@ -2248,196 +2248,6 @@ public function test_personal_data_eraser_pagination() {
22482248 $ this ->assertCount ( 0 , $ posts , 'posts count matches after deleting the other feedback responder ' );
22492249 }
22502250
2251- /**
2252- * Tests the functionality of the Util::grunion_contact_form_apply_block_attribute() function.
2253- */
2254- public function test_grunion_contact_form_apply_block_attribute () {
2255- // No contact form block.
2256- $ original = <<<'EOT'
2257- <!-- wp:template-part {"slug":"post-meta-icons","theme":"pub/zoologist"} /-->
2258-
2259- <!-- wp:spacer {"height":"150px"} -->
2260- <div style="height:150px;" aria-hidden="true" class="wp-block-spacer"></div>
2261- <!-- /wp:spacer -->
2262-
2263- <!-- wp:group {"style":{"spacing":{"padding":{"top":"30px","right":"20px","bottom":"0px","left":"20px"}}},"layout":{"inherit":true}} -->
2264- <div class="wp-block-group" style="padding-top:30px;padding-right:20px;padding-bottom:0;padding-left:20px;"><!-- wp:columns {"align":"wide","className":"next-prev-links"} -->
2265- <div class="wp-block-columns alignwide next-prev-links"><!-- wp:column -->
2266- <div class="wp-block-column"><!-- wp:post-navigation-link {"type":"previous","label":"←","showTitle":true} /--></div>
2267- <!-- /wp:column -->
2268-
2269- <!-- wp:column -->
2270- <div class="wp-block-column"><!-- wp:post-navigation-link {"textAlign":"right","label":"→","showTitle":true} /--></div>
2271- <!-- /wp:column --></div>
2272- <!-- /wp:columns -->
2273-
2274- <!-- wp:post-comments /--></div>
2275- <!-- /wp:group -->
2276- EOT;
2277- $ expected = <<<'EOT'
2278- <!-- wp:template-part {"slug":"post-meta-icons","theme":"pub/zoologist"} /-->
2279-
2280- <!-- wp:spacer {"height":"150px"} -->
2281- <div style="height:150px;" aria-hidden="true" class="wp-block-spacer"></div>
2282- <!-- /wp:spacer -->
2283-
2284- <!-- wp:group {"style":{"spacing":{"padding":{"top":"30px","right":"20px","bottom":"0px","left":"20px"}}},"layout":{"inherit":true}} -->
2285- <div class="wp-block-group" style="padding-top:30px;padding-right:20px;padding-bottom:0;padding-left:20px;"><!-- wp:columns {"align":"wide","className":"next-prev-links"} -->
2286- <div class="wp-block-columns alignwide next-prev-links"><!-- wp:column -->
2287- <div class="wp-block-column"><!-- wp:post-navigation-link {"type":"previous","label":"←","showTitle":true} /--></div>
2288- <!-- /wp:column -->
2289-
2290- <!-- wp:column -->
2291- <div class="wp-block-column"><!-- wp:post-navigation-link {"textAlign":"right","label":"→","showTitle":true} /--></div>
2292- <!-- /wp:column --></div>
2293- <!-- /wp:columns -->
2294-
2295- <!-- wp:post-comments /--></div>
2296- <!-- /wp:group -->
2297- EOT;
2298- $ this ->assertEquals (
2299- $ expected ,
2300- Util::grunion_contact_form_apply_block_attribute ( $ original , array ( 'foo ' => 'bar ' ) )
2301- );
2302- // Contact form block without attributes.
2303- $ original = <<<'EOT'
2304- <!-- wp:template-part {"slug":"post-meta-icons","theme":"pub/zoologist"} /-->
2305-
2306- <!-- wp:spacer {"height":"150px"} -->
2307- <div style="height:150px;" aria-hidden="true" class="wp-block-spacer"></div>
2308- <!-- /wp:spacer -->
2309-
2310- <!-- wp:jetpack/contact-form -->
2311- <div class="wp-block-jetpack-contact-form"><!-- wp:jetpack/field-name {"label":"Single Template","required":true} /-->
2312-
2313- <!-- wp:jetpack/field-textarea /-->
2314-
2315- <!-- wp:jetpack/button {"element":"button","text":"Contact Us"} /--></div>
2316- <!-- /wp:jetpack/contact-form -->
2317-
2318- <!-- wp:group {"style":{"spacing":{"padding":{"top":"30px","right":"20px","bottom":"0px","left":"20px"}}},"layout":{"inherit":true}} -->
2319- <div class="wp-block-group" style="padding-top:30px;padding-right:20px;padding-bottom:0;padding-left:20px;"><!-- wp:columns {"align":"wide","className":"next-prev-links"} -->
2320- <div class="wp-block-columns alignwide next-prev-links"><!-- wp:column -->
2321- <div class="wp-block-column"><!-- wp:post-navigation-link {"type":"previous","label":"←","showTitle":true} /--></div>
2322- <!-- /wp:column -->
2323-
2324- <!-- wp:column -->
2325- <div class="wp-block-column"><!-- wp:post-navigation-link {"textAlign":"right","label":"→","showTitle":true} /--></div>
2326- <!-- /wp:column --></div>
2327- <!-- /wp:columns -->
2328-
2329- <!-- wp:post-comments /--></div>
2330- <!-- /wp:group -->
2331- EOT;
2332- $ expected = <<<'EOT'
2333- <!-- wp:template-part {"slug":"post-meta-icons","theme":"pub/zoologist"} /-->
2334-
2335- <!-- wp:spacer {"height":"150px"} -->
2336- <div style="height:150px;" aria-hidden="true" class="wp-block-spacer"></div>
2337- <!-- /wp:spacer -->
2338-
2339- <!-- wp:jetpack/contact-form {"foo":"bar"} -->
2340- <div class="wp-block-jetpack-contact-form"><!-- wp:jetpack/field-name {"label":"Single Template","required":true} /-->
2341-
2342- <!-- wp:jetpack/field-textarea /-->
2343-
2344- <!-- wp:jetpack/button {"element":"button","text":"Contact Us"} /--></div>
2345- <!-- /wp:jetpack/contact-form -->
2346-
2347- <!-- wp:group {"style":{"spacing":{"padding":{"top":"30px","right":"20px","bottom":"0px","left":"20px"}}},"layout":{"inherit":true}} -->
2348- <div class="wp-block-group" style="padding-top:30px;padding-right:20px;padding-bottom:0;padding-left:20px;"><!-- wp:columns {"align":"wide","className":"next-prev-links"} -->
2349- <div class="wp-block-columns alignwide next-prev-links"><!-- wp:column -->
2350- <div class="wp-block-column"><!-- wp:post-navigation-link {"type":"previous","label":"←","showTitle":true} /--></div>
2351- <!-- /wp:column -->
2352-
2353- <!-- wp:column -->
2354- <div class="wp-block-column"><!-- wp:post-navigation-link {"textAlign":"right","label":"→","showTitle":true} /--></div>
2355- <!-- /wp:column --></div>
2356- <!-- /wp:columns -->
2357-
2358- <!-- wp:post-comments /--></div>
2359- <!-- /wp:group -->
2360- EOT;
2361- $ this ->assertEquals (
2362- $ expected ,
2363- Util::grunion_contact_form_apply_block_attribute ( $ original , array ( 'foo ' => 'bar ' ) )
2364- );
2365- // Contact form block with attributes.
2366- $ original = <<<'EOT'
2367- <!-- wp:template-part {"slug":"post-meta-icons","theme":"pub/zoologist"} /-->
2368-
2369- <!-- wp:spacer {"height":"150px"} -->
2370- <div style="height:150px;" aria-hidden="true" class="wp-block-spacer"></div>
2371- <!-- /wp:spacer -->
2372-
2373- <!-- wp:jetpack/contact-form {"customThankyou":"message"} -->
2374- <div class="wp-block-jetpack-contact-form"><!-- wp:jetpack/field-name {"label":"Single Template","required":true} /-->
2375-
2376- <!-- wp:jetpack/field-textarea /-->
2377-
2378- <!-- wp:jetpack/button {"element":"button","text":"Contact Us"} /--></div>
2379- <!-- /wp:jetpack/contact-form -->
2380-
2381- <!-- wp:group {"style":{"spacing":{"padding":{"top":"30px","right":"20px","bottom":"0px","left":"20px"}}},"layout":{"inherit":true}} -->
2382- <div class="wp-block-group" style="padding-top:30px;padding-right:20px;padding-bottom:0;padding-left:20px;"><!-- wp:columns {"align":"wide","className":"next-prev-links"} -->
2383- <div class="wp-block-columns alignwide next-prev-links"><!-- wp:column -->
2384- <div class="wp-block-column"><!-- wp:post-navigation-link {"type":"previous","label":"←","showTitle":true} /--></div>
2385- <!-- /wp:column -->
2386-
2387- <!-- wp:column -->
2388- <div class="wp-block-column"><!-- wp:post-navigation-link {"textAlign":"right","label":"→","showTitle":true} /--></div>
2389- <!-- /wp:column --></div>
2390- <!-- /wp:columns -->
2391-
2392- <!-- wp:post-comments /--></div>
2393- <!-- /wp:group -->
2394- EOT;
2395- $ expected = <<<'EOT'
2396- <!-- wp:template-part {"slug":"post-meta-icons","theme":"pub/zoologist"} /-->
2397-
2398- <!-- wp:spacer {"height":"150px"} -->
2399- <div style="height:150px;" aria-hidden="true" class="wp-block-spacer"></div>
2400- <!-- /wp:spacer -->
2401-
2402- <!-- wp:jetpack/contact-form {"customThankyou":"message","foo":"bar"} -->
2403- <div class="wp-block-jetpack-contact-form"><!-- wp:jetpack/field-name {"label":"Single Template","required":true} /-->
2404-
2405- <!-- wp:jetpack/field-textarea /-->
2406-
2407- <!-- wp:jetpack/button {"element":"button","text":"Contact Us"} /--></div>
2408- <!-- /wp:jetpack/contact-form -->
2409-
2410- <!-- wp:group {"style":{"spacing":{"padding":{"top":"30px","right":"20px","bottom":"0px","left":"20px"}}},"layout":{"inherit":true}} -->
2411- <div class="wp-block-group" style="padding-top:30px;padding-right:20px;padding-bottom:0;padding-left:20px;"><!-- wp:columns {"align":"wide","className":"next-prev-links"} -->
2412- <div class="wp-block-columns alignwide next-prev-links"><!-- wp:column -->
2413- <div class="wp-block-column"><!-- wp:post-navigation-link {"type":"previous","label":"←","showTitle":true} /--></div>
2414- <!-- /wp:column -->
2415-
2416- <!-- wp:column -->
2417- <div class="wp-block-column"><!-- wp:post-navigation-link {"textAlign":"right","label":"→","showTitle":true} /--></div>
2418- <!-- /wp:column --></div>
2419- <!-- /wp:columns -->
2420-
2421- <!-- wp:post-comments /--></div>
2422- <!-- /wp:group -->
2423- EOT;
2424- $ this ->assertEquals (
2425- $ expected ,
2426- Util::grunion_contact_form_apply_block_attribute ( $ original , array ( 'foo ' => 'bar ' ) )
2427- );
2428-
2429- // Check that the function return null if the function gets null.
2430- $ this ->assertNull (
2431- // @phan-suppress-next-line PhanTypeMismatchArgumentProbablyReal
2432- Util::grunion_contact_form_apply_block_attribute ( null , array ( 'foo ' => 'bar ' ) )
2433- );
2434-
2435- // Check that the function returns an array if the function gets an empty array.
2436- $ this ->assertEquals (
2437- array (), // @phan-suppress-next-line PhanTypeMismatchArgumentProbablyReal
2438- Util::grunion_contact_form_apply_block_attribute ( array (), array ( 'foo ' => 'bar ' ) )
2439- );
2440- }
24412251 /**
24422252 * Helper function that tracks the ids of the feedbacks that got created.
24432253 */
0 commit comments