Make WordPress Core

Ticket #39550: 39550-multisite-tests.diff

File 39550-multisite-tests.diff, 2.8 KB (added by joemcgill, 8 years ago)

Fixes tests for multisite installs

  • tests/phpunit/tests/functions.php

    diff --git tests/phpunit/tests/functions.php tests/phpunit/tests/functions.php
    index e22eb7ed278..a3aba79c448 100644
    class Tests_Functions extends WP_UnitTestCase { 
    931931         * @ticket 39550
    932932         */
    933933        function test_wp_check_filetype_and_ext_with_filtered_svg() {
     934                if ( ! extension_loaded( 'fileinfo' ) ) {
     935                        $this->markTestSkipped( 'The fileinfo PHP extension is not loaded.' );
     936                }
     937
     938                if ( is_multisite() ) {
     939                        $this->markTestSkipped( 'Test does not run in multisite' );
     940                }
     941
    934942                $file = DIR_TESTDATA . '/uploads/video-play.svg';
    935943                $filename = 'video-play.svg';
    936944
    class Tests_Functions extends WP_UnitTestCase { 
    951959         * @ticket 39550
    952960         */
    953961        function test_wp_check_filetype_and_ext_with_filtered_woff() {
     962                if ( ! extension_loaded( 'fileinfo' ) ) {
     963                        $this->markTestSkipped( 'The fileinfo PHP extension is not loaded.' );
     964                }
     965
     966                if ( is_multisite() ) {
     967                        $this->markTestSkipped( 'Test does not run in multisite' );
     968                }
     969
    954970                $file = DIR_TESTDATA . '/uploads/dashicons.woff';
    955971                $filename = 'dashicons.woff';
    956972
    class Tests_Functions extends WP_UnitTestCase { 
    978994        }
    979995
    980996        public function _wp_check_filetype_and_ext_data() {
    981                 return array(
     997                $data = array(
    982998                        // Standard image.
    983999                        array(
    9841000                                DIR_TESTDATA . '/images/canola.jpg',
    class Tests_Functions extends WP_UnitTestCase { 
    10191035                                        'proper_filename' => false,
    10201036                                ),
    10211037                        ),
    1022                         // Standard non-image file.
    1023                         array(
    1024                                 DIR_TESTDATA . '/formatting/big5.txt',
    1025                                 'big5.txt',
    1026                                 array(
    1027                                         'ext' => 'txt',
    1028                                         'type' => 'text/plain',
    1029                                         'proper_filename' => false,
    1030                                 ),
    1031                         ),
    1032                         // Non-image file with wrong sub-type.
    1033                         array(
    1034                                 DIR_TESTDATA . '/uploads/pages-to-word.docx',
    1035                                 'pages-to-word.docx',
    1036                                 array(
    1037                                         'ext' => 'docx',
    1038                                         'type' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
    1039                                         'proper_filename' => false,
    1040                                 ),
    1041                         ),
    10421038                        // Non-image file not allowed.
    10431039                        array(
    10441040                                DIR_TESTDATA . '/export/crazy-cdata.xml',
    class Tests_Functions extends WP_UnitTestCase { 
    10501046                                ),
    10511047                        ),
    10521048                );
     1049
     1050                // Test a few additional file types on single sites.
     1051                if ( ! is_multisite() ) {
     1052                        $data = array_merge( $data, array(
     1053                                // Standard non-image file.
     1054                                array(
     1055                                        DIR_TESTDATA . '/formatting/big5.txt',
     1056                                        'big5.txt',
     1057                                        array(
     1058                                                'ext' => 'txt',
     1059                                                'type' => 'text/plain',
     1060                                                'proper_filename' => false,
     1061                                        ),
     1062                                ),
     1063                                // Non-image file with wrong sub-type.
     1064                                array(
     1065                                        DIR_TESTDATA . '/uploads/pages-to-word.docx',
     1066                                        'pages-to-word.docx',
     1067                                        array(
     1068                                                'ext' => 'docx',
     1069                                                'type' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
     1070                                                'proper_filename' => false,
     1071                                        ),
     1072                                ),
     1073                        ) );
     1074                }
     1075
     1076                return $data;
    10531077        }
    10541078}