get_theme_root_uri() returns a file path, not URI
-
I followed this guide to set up WordPress testing environment: https://make.www.ads-software.com/core/handbook/testing/automated-testing/phpunit/
When I’m running tests with PHPUnit, I receive a lot of ‘F’s, especially for this file:
tests\phpunit\tests\link\themeFile.php:1611) Tests_Link_ThemeFile::test_theme_file_uri_returns_valid_uri with data set #0 ('parent-only.php', 'theme-file-parent', array('theme-file-parent')) Failed asserting that two strings are identical. --- Expected +++ Actual @@ @@ -'' +'C:\DevTools\xampp\htdocs\wptestsuite.local\tests\phpunit\includes/../data/themedir1/default/parent-only.php'
This is because
get_theme_file_uri( $file )
returns file path (C:\DevTools\xampp\htdocs\wptestsuite.local\tests\phpunit\includes/../data/themedir1/default/parent-only.php) instead of URI.I debugged it, and I can see that
get_site_transient( 'theme_roots' )
returns:Array ( [block-theme] => C:\DevTools\xampp\htdocs\wptestsuite.local\tests\phpunit\includes/../data/themedir1 [broken-theme] => C:\DevTools\xampp\htdocs\wptestsuite.local\tests\phpunit\includes/../data/themedir1 [camelCase] => C:\DevTools\xampp\htdocs\wptestsuite.local\tests\phpunit\includes/../data/themedir1 [child-parent-itself] => C:\DevTools\xampp\htdocs\wptestsuite.local\tests\phpunit\includes/../data/themedir1 [default] => C:\DevTools\xampp\htdocs\wptestsuite.local\tests\phpunit\includes/../data/themedir1 [internationalized-theme] => C:\DevTools\xampp\htdocs\wptestsuite.local\tests\phpunit\includes/../data/themedir1 [page-templates-child] => C:\DevTools\xampp\htdocs\wptestsuite.local\tests\phpunit\includes/../data/themedir1 [page-templates] => C:\DevTools\xampp\htdocs\wptestsuite.local\tests\phpunit\includes/../data/themedir1 [rest-api] => C:\DevTools\xampp\htdocs\wptestsuite.local\tests\phpunit\includes/../data/themedir1 [sandbox] => C:\DevTools\xampp\htdocs\wptestsuite.local\tests\phpunit\includes/../data/themedir1 [stylesheetonly] => C:\DevTools\xampp\htdocs\wptestsuite.local\tests\phpunit\includes/../data/themedir1 [subdir/theme with spaces] => C:\DevTools\xampp\htdocs\wptestsuite.local\tests\phpunit\includes/../data/themedir1 [subdir/theme2] => C:\DevTools\xampp\htdocs\wptestsuite.local\tests\phpunit\includes/../data/themedir1 [theme1-dupe] => C:\DevTools\xampp\htdocs\wptestsuite.local\tests\phpunit\includes/../data/themedir1 [theme1] => C:\DevTools\xampp\htdocs\wptestsuite.local\tests\phpunit\includes/../data/themedir1 [twentyeleven] => /themes [twentyfifteen] => /themes [twentyfourteen] => /themes [twentynineteen] => /themes [twentyseventeen] => /themes [twentysixteen] => /themes [twentyten] => /themes [twentythirteen] => /themes [twentytwelve] => /themes [twentytwenty] => /themes [twentytwentyone] => /themes )
It has to return correct URI for each value, or part of it. For the above ones, it returns absolute path.
What am I missing?
- The topic ‘get_theme_root_uri() returns a file path, not URI’ is closed to new replies.