| 1 | <?php |
| 2 | |
| 3 | /** |
| 4 | * @group admin |
| 5 | * @group upgrade |
| 6 | */ |
| 7 | class Tests_Admin_IncludesUpdateCore extends WP_UnitTestCase { |
| 8 | public function data_old_files() { |
| 9 | global $_old_files; |
| 10 | |
| 11 | require_once( ABSPATH . 'wp-admin/includes/update-core.php' ); |
| 12 | |
| 13 | $files = $_old_files; |
| 14 | |
| 15 | foreach ( $files as &$file ) { |
| 16 | $file = array( $file ); |
| 17 | } |
| 18 | |
| 19 | return $files; |
| 20 | } |
| 21 | |
| 22 | /** |
| 23 | * Ensure no project files are inside `$_old_files`. |
| 24 | * |
| 25 | * @ticket 36083 |
| 26 | * |
| 27 | * @dataProvider data_old_files |
| 28 | * |
| 29 | * @param string $file File name. |
| 30 | */ |
| 31 | public function test_new_files_are_not_in_old_files_array( $file ) { |
| 32 | $this->assertFalse( file_exists( ABSPATH . $file ) ); |
| 33 | $this->assertFalse( file_exists( ABSPATH . str_replace( '.min.', '.', $file ) ) ); |
| 34 | $this->assertFalse( file_exists( ABSPATH . str_replace( '-rtl.min.', '.', $file ) ) ); |
| 35 | } |
| 36 | |
| 37 | /** |
| 38 | * Ensure no project files are inside `$_old_files` in the build directory. |
| 39 | * |
| 40 | * The previous test confirms that no existing files are inside `$_old_files`. |
| 41 | * However, we must also confirm that these do not exist in the final build. |
| 42 | * |
| 43 | * @ticket 36083 |
| 44 | * |
| 45 | * @depends test_new_files_are_not_in_old_files_array |
| 46 | * @dataProvider data_old_files |
| 47 | * |
| 48 | * @param string $file File name. |
| 49 | */ |
| 50 | public function test_new_files_are_not_in_old_files_array_compiled( $file ) { |
| 51 | $this->assertFalse( file_exists( dirname( ABSPATH ) . '/build/' . $file ) ); |
| 52 | } |
| 53 | } |