';
$expected_single_product_template = '
';
$result = SingleProductTemplateCompatibility::add_compatibility_layer( $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 Single Product Template is wrapped in a div with the correct class if it contains a block related to the Single Product Template.
*/
public function test_add_compatibility_layer_if_contains_single_product_blocks() {
$default_single_product_template = '
';
$expected_single_product_template = '
';
$result = SingleProductTemplateCompatibility::add_compatibility_layer( $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 Single Product Template is wrapped in a div with the correct class if it contains a block related to the Single Product Template in a nested structure.
*/
public function test_add_compatibility_layer_if_contains_nested_single_product_blocks() {
$default_single_product_template = '
';
$expected_single_product_template = '
';
$result = SingleProductTemplateCompatibility::add_compatibility_layer( $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 Single Product Template is wrapped in a div with the correct class if it contains a block related to the Single Product Template in a nested structure.
*/
public function test_add_compatibility_layer_without_a_main_wrapper() {
$default_single_product_template = '
';
$expected_single_product_template = '
';
$result = SingleProductTemplateCompatibility::add_compatibility_layer( $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 Single Product Template is wrapped in a div with the correct class if it contains a block related to the Single Product Template.
*/
public function test_add_compatibility_layer_with_multiple_header() {
$default_single_product_template = '
';
$expected_single_product_template = '
';
$result = SingleProductTemplateCompatibility::add_compatibility_layer( $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 Single Product Template is wrapped in a div with the correct class if it contains a block related to the Single Product Template.
*/
public function test_add_compatibility_layer_with_multiple_footer() {
$default_single_product_template = '
';
$expected_single_product_template = '
';
$result = SingleProductTemplateCompatibility::add_compatibility_layer( $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 Single Product Template is wrapped in a div with the correct class if it contains a block related to the Single Product Template.
*/
public function test_add_compatibility_layer_with_multiple_blocks_related_to_the_single_product_template() {
$default_single_product_template = '
test
';
$expected_single_product_template = '
test
';
$result = SingleProductTemplateCompatibility::add_compatibility_layer( $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 Single Product Template is wrapped in a div with the correct class if it contains a block related to the Single Product Template and custom HTML isn't removed.
*/
public function test_add_compatibility_layer_if_contains_single_product_blocks_and_custom_HTML_not_removed() {
$default_single_product_template = '
Custom HTML
';
$expected_single_product_template = '
Custom HTML
';
$result = SingleProductTemplateCompatibility::add_compatibility_layer( $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, '' );
}
/**
* @group failing
* Test that the Single Product Template doesn't remove any blocks if those aren't grouped in a a core/group block
*/
public function test_add_compatibility_layer_if_contains_blocks_not_related_to_the_single_product_template_and_not_grouped() {
$default_single_product_template = '
hello
hello1
hello2
';
$expected_single_product_template = '
hello
hello1
hello2
';
$result = SingleProductTemplateCompatibility::add_compatibility_layer( $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, '' );
}
}