40 lines
1.1 KiB
PHP
40 lines
1.1 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
require_once dirname(__DIR__, 2) . '/feca_mailshots_plugin/src/autoload.php';
|
|
|
|
use FecaMailshots\WordPress\ProductionWordPressFacade;
|
|
|
|
if (!function_exists('wp_unslash')) {
|
|
/**
|
|
* Minimal test shim for wp_unslash behavior used by the facade.
|
|
* @param mixed $value
|
|
* @return mixed
|
|
*/
|
|
function wp_unslash($value)
|
|
{
|
|
if (is_array($value)) {
|
|
return array_map('wp_unslash', $value);
|
|
}
|
|
return stripslashes((string) $value);
|
|
}
|
|
}
|
|
|
|
$facade = new ProductionWordPressFacade();
|
|
|
|
$input = '<p class=\"red\">For: <strong>{{ fenedgec_members_mailshot_test_name }}</strong></p>';
|
|
$_POST['Message'] = $input;
|
|
|
|
$actual = $facade->requestParam('Message', '');
|
|
$expected = '<p class="red">For: <strong>{{ fenedgec_members_mailshot_test_name }}</strong></p>';
|
|
|
|
if ($actual !== $expected) {
|
|
fwrite(STDERR, "ProductionWordPressFacade did not unslash request input correctly.\n");
|
|
fwrite(STDERR, "Expected: {$expected}\n");
|
|
fwrite(STDERR, "Actual: {$actual}\n");
|
|
exit(1);
|
|
}
|
|
|
|
echo "Production facade request unslash regression test passed\n";
|