Make WordPress Core

Changeset 43501


Ignore:
Timestamp:
07/18/2018 01:01:28 AM (8 years ago)
Author:
SergeyBiryukov
Message:

Filesystem API: Add basic tests for wp_is_stream().

Props JPry.
See #44533.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/functions.php

    r42451 r43501  
    14521452                );
    14531453        }
     1454
     1455        /**
     1456         * Test stream URL validation.
     1457         *
     1458         * @dataProvider data_test_wp_is_stream
     1459         *
     1460         * @param string $path     The resource path or URL.
     1461         * @param bool   $expected Expected result.
     1462         */
     1463        public function test_wp_is_stream( $path, $expected ) {
     1464                $this->assertSame( $expected, wp_is_stream( $path ) );
     1465        }
     1466
     1467        /**
     1468         * Data provider for stream URL validation.
     1469         *
     1470         * @return array {
     1471         *     @type array $0... {
     1472         *         @type string $0 The resource path or URL.
     1473         *         @type bool   $1 Expected result.
     1474         *     }
     1475         * }
     1476         */
     1477        public function data_test_wp_is_stream() {
     1478                return array(
     1479                        // Legitimate stream examples.
     1480                        array( 'https://example.com', true ),
     1481                        array( 'ftp://example.com', true ),
     1482                        array( 'file:///path/to/some/file', true ),
     1483                        array( 'php://some/php/file.php', true ),
     1484
     1485                        // Non-stream examples.
     1486                        array( 'fakestream://foo/bar/baz', false ),
     1487                        array( '../../some/relative/path', false ),
     1488                        array( 'some/other/relative/path', false ),
     1489                        array( '/leading/relative/path', false ),
     1490                );
     1491        }
    14541492}
Note: See TracChangeset for help on using the changeset viewer.