• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer
WordPress develop tests

WordPress develop tests

WordPress develop tests a2z

  • Home
  • Plugins
  • Shortcodes
  • APIs
  • Classes
  • Files
  • Hooks
  • Sitemap
  • Blog
Home / APIs / Tests_Media::test_get_media_embedded_in_content() –

You appear to be a bot. Output may be restricted

Description

Usage

Tests_Media::test_get_media_embedded_in_content();

Parameters

Returns

void

Source

File name: wordpress-develop-tests/phpunit/tests/media.php


Lines:

1 to 64 of 64
  function test_get_media_embedded_in_content() {
    $object = <<<OBJ
<object src="this" data="that">
	<param name="value"/>
</object>
OBJ;
    $embed  = <<<EMBED
<embed src="something.mp4"/>
EMBED;
    $iframe = <<<IFRAME
<iframe src="youtube.com" width="7000" />
IFRAME;
    $audio  = <<<AUDIO
<audio preload="none">
	<source />
</audio>
AUDIO;
    $video  = <<<VIDEO
<video preload="none">
	<source />
</video>
VIDEO;

    $content = <<<CONTENT
This is a comment
$object

This is a comment
$embed

This is a comment
$iframe

This is a comment
$audio

This is a comment
$video

This is a comment
CONTENT;

    $types    = array( 'object', 'embed', 'iframe', 'audio', 'video' );
    $contents = array_values( compact( $types ) );

    $matches = get_media_embedded_in_content( $content, 'audio' );
    $this->assertEquals( array( $audio ), $matches );

    $matches = get_media_embedded_in_content( $content, 'video' );
    $this->assertEquals( array( $video ), $matches );

    $matches = get_media_embedded_in_content( $content, 'object' );
    $this->assertEquals( array( $object ), $matches );

    $matches = get_media_embedded_in_content( $content, 'embed' );
    $this->assertEquals( array( $embed ), $matches );

    $matches = get_media_embedded_in_content( $content, 'iframe' );
    $this->assertEquals( array( $iframe ), $matches );

    $matches = get_media_embedded_in_content( $content, $types );
    $this->assertEquals( $contents, $matches );
  }
 

 View on GitHub

Published: 26th November 2019 | Last updated: 27th November 2019

Primary Sidebar

Information

Function name: Tests_Media::test_get_media_embedded_in_content
Class ref: Tests_Media
Plugin ref: WordPress develop tests
Version: 5.3
Sourcefile: phpunit/tests/media.php
File ref: phpunit/tests/media.php
Deprecated?: No
API Letters: G,M,T

Footer

WordPress develop tests
WordPress develop tests
WordPress develop tests a2z
WordPress 5.6
WordPress a2z
WordPress core a2z
Genesis Theme Framework a2z
Jetpack a2z
WordPress develop tests
Easy Digital Downloads a2z
WooCommerce a2z
Yoast SEO a2z
WordPress Blocks

Site:  develop.wp-a2z.org
© Copyright WordPress develop tests 2014-2021. All rights reserved.


Website designed and developed by Herb Miller
Proudly powered by WordPress and oik plugins

  • Home
  • Blog
  • Sitemap
  • Sites