Skip to content

Commit

Permalink
Update tests to match 1bfc3e6
Browse files Browse the repository at this point in the history
  • Loading branch information
jeherve committed Nov 7, 2019
1 parent 1bfc3e6 commit d0fac0c
Showing 1 changed file with 5 additions and 55 deletions.
60 changes: 5 additions & 55 deletions tests/php/modules/shortcodes/test-class.vimeo.php
Original file line number Diff line number Diff line change
Expand Up @@ -241,27 +241,15 @@ function test_vimeo_embed_to_shortcode_5() {
*/
public function get_vimeo_shortcode_data() {
return array(
'not_a_vimeo_shortcode' => array(
'<amp-youtube></amp-youtube>',
'youtube',
array( 'id' => '62245' ),
null,
),
'empty_attr_array' => array(
'<div>Initial shortcode</div>',
'vimeo',
array(),
null,
'<!-- vimeo error: not a vimeo video -->',
),
'no_width_or_height_in_attr' => array(
'<div>Initial shortcode</div>',
'vimeo',
array( 'id' => '24246' ),
'<amp-vimeo data-videoid="24246" layout="responsive" width="600" height="338"></amp-vimeo>'
),
'normal_attributes_present' => array(
'<div>Initial shortcode</div>',
'vimeo',
array(
'id' => '623422',
'width' => '900',
Expand All @@ -276,28 +264,19 @@ public function get_vimeo_shortcode_data() {
* Tests that the Vimeo shortcode filter produces the right HTML.
*
* @dataProvider get_vimeo_shortcode_data
* @covers ::amp_vimeo_shortcode()
*
* @param string $html The html passed to the filter.
* @param string $shortcode_tag The tag (name) of the shortcode, like 'vimeo'.
* @param array $attr The shortcode attributes.
* @param string $expected The expected return value.
*/
public function test_jetpack_amp_vimeo_shortcode( $html, $shortcode_tag, $attr, $expected ) {
public function test_jetpack_amp_vimeo_shortcode( $attr, $expected ) {
unset( $GLOBALS['content_width'] );
add_filter( 'jetpack_is_amp_request', '__return_true' );

if ( null === $expected ) {
$expected = $html;
}

$this->assertEquals( $expected, jetpack_amp_vimeo_shortcode( $html, $shortcode_tag, $attr ) );
$this->assertEquals( $expected, vimeo_shortcode( $attr ) );
}

/**
* Tests the Vimeo shortcode filter when there is a global $content_width value.
*
* @covers ::jetpack_amp_vimeo_shortcode()
* Tests the Vimeo shortcode filter in an AMP view when there is a global $content_width value.
*/
public function test_jetpack_amp_vimeo_shortcode_global_content_width() {
add_filter( 'jetpack_is_amp_request', '__return_true' );
Expand All @@ -309,36 +288,7 @@ public function test_jetpack_amp_vimeo_shortcode_global_content_width() {

$this->assertEquals(
'<amp-vimeo data-videoid="' . $video_id .'" layout="responsive" width="' . $content_width . '" height="' . $expected_height .'"></amp-vimeo>',
jetpack_amp_vimeo_shortcode(
'<div><span>Initial shortcode</span></div>',
'vimeo',
array(
'id' => $video_id,
)
)
);
}

/**
* Tests that the Vimeo shortcode filter does not filter the markup on non-AMP endpoints.
*
* @covers ::jetpack_amp_vimeo_shortcode()
*/
public function test_jetpack_amp_vimeo_shortcode_non_amp() {
add_filter( 'jetpack_is_amp_request', '__return_false' );
$initial_shortcode_markup = '<div><span>Shortcode here</span></div>';

$this->assertEquals(
$initial_shortcode_markup,
jetpack_amp_vimeo_shortcode(
$initial_shortcode_markup,
'vimeo',
array(
'id' => '624432',
'width' => '800',
'height' => '400',
)
)
vimeo_shortcode( array( 'id' => $video_id ) )
);
}

Expand Down

0 comments on commit d0fac0c

Please sign in to comment.