<commit_before><?php
/**
 * Class AMP_Base_Sanitizer_Test
 *
 * @package AMP
 */

use Amp\AmpWP\Dom\Document;

/**
 * Test AMP_Base_Sanitizer_Test
 *
 * @covers AMP_Base_Sanitizer
 */
class AMP_Base_Sanitizer_Test extends WP_UnitTestCase {

	/**
	 * Set up.
	 */
	public function setUp() {
		parent::setUp();
		AMP_Validation_Manager::reset_validation_results();
	}

	/**
	 * Tear down.
	 */
	public function tearDown() {
		parent::tearDown();
		AMP_Validation_Manager::reset_validation_results();
		AMP_Validation_Manager::$is_validate_request = false;
	}

	/**
	 * Gets data for test_set_layout().
	 *
	 * @return array
	 */
	public function get_data() {
		return [
			'both_dimensions_included'                   => [
				[
					'width'  => 100,
					'height' => 100,
					'layout' => 'responsive',
				],
				[
					'width'  => 100,
					'height' => 100,
					'layout' => 'responsive',
				],
			],

			'both_dimensions_missing'                    => [
				[],
				[
					'height' => 400,
					'layout' => 'fixed-height',
					'width'  => 'auto',
				],
			],

			'both_dimensions_empty'                      => [
				[
					'width'  => '',
					'height' => '',
				],
				[
					'height' => 400,
					'layout' => 'fixed-height',
					'width'  => 'auto',
				],
			],

			'no_width'                                   => [
				[
					'height' => 100,
				],
				[
					'height' => 100,
					'layout' => 'fixed-height',
					'width'  => 'auto',
				],
			],

			'no_height'                                  => [
				[
					'width' => 200,
				],
				[
					'height' => 400,
					'layout' => 'fixed-height',
					'width'  => 'auto',
				],
			],

			'no_layout_specified'                        => [
				[
					'width'  => 100,
					'height' => 100,
				],
				[
					'width'  => 100,
					'height' => 100,
				],
			],

			'fill_with_bottom_right_removes_empty_style' => [
				[
					'style' => 'position:absolute;top:0;left:0;right:0;bottom:0',
				],
				[
					'layout' => 'fill',
				],
			],

			'fill_100p_dimensions_and_absolute_position' => [
				[
					'style'  => 'position:absolute;top:0;left:0;right:0;bottom:0',
					'width'  => '100%',
					'height' => '100%',
				],
				[
					'layout' => 'fill',
				],
			],

			'fill_both_dimensions_and_absolute_position' => [
				[
					'width'  => '100%',
					'height' => '100%',
					'style'  => 'position:absolute',
				],
				[
					'layout' => 'fill',
				],
			],

			'fill_with_bottom_right_keeps_unrelated_styles' => [
				[
					'style' => 'position:absolute;background-color:white;top:0;left:0;right:0;bottom:0;color:red;',
				],
				[
					'layout' => 'fill',
					'style'  => 'background-color:white;color:red',
				],
			],

			'fill_with_width_height_removes_empty_style' => [
				[
					'style' => 'position:absolute;top:0;left:0;width:100%;height:100%',
				],
				[
					'layout' => 'fill',
				],
			],

			'fill_with_width_height_keeps_unrelated_styles' => [
				[
					'style' => 'position:absolute;background-color:white;top:0;left:0;width:100%;height:100%;color:red;',
				],
				[
					'layout' => 'fill',
					'style'  => 'background-color:white;color:red',
				],<commit_msg>Add test for verifying style attribute being maintained when setting layout<commit_after><?php
/**
 * Class AMP_Base_Sanitizer_Test
 *
 * @package AMP
 */

use Amp\AmpWP\Dom\Document;

/**
 * Test AMP_Base_Sanitizer_Test
 *
 * @covers AMP_Base_Sanitizer
 */
class AMP_Base_Sanitizer_Test extends WP_UnitTestCase {

	/**
	 * Set up.
	 */
	public function setUp() {
		parent::setUp();
		AMP_Validation_Manager::reset_validation_results();
	}

	/**
	 * Tear down.
	 */
	public function tearDown() {
		parent::tearDown();
		AMP_Validation_Manager::reset_validation_results();
		AMP_Validation_Manager::$is_validate_request = false;
	}

	/**
	 * Gets data for test_set_layout().
	 *
	 * @return array
	 */
	public function get_data() {
		return [
			'both_dimensions_included'                   => [
				[
					'width'  => 100,
					'height' => 100,
					'layout' => 'responsive',
				],
				[
					'width'  => 100,
					'height' => 100,
					'layout' => 'responsive',
				],
			],

			'both_dimensions_missing'                    => [
				[],
				[
					'height' => 400,
					'layout' => 'fixed-height',
					'width'  => 'auto',
				],
			],

			'both_dimensions_empty'                      => [
				[
					'width'  => '',
					'height' => '',
				],
				[
					'height' => 400,
					'layout' => 'fixed-height',
					'width'  => 'auto',
				],
			],

			'no_width'                                   => [
				[
					'height' => 100,
				],
				[
					'height' => 100,
					'layout' => 'fixed-height',
					'width'  => 'auto',
				],
			],

			'no_height'                                  => [
				[
					'width' => 200,
				],
				[
					'height' => 400,
					'layout' => 'fixed-height',
					'width'  => 'auto',
				],
			],

			'no_layout_specified'                        => [
				[
					'width'  => 100,
					'height' => 100,
				],
				[
					'width'  => 100,
					'height' => 100,
				],
			],

			'fill_with_bottom_right_removes_empty_style' => [
				[
					'style' => 'position:absolute;top:0;left:0;right:0;bottom:0',
				],
				[
					'layout' => 'fill',
				],
			],

			'fill_100p_dimensions_and_absolute_position' => [
				[
					'style'  => 'position:absolute;top:0;left:0;right:0;bottom:0',
					'width'  => '100%',
					'height' => '100%',
				],
				[
					'layout' => 'fill',
				],
			],

			'fill_both_dimensions_and_absolute_position' => [
				[
					'width'  => '100%',
					'height' => '100%',
					'style'  => 'position:absolute',
				],
				[
					'layout' => 'fill',
				],
			],

			'fill_both_dimensions_with_unrelated_style'  => [
				[
					'width'  => '100%',
					'height' => '100%',
					'style'  => 'position:absolute; color:red',
				],
				[
					'layout' => 'fill',
					'style'  => 'color:red',
				],
			],

			'fill_with_bottom_right_keeps_unrelated_styles' => [
				[
					'style' => 'position:absolute;background-color:white;top:0;left:0;right:0;bottom:0;color:red;',
				],
				[
					'layout' => 'fill',
					'style'  => 'background-color:white;color:red',
				],
			],

			'fill_with_width_height_removes_empty_style' => [
				[
					'style' => 'position:absolute;top:0;left:0;width:100%;height:100%',
				],
				[
					'layout' => 'fill',
				],
			],

			'fill_with_width_height_keeps_unrelated_styles' => [
				[
					'style' => 'position:absolute;background-color:white;top:0;left:0;width:100%;height:100%;color:red;',
				],
				[
					'layout' => 'fill',
					'style'  => 'background-color:white;color:red',
				],
{'fraction_non_alphanumeric': 0.19038984587488667, 'fraction_numerical': 0.02659413720157147, 'mean_word_length': 2.1148235294117645, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 121, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2129800', 'n_tokens_mistral': 3346, 'n_tokens_neox': 2377, 'n_words': 300}