| 890 | |
| 891 | /** |
| 892 | * @dataProvider files_provider |
| 893 | */ |
| 894 | public function test_wp_check_filetype( $actual, $expected, $mimes = null ) { |
| 895 | $result = wp_check_filetype( $actual, $mimes ); |
| 896 | |
| 897 | $this->assertInternalType( 'array', $result, 'The return must be an array' ); |
| 898 | $this->assertArrayHasKey( 'ext', $result, "The return array must contains the 'ext' key" ); |
| 899 | $this->assertArrayHasKey( 'type', $result, "The return array must contains the 'type' key" ); |
| 900 | $this->assertEquals( $expected['ext'], $result['ext'] ); |
| 901 | $this->assertEquals( $expected['type'], $result['type'] ); |
| 902 | } |
| 903 | |
| 904 | function files_provider() { |
| 905 | return array( |
| 906 | array( '/var/www/html/image.jpg', array( 'ext' => 'jpg', 'type' => 'image/jpeg' ), null ), |
| 907 | array( '/home/foo/file.csv', array( 'ext' => 'csv', 'type' => 'text/csv' ), null ), |
| 908 | array( |
| 909 | '/home/foo/flash_pix_file.fpx', |
| 910 | array( 'ext' => 'fpx', 'type' => 'image/vnd.fpx' ), |
| 911 | array( 'fpx' => 'image/vnd.fpx', 'g' => 'text/plain' ), |
| 912 | ), |
| 913 | array( 'win_help_file.hlp', array( 'ext' => false, 'type' => false ), null ), |
| 914 | ); |
| 915 | } |