+
HTML
,
- 'https://open.spotify.com/embed/track/2qToAcex0ruZfbEbAy9OhW',
+ 'https://open.spotify.com/track/2XKsHHNCtKqk9cF35TRFyC?si=8f5b540ce9754431',
'Spotify',
- 'Spotify Embed: M1 A1',
- ],
-
- // Gutenberg: TED embed.
- [
- <<
-HTML
- ,
- 'https://embed.ted.com/talks/jill_bolte_taylor_s_powerful_stroke_of_insight',
- 'TED',
- 'Jill Bolte Taylor: My stroke of insight',
],
// Gutenberg: TikTok embed.
[
<<
-
-
+
+
+
HTML
,
'https://www.tiktok.com/@dynamic_wallpaper/video/6778286193776938241',
'TikTok',
],
- // Gutenberg: Tumblr embed.
- [
- <<
-HTML
- ,
- 'https://embed.tumblr.com/embed/post/D5irYqe4SehhxRSSl9nZ2Q/186928288420',
- 'Tumblr',
- ],
-
- // Gutenberg: VideoPress embed.
- [
- <<
-
-
-HTML
- ,
- 'https://videopress.com/embed/bd2G0c0g?hd=0',
- 'VideoPress',
- 'Matt Mullenweg: Matt on WordPress',
- ],
-
- // Gutenberg: WordPress embed.
- [
- <<
-HTML
- ,
- 'https://en.blog.wordpress.com/2019/08/10/the-second-edition-of-our-learn-user-support-workshop-is-open-for-signups/',
- 'the original site',
- ],
-
- // Gutenberg: WordPress.tv embed.
- [
- <<
-
-
-HTML
- ,
- 'https://videopress.com/embed/DK5mLrbr?hd=0',
- 'WordPress.tv',
- ],
-
// Classic: Amazon Kindle embed.
[
<<workspace,
- $this->settings,
- $this->styles,
- $this->layouts
- );
- add_filter(
- 'apple_news_embed_generic_json',
- array( $this, 'filter_apple_news_embed_generic_json' )
- );
-
- // Test.
- $result = $component->to_array();
- $this->assertEquals(
- 'https://www.example.org/test/posts/54321',
- $result['URL']
- );
+ public function test_filter() {
+ add_filter( 'apple_news_embed_generic_json', [ $this, 'filter_apple_news_embed_generic_json' ] );
+
+ // Create a test post and get JSON for it.
+ $post_content = <<
+
+
+HTML;
+ $post_id = self::factory()->post->create( [ 'post_content' => $post_content ] );
+ $json = $this->get_json_for_post( $post_id );
+ $this->assertEquals( 'my-cool-layout', $json['components'][3]['layout'] );
// Teardown.
- remove_filter(
- 'apple_news_embed_generic_json',
- array( $this, 'filter_apple_news_embed_generic_json' )
- );
+ remove_filter( 'apple_news_embed_generic_json', [ $this, 'filter_apple_news_embed_generic_json' ] );
}
/**
@@ -630,36 +377,22 @@ public function testFilter() {
*
* @dataProvider data_transform
*
- * @param string $html The HTML to test.
- * @param string $url The expected URL associated with the embed.
- * @param string $provider The expected name of the provider associated with the embed.
- * @param string $title Optional. The title for the embed, if there is one.
- *
- * @access public
+ * @param string $post_content The post content to set for the post.
+ * @param string $url The URL of the embedded content.
+ * @param string $provider The embed provider name.
+ * @param string $title The title of the embed.
*/
- public function testTransform( $html, $url, $provider, $title = '' ) {
-
- // Setup.
- $component = new Embed_Generic(
- $html,
- $this->workspace,
- $this->settings,
- $this->styles,
- $this->layouts
- );
-
- // Ensure that the node match returns true for valid signatures.
- $node = self::build_node( $html );
- $this->assertEquals(
- $component->node_matches( $node ),
- $node
- );
+ public function test_transform( $post_content, $url = '', $provider = '', $title = '' ) {
+ // Become an administrator so we can save post_content with iframes in it.
+ $this->become_admin();
+ $post_id = self::factory()->post->create( [ 'post_content' => $post_content ] );
+ $json = $this->get_json_for_post( $post_id );
// Set up expected components result.
$components = [
[
'role' => 'body',
- 'text' => '
' . 'View on ' . $provider . '.' . '',
+ 'text' => '
View on ' . $provider . '.',
'format' => 'html',
'textStyle' => [
'fontSize' => 14,
@@ -686,7 +419,7 @@ public function testTransform( $html, $url, $provider, $title = '' ) {
'role' => 'container',
'components' => $components,
],
- $component->to_array()
+ $json['components'][3]
);
}
}
diff --git a/tests/apple-exporter/components/test-class-gallery.php b/tests/apple-exporter/components/test-class-gallery.php
index 48778005..e404607a 100644
--- a/tests/apple-exporter/components/test-class-gallery.php
+++ b/tests/apple-exporter/components/test-class-gallery.php
@@ -23,36 +23,28 @@ class Gallery_Test extends Component_TestCase {
* @return array An array of arrays representing function arguments.
*/
public function data_gallery_content() {
- // Gutenberg, standard gallery, three images.
- $standard = <<
-
-
-HTML;
+ return [
+ [
+ // Gutenberg, standard gallery, three images.
+ <<
+
+Test Caption 1
+
- // Gutenberg, Jetpack slideshow, three images.
- $jetpack = <<
+Test Caption 2
+
+
+
+Test Caption 3
+
+
+HTML
+ ],
+ [
+ // Gutenberg, Jetpack slideshow, three images.
+ <<
@@ -83,18 +75,12 @@ public function data_gallery_content() {
-HTML;
-
- // Classic editor, gallery, three images.
- $shortcode = '[gallery ids="%1$d,%4$d,%7$d"]';
-
- return [
- [ [ 'cover', 'slug', 'title', 'byline' ], $standard, 2 ],
- [ [ 'cover', 'slug', 'title', 'byline' ], $jetpack, 2 ],
- [ [ 'cover', 'slug', 'title', 'byline' ], $shortcode, 2 ],
- [ [ 'cover', 'slug', 'title', 'author', 'date' ], $standard, 3 ],
- [ [ 'cover', 'slug', 'title', 'author', 'date' ], $jetpack, 3 ],
- [ [ 'cover', 'slug', 'title', 'author', 'date' ], $shortcode, 3 ],
+HTML
+ ],
+ [
+ // Classic editor, gallery shortcode, three images.
+ '[gallery ids="%1$d,%4$d,%7$d"]',
+ ],
];
}
@@ -106,9 +92,7 @@ public function data_gallery_content() {
*
* @param string $post_content The post content to load into the example post.
*/
- public function test_component( $meta_order, $post_content, $index ) {
- $this->set_theme_settings( [ 'meta_component_order' => $meta_order ] );
-
+ public function test_component( $post_content ) {
// Create three new images for testing.
$images = [
$this->get_new_attachment( 0, 'Test Caption 1', 'Alt Text 1' ),
@@ -141,7 +125,7 @@ public function test_component( $meta_order, $post_content, $index ) {
// Get the JSON for the article and test the gallery output.
$json = $this->get_json_for_post( $post_id );
- $gallery = $json['components'][1]['components'][ $index ];
+ $gallery = $json['components'][1]['components'][3];
$this->assertEquals( 'gallery', $gallery['role'] );
$this->assertEquals( 3, count( $gallery['items'] ) );
$this->assertEquals( wp_get_attachment_image_url( $images[0] ), $gallery['items'][0]['URL'] );