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

/**
 * Class AMP_Vimeo_Embed_Test
 *
 * @covers AMP_Vimeo_Embed_Handler
 */
class AMP_Vimeo_Embed_Test extends WP_UnitTestCase {

	/**
	 * Get conversion data.
	 *
	 * @return array
	 */
	public function get_conversion_data() {
		return [
			'no_embed'     => [
				'<p>Hello world.</p>',
				'<p>Hello world.</p>' . PHP_EOL,
			],

			'url_simple'   => [
				'https://vimeo.com/172355597' . PHP_EOL,
				'<p><amp-vimeo data-videoid="172355597" layout="responsive" width="600" height="338"></amp-vimeo></p>' . PHP_EOL,
			],

			'url_unlisted' => [
				'https://vimeo.com/172355597/<PASSWORD>123' . PHP_EOL,
				'<p><amp-vimeo data-videoid="172355597" layout="responsive" width="600" height="338"></amp-vimeo></p>' . PHP_EOL,
			],
		];
	}

	/**
	 * Test conversion.
	 *
	 * @dataProvider get_conversion_data
	 *
	 * @param string $source   Source.
	 * @param string $expected Expected.
	 */
	public function test__conversion( $source, $expected ) {
		$embed = new AMP_Vimeo_Embed_Handler();
		$embed->register_embed();
		$filtered_content = apply_filters( 'the_content', $source );

		$this->assertEquals( $expected, $filtered_content );
	}

	/**
	 * Get scripts data.
	 *
	 * @return array Scripts data.
	 */
	public function get_scripts_data() {
		return [
			'not_converted' => [
				'<p>Hello World.</p>',
				[],
			],
			'converted'     => [
				'https://vimeo.com/172355597' . PHP_EOL,
				[ 'amp-vimeo' => true ],
			],
		];
	}

	/**
	 * Test get_scripts().
	 *
	 * @dataProvider get_scripts_data
	 * @covers AMP_Vimeo_Embed_Handler::get_scripts()
	 *
	 * @param string $source   Source.
	 * @param string $expected Expected.
	 */
	public function test__get_scripts( $source, $expected ) {
		$embed = new AMP_Vimeo_Embed_Handler();
		$embed->register_embed();
		$source = apply_filters( 'the_content', $source );

		$whitelist_sanitizer = new AMP_Tag_And_Attribute_Sanitizer( AMP_DOM_Utils::get_dom_from_content( $source ) );
		$whitelist_sanitizer->sanitize();

		$scripts = array_merge(
			$embed->get_scripts(),
			$whitelist_sanitizer->get_scripts()
		);

		$this->assertEquals( $expected, $scripts );
	}

	/**
	 * Gets the test data for test_video_override().
	 *
	 * @return array The test data.
	 */
	public function get_video_override_data() {
		return [
			'no_src_empty_html'    => [
				'',
				[ 'foo' => 'baz' ],
				null,
			],
			'no_src_with_html'     => [
				'Initial HTML here',
				[ 'foo' => 'baz' ],
				null,
			],
			'non_vimeo_src'        => [
				'Initial HTML here',
				[ 'src' => 'https://youtube.com/1234567' ],
				null,
			],
			'non_numeric_video_id' => [
				'Initial HTML here',
				[ 'src' => 'https://vimeo.com/abcdefg' ],
				'',
			],
			'valid_video_id'       => [
				'Initial HTML here',
				[ 'src' => 'https://vimeo.com/1234567' ],
				'<amp-vimeo data-videoid="1234567" layout="responsive" width="600" height="338"></amp-vimeo>',
			],
			'http_url'             => [
				'Initial HTML here',
				[ 'src' => 'https://vimeo.com/1234567' ],
				'<amp-vimeo data-videoid="1234567" layout="responsive" width="600" height="338"></amp-vimeo>',
			],
		];
	}

	/**
	 * Test video_override().
	 *
	 * @dataProvider get_video_override_data
	 * @covers AMP_Vimeo_Embed_Handler::test_video_override()
	 *
	 * @param string $html The initial HTML.
	 * @param array  $attr The attributes of the shortcode.
	 * @param string $expected Expected.
	 */
	public function test_video_override( $html, $attr, $expected ) {
		if ( null === $expected ) {
			$expected = $html;
		}

		$embed = new AMP_Vimeo_Embed_Handler();
		$this->assertEquals( $expected, $embed->video_override( $html, $attr ) );
	}
}<commit_msg>Align @param descriptions in test_video_override<commit_after><?php
/**
 * Class AMP_Vimeo_Embed_Test
 *
 * @package AMP
 */

/**
 * Class AMP_Vimeo_Embed_Test
 *
 * @covers AMP_Vimeo_Embed_Handler
 */
