';
$expected_single_product_template = '
';
$result = SingleProductTemplate::add_password_form(
$default_single_product_template
);
$result_without_withespace = preg_replace( '/\s+/', '', $result );
$expected_single_product_template_without_whitespace = preg_replace(
'/\s+/',
'',
$expected_single_product_template
);
$this->assertEquals(
$result_without_withespace,
$expected_single_product_template_without_whitespace,
''
);
}
/**
* Test that the password form is added to the Single Product Template.
*/
public function test_replace_single_product_blocks_with_input_form() {
$default_single_product_template = '
';
$expected_single_product_template = sprintf(
'
%s
',
get_the_password_form()
);
$result = SingleProductTemplate::add_password_form(
$default_single_product_template
);
$result_without_withespace = preg_replace( '/\s+/', '', $result );
$result_without_withespace_without_custom_pwbox_ids = preg_replace(
'/pwbox-\d+/',
'',
$result_without_withespace
);
$expected_single_product_template_without_whitespace = preg_replace(
'/\s+/',
'',
$expected_single_product_template
);
$expected_single_product_template_without_whitespace_without_custom_pwbox_ids = preg_replace(
'/pwbox-\d+/',
'',
$expected_single_product_template_without_whitespace
);
$this->assertEquals(
$result_without_withespace_without_custom_pwbox_ids,
$expected_single_product_template_without_whitespace_without_custom_pwbox_ids,
''
);
}
/**
* Test that the password form is added to the Single Product Template with the default template.
*/
public function test_replace_default_template_single_product_blocks_with_input_form() {
$default_single_product_template = '
';
$expected_single_product_template = sprintf(
'
',
get_the_password_form()
);
$result = SingleProductTemplate::add_password_form(
$default_single_product_template
);
$result_without_withespace = preg_replace( '/\s+/', '', $result );
$result_without_withespace_without_custom_pwbox_ids = preg_replace(
'/pwbox-\d+/',
'',
$result_without_withespace
);
$expected_single_product_template_without_whitespace = preg_replace(
'/\s+/',
'',
$expected_single_product_template
);
$expected_single_product_template_without_whitespace_without_custom_pwbox_ids = preg_replace(
'/pwbox-\d+/',
'',
$expected_single_product_template_without_whitespace
);
$this->assertEquals(
$result_without_withespace_without_custom_pwbox_ids,
$expected_single_product_template_without_whitespace_without_custom_pwbox_ids,
''
);
}
}