From ac6409a479f7119122e8e7749d14243cf23969d0 Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Fri, 31 Jan 2020 00:20:47 +0000 Subject: [PATCH] HTTP API: Add some basic tests for `wp_remote_fopen()`. Props pbearne, donmhico. Fixes #48845. git-svn-id: https://develop.svn.wordpress.org/trunk@47142 602fd350-edb4-49c9-b593-d223f7449a82 --- .../phpunit/tests/functions/wpRemoteFopen.php | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 tests/phpunit/tests/functions/wpRemoteFopen.php diff --git a/tests/phpunit/tests/functions/wpRemoteFopen.php b/tests/phpunit/tests/functions/wpRemoteFopen.php new file mode 100644 index 0000000000..3f87138ff1 --- /dev/null +++ b/tests/phpunit/tests/functions/wpRemoteFopen.php @@ -0,0 +1,34 @@ +assertFalse( wp_remote_fopen( '' ) ); + } + + /** + * @ticket 48845 + */ + public function test_wp_remote_fopen_bad_url() { + $this->assertFalse( wp_remote_fopen( 'wp.com' ) ); + } + + /** + * @ticket 48845 + */ + public function test_wp_remote_fopen() { + // This URL gives a direct 200 response. + $url = 'https://asdftestblog1.files.wordpress.com/2007/09/2007-06-30-dsc_4700-1.jpg'; + $response = wp_remote_fopen( $url ); + + $this->assertInternalType( 'string', $response ); + $this->assertEquals( 40148, strlen( $response ) ); + } +}