class AMP_Vimeo_Embed_Test extends WP_UnitTestCase {

	/**
	 * Get conversion data.
	 *
	 * @return array
	 */
	public function get_conversion_data() {
		return [
			'no_embed'     => [
				'<p>Hello world.</p>',
				'<p>Hello world.</p>' . PHP_EOL,
			],

			'url_simple'   => [
				'https://vimeo.com/172355597' . PHP_EOL,
				'<p><amp-vimeo data-videoid="172355597" layout="responsive" width="600" height="338"></amp-vimeo></p>' . PHP_EOL,
			],

			'url_unlisted' => [
				'https://vimeo.com/172355597/<PASSWORD>0123' . PHP_EOL,
				'<p><amp-vimeo data-videoid="172355597" layout="responsive" width="600" height="338"></amp-vimeo></p>' . PHP_EOL,
			],
		];
	}

	/**
	 * Test conversion.
	 *
	 * @dataProvider get_conversion_data
	 *
	 * @param string $source   Source.
	 * @param string $expected Expected.
	 */
	public function test__conversion( $source, $expected ) {
		$embed = new AMP_Vimeo_Embed_Handler();
		$embed->register_embed();
		$filtered_content = apply_filters( 'the_content', $source );

		$this->assertEquals( $expected, $filtered_content );
	}

	/**
	 * Get scripts data.
	 *
	 * @return array Scripts data.
	 */
	public function get_scripts_data() {
		return [
			'not_converted' => [
				'<p>Hello World.</p>',
				[],
			],
			'converted'     => [
				'https://vimeo.com/172355597' . PHP_EOL,
				[ 'amp-vimeo' => true ],
			],
		];
	}

	/**
	 * Test get_scripts().
	 *
	 * @dataProvider get_scripts_data
	 * @covers AMP_Vimeo_Embed_Handler::get_scripts()
	 *
	 * @param string $source   Source.
	 * @param string $expected Expected.
	 */
	public function test__get_scripts( $source, $expected ) {
		$embed = new AMP_Vimeo_Embed_Handler();
		$embed->register_embed();
		$source = apply_filters( 'the_content', $source );

		$whitelist_sanitizer = new AMP_Tag_And_Attribute_Sanitizer( AMP_DOM_Utils::get_dom_from_content( $source ) );
		$whitelist_sanitizer->sanitize();

		$scripts = array_merge(
			$embed->get_scripts(),
			$whitelist_sanitizer->get_scripts()
		);

		$this->assertEquals( $expected, $scripts );
	}

	/**
	 * Gets the test data for test_video_override().
	 *
	 * @return array The test data.
	 */
	public function get_video_override_data() {
		return [
			'no_src_empty_html'    => [
				'',
				[ 'foo' => 'baz' ],
				null,
			],
			'no_src_with_html'     => [
				'Initial HTML here',
				[ 'foo' => 'baz' ],
				null,
			],
			'non_vimeo_src'        => [
				'Initial HTML here',
				[ 'src' => 'https://youtube.com/1234567' ],
				null,
			],
			'non_numeric_video_id' => [
				'Initial HTML here',
				[ 'src' => 'https://vimeo.com/abcdefg' ],
				'',
			],
			'valid_video_id'       => [
				'Initial HTML here',
				[ 'src' => 'https://vimeo.com/1234567' ],
				'<amp-vimeo data-videoid="1234567" layout="responsive" width="600" height="338"></amp-vimeo>',
			],
			'http_url'             => [
				'Initial HTML here',
				[ 'src' => 'https://vimeo.com/1234567' ],
				'<amp-vimeo data-videoid="1234567" layout="responsive" width="600" height="338"></amp-vimeo>',
			],
		];
	}

	/**
	 * Test video_override().
	 *
	 * @dataProvider get_video_override_data
	 * @covers AMP_Vimeo_Embed_Handler::test_video_override()
	 *
	 * @param string $html     The initial HTML.
	 * @param array  $attr     The attributes of the shortcode.
	 * @param string $expected The expected return value.
	 */
	public function test_video_override( $html, $attr, $expected ) {
		if ( null === $expected ) {
			$expected = $html;
		}

		$embed = new AMP_Vimeo_Embed_Handler();
		$this->assertEquals( $expected, $embed->video_override( $html, $attr ) );
	}
}
{'fraction_non_alphanumeric': 0.17347889761682866, 'fraction_numerical': 0.02862468379709759, 'mean_word_length': 3.2013422818791946, 'pattern_counts': {'":': 0, '<': 43, '<?xml version=': 0, '>': 95, 'https://': 14, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4380247', 'n_tokens_mistral': 3325, 'n_tokens_neox': 2726, 'n_words': 481}