From 636d748a4936216a1567d0898d8fa15a08f415b0 Mon Sep 17 00:00:00 2001 From: Peter Wilson Date: Thu, 3 Oct 2024 23:16:21 +0000 Subject: [PATCH] Tests/Build Tools: Introduce tests for `links_add_base_url()`. Props pbearne, rajinsharwar, jorbin, mukesh27, aristath, desrosj, ironprogrammer. Fixes #60389. git-svn-id: https://develop.svn.wordpress.org/trunk@59162 602fd350-edb4-49c9-b593-d223f7449a82 --- .../tests/formatting/linksAddBaseUrl.php | 94 +++++++++++++++++++ 1 file changed, 94 insertions(+) create mode 100644 tests/phpunit/tests/formatting/linksAddBaseUrl.php diff --git a/tests/phpunit/tests/formatting/linksAddBaseUrl.php b/tests/phpunit/tests/formatting/linksAddBaseUrl.php new file mode 100644 index 0000000000000..0d88cc061a564 --- /dev/null +++ b/tests/phpunit/tests/formatting/linksAddBaseUrl.php @@ -0,0 +1,94 @@ +assertSame( $expected, links_add_base_url( $content, $base, $attrs ) ); + } else { + $this->assertSame( $expected, links_add_base_url( $content, $base ) ); + } + } + + /** + * Data provider for test_links_add_base_url(). + * + * @return array[] + */ + public function data_links_add_base_url() { + return array( + 'https' => array( + 'content' => '', + 'base' => 'https://localhost', + 'attrs' => null, + 'expected' => '', + ), + 'http' => array( + 'content' => '', + 'base' => 'http://localhost', + 'attrs' => null, + 'expected' => '', + ), + 'relative_scheme' => array( + 'content' => '', + 'base' => 'http://localhost', + 'attrs' => null, + 'expected' => '', + ), + 'empty_array' => array( + 'content' => '', + 'base' => 'https://localhost', + 'attrs' => array(), + 'expected' => '', + ), + 'data_url' => array( + 'content' => '', + 'base' => 'https://localhost', + 'attrs' => array( 'data-url', 'href' ), + 'expected' => '', + ), + 'not relative' => array( + 'content' => '', + 'base' => 'https://localbase', + 'attrs' => null, + 'expected' => '', + ), + 'no_href' => array( + 'content' => '', + 'base' => 'https://localhost', + 'attrs' => null, + 'expected' => '', + ), + 'img' => array( + 'content' => '', + 'base' => 'https://localhost', + 'attrs' => null, + 'expected' => '', + ), + 'ftp' => array( + 'content' => 'sss', + 'base' => 'ftp://localhost', + 'attrs' => null, + 'expected' => 'sss', + ), + 'ftps' => array( + 'content' => 'sss', + 'base' => 'ftps://localhost', + 'attrs' => null, + 'expected' => 'sss', + ), + ); + } +}