forked from WordPress/wordpress-develop
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjquery.php
More file actions
72 lines (63 loc) · 2.49 KB
/
Copy pathjquery.php
File metadata and controls
72 lines (63 loc) · 2.49 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
<?php
/**
* @group dependencies
* @group scripts
*/
class Tests_Dependencies_jQuery extends WP_UnitTestCase {
function test_location_of_jquery() {
$scripts = new WP_Scripts;
wp_default_scripts( $scripts );
$jquery_scripts = array(
'jquery-core' => '/wp-includes/js/jquery/jquery.js',
);
if ( SCRIPT_DEBUG )
$jquery_scripts['jquery-migrate'] = '/wp-includes/js/jquery/jquery-migrate.js';
else
$jquery_scripts['jquery-migrate'] = '/wp-includes/js/jquery/jquery-migrate.min.js';
$object = $scripts->query( 'jquery', 'registered' );
$this->assertInstanceOf( '_WP_Dependency', $object );
$this->assertEqualSets( $object->deps, array_keys( $jquery_scripts ) );
foreach( $object->deps as $dep ) {
$o = $scripts->query( $dep, 'registered' );
$this->assertInstanceOf( '_WP_Dependency', $object );
$this->assertTrue( isset( $jquery_scripts[ $dep ] ) );
$this->assertEquals( $jquery_scripts[ $dep ], $o->src );
}
}
function test_presence_of_jquery_no_conflict() {
$contents = trim( file_get_contents( ABSPATH . WPINC . '/js/jquery/jquery.js' ) );
$noconflict = 'jQuery.noConflict();';
$end = substr( $contents, - strlen( $noconflict ) );
$this->assertEquals( $noconflict, $end );
}
/**
* @ticket 22896
*
* @expectedIncorrectUsage wp_deregister_script
*/
function test_dont_allow_deregister_core_scripts_in_admin() {
set_current_screen( 'edit.php' );
$this->assertTrue( is_admin() ) ;
$libraries = array(
'jquery', 'jquery-core', 'jquery-migrate', 'jquery-ui-core', 'jquery-ui-accordion',
'jquery-ui-autocomplete', 'jquery-ui-button', 'jquery-ui-datepicker', 'jquery-ui-dialog',
'jquery-ui-draggable', 'jquery-ui-droppable', 'jquery-ui-menu', 'jquery-ui-mouse',
'jquery-ui-position', 'jquery-ui-progressbar', 'jquery-ui-resizable', 'jquery-ui-selectable',
'jquery-ui-slider', 'jquery-ui-sortable', 'jquery-ui-spinner', 'jquery-ui-tabs',
'jquery-ui-tooltip', 'jquery-ui-widget', 'backbone', 'underscore',
);
foreach ( $libraries as $library ) {
// Try to deregister the script, which should fail.
wp_deregister_script( $library );
$this->assertTrue( wp_script_is( $library, 'registered' ) );
}
set_current_screen( 'front' );
}
/**
* @ticket 24994
*/
function test_exclusion_of_sourcemaps() {
$contents = trim( file_get_contents( ABSPATH . WPINC . '/js/jquery/jquery.js' ) );
$this->assertFalse( strpos( $contents, 'sourceMappingURL' ), 'Presence of sourceMappingURL' );
}
}