Skip to content

Commit

Permalink
fix tests?
Browse files Browse the repository at this point in the history
  • Loading branch information
nextgenthemes committed Oct 13, 2018
1 parent dbbbec3 commit 8cf70ce
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 35 deletions.
2 changes: 1 addition & 1 deletion tests/bootstrap.php
Expand Up @@ -26,7 +26,7 @@ function ci_manually_load_plugin() {

activate_plugin( 'advanced-responsive-video-embedder/advanced-responsive-video-embedder.php' );

$GLOBALS['current_user'] = new WP_User( 1);
$GLOBALS['current_user'] = new WP_User( 1 );
$GLOBALS['current_user']->set_role( 'administrator');
wp_update_user( array(
'ID' => 1,
Expand Down
70 changes: 36 additions & 34 deletions tests/tests-shortcodes.php
@@ -1,4 +1,6 @@
<?php
use function Nextenthemes\ARVE\shortcode;

// phpcs:disable Squiz.Classes.ClassFileName.NoMatch
// phpcs:disable Squiz.Classes.ValidClassName.NotCamelCaps
class Tests_Shortcode extends WP_UnitTestCase {
Expand All @@ -13,10 +15,10 @@ public function test_sandbox() {

$attr = array( 'url' => 'https://example.com' );

$this->assertNotContains( 'Error', shortcode_arve( $attr ) );
$this->assertNotContains( 'Error', shortcode( $attr ) );
$this->assertNotContains(
'sandbox="',
arve_shortcode_arve( $attr ),
shortcode( $attr ),
$attr['url']
);
}
Expand All @@ -27,10 +29,10 @@ public function test_sandbox2() {
'disable_flash' => 'n'
);

$this->assertNotContains( 'Error', shortcode_arve( $attr ) );
$this->assertNotContains( 'Error', shortcode( $attr ) );
$this->assertContains(
'sandbox="allow-scripts allow-same-origin allow-presentation allow-popups"',
arve_shortcode_arve( $attr ),
shortcode( $attr ),
$attr['url']
);
}
Expand All @@ -40,10 +42,10 @@ public function test_sandbox3() {

$attr = array( 'url' => 'https://example.com' );

$this->assertNotContains( 'Error', shortcode_arve( $attr ) );
$this->assertNotContains( 'Error', shortcode( $attr ) );
$this->assertContains(
'sandbox="allow-scripts allow-same-origin allow-presentation allow-popups"',
arve_shortcode_arve( $attr ),
shortcode( $attr ),
$attr['url']
);
}
Expand All @@ -52,10 +54,10 @@ public function test_sandbox_vimeo() {
/*
$attr = array( 'url' => 'https://vimeo.com/214300845' );
$this->assertNotContains( 'Error', shortcode_arve( $attr ) );
$this->assertNotContains( 'Error', shortcode( $attr ) );
$this->assertContains(
'sandbox="allow-scripts allow-same-origin allow-presentation allow-popups allow-forms"',
arve_shortcode_arve( $attr ),
shortcode( $attr ),
$attr['url']
);
*/
Expand All @@ -78,10 +80,10 @@ public function test_thumbnails() {
'title' => 'Something',
);

$this->assertRegExp( '#<meta itemprop="thumbnailUrl" content=".*test-attachment\.jpg#', shortcode_arve( $attr ) );
$this->assertRegExp( '#<meta itemprop="thumbnailUrl" content=".*test-attachment\.jpg#', shortcode( $attr ) );

$attr['thumbnail'] = 'https://example.com/image.jpg';
$this->assertContains( '<meta itemprop="thumbnailUrl" content="https://example.com/image.jpg"', shortcode_arve( $attr ) );
$this->assertContains( '<meta itemprop="thumbnailUrl" content="https://example.com/image.jpg"', shortcode( $attr ) );
}

public function test_shortcodes_are_registered() {
Expand All @@ -104,8 +106,8 @@ public function old_test_compare_shortcodes() {
$old_atts = $atts;

$this->assertEquals(
arve_shortcode_arve( $old_atts, null, false ),
arve_shortcode_arve( $new_atts )
shortcode( $old_atts ),
shortcode( $new_atts )
);

unset( $old_atts['url'] );
Expand All @@ -114,14 +116,14 @@ public function old_test_compare_shortcodes() {
unset( $new_atts['provider'] );

$this->assertEquals(
arve_shortcode_arve( $old_atts, null, false ),
arve_shortcode_arve( $new_atts )
shortcode( $old_atts ),
shortcode( $new_atts )
);
}

public function NO_test_modes() {

$output = shortcode_arve( array( 'url' => 'https://www.youtube.com/watch?v=hRonZ4wP8Ys' ) );
$output = shortcode( array( 'url' => 'https://www.youtube.com/watch?v=hRonZ4wP8Ys' ) );

$this->assertNotContains( 'Error', $output );
$this->assertContains( 'data-mode="normal"', $output );
Expand All @@ -130,7 +132,7 @@ public function NO_test_modes() {

foreach ( $modes as $key => $mode ) {

$output = shortcode_arve( array(
$output = shortcode( array(
'url' => 'https://www.youtube.com/watch?v=hRonZ4wP8Ys',
'mode' => $mode
) );
Expand All @@ -152,7 +154,7 @@ public function test_attr() {
'url' => 'https://example.com',
);

$output = shortcode_arve( $atts );
$output = shortcode( $atts );

$this->assertNotContains( 'Error', $output );

Expand All @@ -172,8 +174,8 @@ public function test_html5() {

foreach ( $html5_ext as $ext ) {

$with_src = shortcode_arve( array( 'url' => 'https://example.com/video.' . $ext ) );
$with_ext = shortcode_arve( array( $ext => 'https://example.com/video.' . $ext ) );
$with_src = shortcode( array( 'url' => 'https://example.com/video.' . $ext ) );
$with_ext = shortcode( array( $ext => 'https://example.com/video.' . $ext ) );

$this->assertNotContains( 'Error', $with_src );
$this->assertNotContains( 'Error', $with_ext );
Expand All @@ -192,9 +194,9 @@ public function test_html5() {
'controlslist' => 'nofullscreen whatever',
);

$this->assertContains( 'controlslist="nofullscreen whatever"', shortcode_arve( $attr ) );
$this->assertContains( 'controlslist="nofullscreen whatever"', shortcode( $attr ) );

$output = shortcode_arve( array(
$output = shortcode( array(
'mp4' => 'https://example.com/video.mp4',
'ogv' => 'https://example.com/video.ogv',
'webm' => 'https://example.com/video.webm',
Expand Down Expand Up @@ -229,7 +231,7 @@ public function test_html5() {

public function test_iframe() {

$output = shortcode_arve( array( 'url' => 'https://example.com' ) );
$output = shortcode( array( 'url' => 'https://example.com' ) );

$this->assertNotContains( 'Error', $output );
$this->assertRegExp( '#<iframe .*src="https://example\.com#', $output );
Expand Down Expand Up @@ -305,7 +307,7 @@ public function regex2() {

$this->$current_test;

shortcode_arve( array(
shortcode( array(
'url' => $test['url']
) );
}
Expand All @@ -320,26 +322,26 @@ public function check_regex_detection( $atts ) {
public function test_disable_flash() {

$attr = array( 'url' => 'https://example.com' );
$this->assertNotContains( 'Error', shortcode_arve( $attr) );
$this->assertRegExp( '#<iframe .*src="https://example\.com#', shortcode_arve( $attr) );
$this->assertContains( 'data-provider="iframe"', shortcode_arve( $attr ) );
$this->assertNotContains( 'sandbox="', shortcode_arve( $attr ) );
$this->assertNotContains( 'Error', shortcode( $attr) );
$this->assertRegExp( '#<iframe .*src="https://example\.com#', shortcode( $attr) );
$this->assertContains( 'data-provider="iframe"', shortcode( $attr ) );
$this->assertNotContains( 'sandbox="', shortcode( $attr ) );

$attr['disable_flash'] = 'y';

$this->assertNotContains( 'Error', shortcode_arve( $attr) );
$this->assertRegExp( '#<iframe .*src="https://example\.com#', shortcode_arve( $attr) );
$this->assertContains( 'data-provider="iframe"', shortcode_arve( $attr ) );
$this->assertContains( 'sandbox="', shortcode_arve( $attr ) );
$this->assertNotContains( 'Error', shortcode( $attr) );
$this->assertRegExp( '#<iframe .*src="https://example\.com#', shortcode( $attr) );
$this->assertContains( 'data-provider="iframe"', shortcode( $attr ) );
$this->assertContains( 'sandbox="', shortcode( $attr ) );
}

public function test_dropbox_html5() {

$attr = array( 'url' => 'https://www.dropbox.com/s/ocqf9u5pn9b4ox0/Oops%20I%20dropped%20my%20Hoop.mp4' );

$this->assertNotContains( 'Error', shortcode_arve( $attr) );
$this->assertNotContains( 'Error', shortcode( $attr) );

$this->assertRegExp( '#<video .*src="https://www\.dropbox\.com/s/ocqf9u5pn9b4ox0/Oops%20I%20dropped%20my%20Hoop\.mp4\?dl=1#', shortcode_arve( $attr) );
$this->assertContains( 'data-provider="html5"', shortcode_arve( $attr ) );
$this->assertRegExp( '#<video .*src="https://www\.dropbox\.com/s/ocqf9u5pn9b4ox0/Oops%20I%20dropped%20my%20Hoop\.mp4\?dl=1#', shortcode( $attr) );
$this->assertContains( 'data-provider="html5"', shortcode( $attr ) );
}
}

0 comments on commit 8cf70ce

Please sign in to comment.