From 8140a4016ff91ca9d42f402f73ba401dea3130aa Mon Sep 17 00:00:00 2001 From: Ryan Kienstra Date: Sun, 11 Feb 2018 14:34:51 -0600 Subject: [PATCH] Issue #841: Remove dependence on test files. Before, test_shortcode() used test files from Core. But these did not exist in 4.7, and caused a failure. So create new mock files to test. --- .../test-class-amp-playlist-embed-handler.php | 27 ++++++++++++++----- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/tests/test-class-amp-playlist-embed-handler.php b/tests/test-class-amp-playlist-embed-handler.php index e610ce940f3..d21f4c6f810 100644 --- a/tests/test-class-amp-playlist-embed-handler.php +++ b/tests/test-class-amp-playlist-embed-handler.php @@ -65,17 +65,29 @@ public function test_unregister_embed() { /** * Test shortcode. * - * Logic for creating the upload object copied from Tests_Media. + * Logic for creating the videos copied from Tests_Media. * * @covers AMP_Playlist_Embed_Handler::shortcode() */ public function test_shortcode() { - $id_mp4 = $this->factory->attachment->create_upload_object( DIR_TESTDATA . '/uploads/small-video.mp4' ); - $id_mkv = $this->factory->attachment->create_upload_object( DIR_TESTDATA . '/uploads/small-video.mkv' ); - $ids = array( - $id_mp4, - $id_mkv, + $file_1 = 'example-video-1.mp4'; + $file_2 = 'example-video-2.mkv'; + $files = array( + $file_1, + $file_2, ); + + $ids = array(); + foreach ( $files as $file ) { + $ids[] = $this->factory()->attachment->create_object( + $file, + 0, + array( + 'post_mime_type' => 'video/mp4', + 'post_type' => 'attachment', + ) + ); + } $attr = array( 'ids' => implode( ',', $ids ), 'type' => 'video', @@ -83,7 +95,8 @@ public function test_shortcode() { $playlist = $this->instance->shortcode( $attr ); $this->assertContains( 'assertContains( 'assertContains( 'small-video', $playlist ); + $this->assertContains( $file_1, $playlist ); + $this->assertContains( $file_2, $playlist ); $this->assertContains( '[src]="playlist0[playlist0.currentVideo].videoUrl"', $playlist ); $this->assertContains( 'on="tap:AMP.setState({playlist0: {currentVideo: 0}})"', $playlist ); }