Code Coverage |
||||||||||
Classes and Traits |
Functions and Methods |
Lines |
||||||||
Total | |
0.00% |
0 / 1 |
|
0.00% |
0 / 5 |
CRAP | |
0.00% |
0 / 30 |
Migrator_Admin_Controller_Test | |
0.00% |
0 / 1 |
|
0.00% |
0 / 5 |
30 | |
0.00% |
0 / 30 |
setUp | |
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 4 |
|||
migrator_panel_css_file_must_attach_just_in_dedicated_page | |
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 8 |
|||
migrator_js_file_must_attach_in_migration_page | |
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 8 |
|||
migrator_localize_script_script_should_load_in_dedicated_page | |
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 7 |
|||
tearDown | |
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 3 |
<?php | |
/** | |
* @coversDefaultClass Migrator_Admin_Controller | |
*/ | |
class Migrator_Admin_Controller_Test extends WP_UnitTestCase { | |
public $user_id; | |
function setUp() { | |
parent::setUp(); | |
$this->user_id = self::factory()->user->create( array( 'role' => 'administrator' ) ); | |
wp_set_current_user( $this->user_id ); | |
} | |
/** | |
* @test | |
* | |
* @covers ::enqueue_static_files | |
*/ | |
public function migrator_panel_css_file_must_attach_just_in_dedicated_page() { | |
wp_styles()->done = array(); | |
unset( wp_scripts()->registered['wp-migrator-panel'] ); | |
$url = mg_asset( 'css/wp-migrator-panel.css' ); | |
$pattern = "#<link \s+ rel='stylesheet' .*? href='$url\?ver=.*?' \s+ type='text/css' \s+#isx"; | |
$this->assertNotRegExp( $pattern, get_echo( 'wp_print_styles' ), 'wp-migrator-panel.css should not include in every wp-admin single pages!' ); | |
mg_fire( 'Migrator_Admin_Controller@index' ); | |
$this->assertRegExp( $pattern, get_echo( 'wp_print_styles' ), 'wp-migrator-panel.css must load in migrator admin panel' ); | |
} | |
/** | |
* @test | |
* | |
* @covers ::enqueue_static_files | |
*/ | |
public function migrator_js_file_must_attach_in_migration_page() { | |
wp_scripts()->done = array(); | |
unset( wp_scripts()->registered['wp-migrator'] ); | |
$url = mg_asset( 'js/wp-migrator.js' ); | |
$pattern = "#<script \s+ type='text/javascript' .*? src='$url\?ver=.*?'\s*\>#isx"; | |
$this->assertNotRegExp( $pattern, get_echo( 'wp_print_scripts' ), 'wp-migrator.js should not load in all wp-admin pages' ); | |
mg_fire( 'Migrator_Admin_Controller@index' ); | |
$this->assertRegExp( $pattern, get_echo( 'wp_print_scripts' ), 'wp-migrator.js must load in migrator admin panel.' ); | |
} | |
/** | |
* @test | |
* | |
* @covers ::enqueue_static_files | |
*/ | |
public function migrator_localize_script_script_should_load_in_dedicated_page() { | |
wp_scripts()->done = array(); | |
unset( wp_scripts()->registered['wp-migrator'] ); | |
$pattern = "#<script \s+ type='text/javascript'\s*\>.*?var \s* wp_migrator_loc\s*=\s* (?:\{|\[)#isx"; | |
$this->assertNotRegExp( $pattern, get_echo( 'wp_print_scripts' ), 'Localization script should not load in all wordpress admin panel!' ); | |
mg_fire( 'Migrator_Admin_Controller@index' ); | |
$this->assertRegExp( $pattern, get_echo( 'wp_print_scripts' ), 'Localization script not found!' ); | |
} | |
function tearDown() { | |
parent::tearDown(); | |
wp_set_current_user( 0 ); | |
} | |
} | |