|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Automattic\Jetpack; |
|
4
|
|
|
|
|
5
|
|
|
use PHPUnit\Framework\TestCase; |
|
6
|
|
|
use Automattic\Jetpack\Constants as Jetpack_Constants; |
|
7
|
|
|
|
|
8
|
|
|
function plugins_url( $path, $plugin_path ) { |
|
9
|
|
|
return $plugin_path . $path; |
|
10
|
|
|
} |
|
11
|
|
|
|
|
12
|
|
|
class AssetsTest extends TestCase { |
|
13
|
|
|
public function setUp() { |
|
14
|
|
|
$plugin_file = dirname( dirname( dirname( dirname( __DIR__ ) ) ) ) . '/jetpack.php'; |
|
15
|
|
|
Jetpack_Constants::set_constant( 'JETPACK__PLUGIN_FILE', $plugin_file ); |
|
16
|
|
|
} |
|
17
|
|
|
|
|
18
|
|
|
public function tearDown() { } |
|
19
|
|
|
|
|
20
|
|
|
/** |
|
21
|
|
|
* @author ebinnion goldsounds |
|
22
|
|
|
* @dataProvider get_file_url_for_environment_data_provider |
|
23
|
|
|
*/ |
|
24
|
|
|
function test_get_file_url_for_environment( $min_path, $non_min_path, $is_script_debug, $expected, $not_expected ) { |
|
25
|
|
|
Constants::set_constant( 'SCRIPT_DEBUG', $is_script_debug ); |
|
26
|
|
|
$file_url = Assets::get_file_url_for_environment( $min_path, $non_min_path ); |
|
27
|
|
|
|
|
28
|
|
|
// note the double-$$ here, $(non_)min_path is referenced by var name |
|
29
|
|
|
$this->assertContains( $$expected, $file_url ); |
|
30
|
|
|
$this->assertNotContains( $$not_expected, $file_url ); |
|
31
|
|
|
} |
|
32
|
|
|
|
|
33
|
|
|
function get_file_url_for_environment_data_provider() { |
|
34
|
|
|
return array( |
|
35
|
|
|
'script-debug-true' => array( |
|
36
|
|
|
'_inc/build/shortcodes/js/instagram.js', |
|
37
|
|
|
'modules/shortcodes/js/instagram.js', |
|
38
|
|
|
true, |
|
39
|
|
|
'non_min_path', |
|
40
|
|
|
'min_path' |
|
41
|
|
|
), |
|
42
|
|
|
'script-debug-false' => array( |
|
43
|
|
|
'_inc/build/shortcodes/js/instagram.js', |
|
44
|
|
|
'modules/shortcodes/js/instagram.js', |
|
45
|
|
|
false, |
|
46
|
|
|
'min_path', |
|
47
|
|
|
'non_min_path' |
|
48
|
|
|
), |
|
49
|
|
|
); |
|
50
|
|
|
} |
|
51
|
|
|
} |
|
52
|
|
|
|