From c4d5be53c2ae503c00da3cfe6b28d0ce9d2ca7f5 Mon Sep 17 00:00:00 2001 From: ArthurHoaro Date: Sun, 17 May 2020 14:16:32 +0200 Subject: Process Daily RSS feed through Slim controller The daily RSS template has been entirely rewritten to handle the whole feed through the template engine. --- tests/http/HttpUtils/IndexUrlTest.php | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'tests/http') diff --git a/tests/http/HttpUtils/IndexUrlTest.php b/tests/http/HttpUtils/IndexUrlTest.php index bcbe59cb..73d33cd4 100644 --- a/tests/http/HttpUtils/IndexUrlTest.php +++ b/tests/http/HttpUtils/IndexUrlTest.php @@ -71,4 +71,36 @@ class IndexUrlTest extends \PHPUnit\Framework\TestCase ) ); } + + /** + * The route is stored in REQUEST_URI + */ + public function testPageUrlWithRoute() + { + $this->assertEquals( + 'http://host.tld/picture-wall', + page_url( + array( + 'HTTPS' => 'Off', + 'SERVER_NAME' => 'host.tld', + 'SERVER_PORT' => '80', + 'SCRIPT_NAME' => '/index.php', + 'REQUEST_URI' => '/picture-wall', + ) + ) + ); + + $this->assertEquals( + 'http://host.tld/admin/picture-wall', + page_url( + array( + 'HTTPS' => 'Off', + 'SERVER_NAME' => 'host.tld', + 'SERVER_PORT' => '80', + 'SCRIPT_NAME' => '/admin/index.php', + 'REQUEST_URI' => '/admin/picture-wall', + ) + ) + ); + } } -- cgit v1.2.3 From 650a5f09cbeb1c1bef19810c6cc504c06d5b7e87 Mon Sep 17 00:00:00 2001 From: ArthurHoaro Date: Thu, 3 Sep 2020 14:51:41 +0200 Subject: Add manual configuration for root URL This new setting under 'general.root_url' allows to override automatic discovery of Shaarli instance's URL. Fixes #1339 --- tests/http/HttpUtils/IndexUrlTest.php | 36 +++++++++++++++- tests/http/HttpUtils/IndexUrlTestWithConstant.php | 51 +++++++++++++++++++++++ 2 files changed, 86 insertions(+), 1 deletion(-) create mode 100644 tests/http/HttpUtils/IndexUrlTestWithConstant.php (limited to 'tests/http') diff --git a/tests/http/HttpUtils/IndexUrlTest.php b/tests/http/HttpUtils/IndexUrlTest.php index 73d33cd4..cce45c51 100644 --- a/tests/http/HttpUtils/IndexUrlTest.php +++ b/tests/http/HttpUtils/IndexUrlTest.php @@ -5,12 +5,14 @@ namespace Shaarli\Http; +use PHPUnit\Framework\TestCase; + require_once 'application/http/HttpUtils.php'; /** * Unitary tests for index_url() */ -class IndexUrlTest extends \PHPUnit\Framework\TestCase +class IndexUrlTest extends TestCase { /** * If on the main page, remove "index.php" from the URL resource @@ -103,4 +105,36 @@ class IndexUrlTest extends \PHPUnit\Framework\TestCase ) ); } + + /** + * The route is stored in REQUEST_URI and subfolder + */ + public function testPageUrlWithRouteUnderSubfolder() + { + $this->assertEquals( + 'http://host.tld/subfolder/picture-wall', + page_url( + array( + 'HTTPS' => 'Off', + 'SERVER_NAME' => 'host.tld', + 'SERVER_PORT' => '80', + 'SCRIPT_NAME' => '/subfolder/index.php', + 'REQUEST_URI' => '/subfolder/picture-wall', + ) + ) + ); + + $this->assertEquals( + 'http://host.tld/subfolder/admin/picture-wall', + page_url( + array( + 'HTTPS' => 'Off', + 'SERVER_NAME' => 'host.tld', + 'SERVER_PORT' => '80', + 'SCRIPT_NAME' => '/subfolder/admin/index.php', + 'REQUEST_URI' => '/subfolder/admin/picture-wall', + ) + ) + ); + } } diff --git a/tests/http/HttpUtils/IndexUrlTestWithConstant.php b/tests/http/HttpUtils/IndexUrlTestWithConstant.php new file mode 100644 index 00000000..15ca3d72 --- /dev/null +++ b/tests/http/HttpUtils/IndexUrlTestWithConstant.php @@ -0,0 +1,51 @@ +assertEquals( + 'http://other-host.tld/subfolder/', + index_url( + array( + 'HTTPS' => 'Off', + 'SERVER_NAME' => 'host.tld', + 'SERVER_PORT' => '80', + 'SCRIPT_NAME' => '/index.php', + 'REQUEST_URI' => '/picture-wall', + ) + ) + ); + + $this->assertEquals( + 'http://other-host.tld/subfolder/', + index_url( + array( + 'HTTPS' => 'Off', + 'SERVER_NAME' => 'host.tld', + 'SERVER_PORT' => '80', + 'SCRIPT_NAME' => '/admin/index.php', + 'REQUEST_URI' => '/admin/picture-wall', + ) + ) + ); + } +} -- cgit v1.2.3 From a5a9cf23acd1248585173aa32757d9720b5f2d62 Mon Sep 17 00:00:00 2001 From: ArthurHoaro Date: Tue, 29 Sep 2020 14:41:40 +0200 Subject: Compatibility with PHPUnit 9 --- tests/http/HttpUtils/ClientIpIdTest.php | 2 +- tests/http/HttpUtils/GetHttpUrlTest.php | 2 +- tests/http/HttpUtils/GetIpAdressFromProxyTest.php | 2 +- tests/http/HttpUtils/IndexUrlTest.php | 2 +- tests/http/HttpUtils/IndexUrlTestWithConstant.php | 2 +- tests/http/HttpUtils/IsHttpsTest.php | 2 +- tests/http/HttpUtils/PageUrlTest.php | 2 +- tests/http/HttpUtils/ServerUrlTest.php | 2 +- tests/http/UrlTest.php | 2 +- tests/http/UrlUtils/CleanupUrlTest.php | 2 +- tests/http/UrlUtils/GetUrlSchemeTest.php | 2 +- tests/http/UrlUtils/UnparseUrlTest.php | 2 +- tests/http/UrlUtils/WhitelistProtocolsTest.php | 2 +- 13 files changed, 13 insertions(+), 13 deletions(-) (limited to 'tests/http') diff --git a/tests/http/HttpUtils/ClientIpIdTest.php b/tests/http/HttpUtils/ClientIpIdTest.php index 982e57e0..3a0fcf30 100644 --- a/tests/http/HttpUtils/ClientIpIdTest.php +++ b/tests/http/HttpUtils/ClientIpIdTest.php @@ -10,7 +10,7 @@ require_once 'application/http/HttpUtils.php'; /** * Unitary tests for client_ip_id() */ -class ClientIpIdTest extends \PHPUnit\Framework\TestCase +class ClientIpIdTest extends \Shaarli\TestCase { /** * Get a remote client ID based on its IP diff --git a/tests/http/HttpUtils/GetHttpUrlTest.php b/tests/http/HttpUtils/GetHttpUrlTest.php index 3dc5bc9b..a868ac02 100644 --- a/tests/http/HttpUtils/GetHttpUrlTest.php +++ b/tests/http/HttpUtils/GetHttpUrlTest.php @@ -10,7 +10,7 @@ require_once 'application/http/HttpUtils.php'; /** * Unitary tests for get_http_response() */ -class GetHttpUrlTest extends \PHPUnit\Framework\TestCase +class GetHttpUrlTest extends \Shaarli\TestCase { /** * Get an invalid local URL diff --git a/tests/http/HttpUtils/GetIpAdressFromProxyTest.php b/tests/http/HttpUtils/GetIpAdressFromProxyTest.php index fe3a639e..60cdb992 100644 --- a/tests/http/HttpUtils/GetIpAdressFromProxyTest.php +++ b/tests/http/HttpUtils/GetIpAdressFromProxyTest.php @@ -7,7 +7,7 @@ require_once 'application/http/HttpUtils.php'; /** * Unitary tests for getIpAddressFromProxy() */ -class GetIpAdressFromProxyTest extends \PHPUnit\Framework\TestCase +class GetIpAdressFromProxyTest extends \Shaarli\TestCase { /** diff --git a/tests/http/HttpUtils/IndexUrlTest.php b/tests/http/HttpUtils/IndexUrlTest.php index cce45c51..f283d119 100644 --- a/tests/http/HttpUtils/IndexUrlTest.php +++ b/tests/http/HttpUtils/IndexUrlTest.php @@ -5,7 +5,7 @@ namespace Shaarli\Http; -use PHPUnit\Framework\TestCase; +use Shaarli\TestCase; require_once 'application/http/HttpUtils.php'; diff --git a/tests/http/HttpUtils/IndexUrlTestWithConstant.php b/tests/http/HttpUtils/IndexUrlTestWithConstant.php index 15ca3d72..ecaea724 100644 --- a/tests/http/HttpUtils/IndexUrlTestWithConstant.php +++ b/tests/http/HttpUtils/IndexUrlTestWithConstant.php @@ -4,7 +4,7 @@ declare(strict_types=1); namespace Shaarli\Http; -use PHPUnit\Framework\TestCase; +use Shaarli\TestCase; /** * Test index_url with SHAARLI_ROOT_URL defined to override automatic retrieval. diff --git a/tests/http/HttpUtils/IsHttpsTest.php b/tests/http/HttpUtils/IsHttpsTest.php index 348956c6..8b3fd93d 100644 --- a/tests/http/HttpUtils/IsHttpsTest.php +++ b/tests/http/HttpUtils/IsHttpsTest.php @@ -9,7 +9,7 @@ require_once 'application/http/HttpUtils.php'; * * Test class for is_https() function. */ -class IsHttpsTest extends \PHPUnit\Framework\TestCase +class IsHttpsTest extends \Shaarli\TestCase { /** diff --git a/tests/http/HttpUtils/PageUrlTest.php b/tests/http/HttpUtils/PageUrlTest.php index f1991716..ebb3e617 100644 --- a/tests/http/HttpUtils/PageUrlTest.php +++ b/tests/http/HttpUtils/PageUrlTest.php @@ -10,7 +10,7 @@ require_once 'application/http/HttpUtils.php'; /** * Unitary tests for page_url() */ -class PageUrlTest extends \PHPUnit\Framework\TestCase +class PageUrlTest extends \Shaarli\TestCase { /** * If on the main page, remove "index.php" from the URL resource diff --git a/tests/http/HttpUtils/ServerUrlTest.php b/tests/http/HttpUtils/ServerUrlTest.php index 9caf1049..339664e1 100644 --- a/tests/http/HttpUtils/ServerUrlTest.php +++ b/tests/http/HttpUtils/ServerUrlTest.php @@ -10,7 +10,7 @@ require_once 'application/http/HttpUtils.php'; /** * Unitary tests for server_url() */ -class ServerUrlTest extends \PHPUnit\Framework\TestCase +class ServerUrlTest extends \Shaarli\TestCase { /** * Detect if the server uses SSL diff --git a/tests/http/UrlTest.php b/tests/http/UrlTest.php index ae92f73a..c6b39c29 100644 --- a/tests/http/UrlTest.php +++ b/tests/http/UrlTest.php @@ -8,7 +8,7 @@ namespace Shaarli\Http; /** * Unitary tests for URL utilities */ -class UrlTest extends \PHPUnit\Framework\TestCase +class UrlTest extends \Shaarli\TestCase { // base URL for tests protected static $baseUrl = 'http://domain.tld:3000'; diff --git a/tests/http/UrlUtils/CleanupUrlTest.php b/tests/http/UrlUtils/CleanupUrlTest.php index 6c4d124b..45690ecf 100644 --- a/tests/http/UrlUtils/CleanupUrlTest.php +++ b/tests/http/UrlUtils/CleanupUrlTest.php @@ -7,7 +7,7 @@ namespace Shaarli\Http; require_once 'application/http/UrlUtils.php'; -class CleanupUrlTest extends \PHPUnit\Framework\TestCase +class CleanupUrlTest extends \Shaarli\TestCase { /** * @var string reference URL diff --git a/tests/http/UrlUtils/GetUrlSchemeTest.php b/tests/http/UrlUtils/GetUrlSchemeTest.php index 2b97f7be..18a9a5e5 100644 --- a/tests/http/UrlUtils/GetUrlSchemeTest.php +++ b/tests/http/UrlUtils/GetUrlSchemeTest.php @@ -7,7 +7,7 @@ namespace Shaarli\Http; require_once 'application/http/UrlUtils.php'; -class GetUrlSchemeTest extends \PHPUnit\Framework\TestCase +class GetUrlSchemeTest extends \Shaarli\TestCase { /** * Get empty scheme string for empty UrlUtils diff --git a/tests/http/UrlUtils/UnparseUrlTest.php b/tests/http/UrlUtils/UnparseUrlTest.php index 040d8c54..5e6246cc 100644 --- a/tests/http/UrlUtils/UnparseUrlTest.php +++ b/tests/http/UrlUtils/UnparseUrlTest.php @@ -10,7 +10,7 @@ require_once 'application/http/UrlUtils.php'; /** * Unitary tests for unparse_url() */ -class UnparseUrlTest extends \PHPUnit\Framework\TestCase +class UnparseUrlTest extends \Shaarli\TestCase { /** * Thanks for building nothing diff --git a/tests/http/UrlUtils/WhitelistProtocolsTest.php b/tests/http/UrlUtils/WhitelistProtocolsTest.php index 69512dbd..b8a6baaa 100644 --- a/tests/http/UrlUtils/WhitelistProtocolsTest.php +++ b/tests/http/UrlUtils/WhitelistProtocolsTest.php @@ -9,7 +9,7 @@ require_once 'application/http/UrlUtils.php'; * * Test whitelist_protocols() function of UrlUtils. */ -class WhitelistProtocolsTest extends \PHPUnit\Framework\TestCase +class WhitelistProtocolsTest extends \Shaarli\TestCase { /** * Test whitelist_protocols() on a note (relative URL). -- cgit v1.2.3