Fix PHPCS issues in URLTests.php

This commit is contained in:
Nestor Soriano 2022-04-11 10:22:13 +02:00
parent 6dcb796a89
commit 21ecb88c4c
No known key found for this signature in database
GPG Key ID: 08110F3518C12CAD
1 changed files with 56 additions and 52 deletions

View File

@ -9,9 +9,13 @@ use WC_Unit_Test_Case;
* A collection of tests for the filepath utility class.
*/
class URLTest extends WC_Unit_Test_Case {
/**
* @testdox Test if it can be determined whether a URL is absolute or relative.
*/
public function test_if_absolute_or_relative() {
$this->assertTrue(
( new URL( '/etc/foo/bar' ) )->is_absolute() ,
( new URL( '/etc/foo/bar' ) )->is_absolute(),
'Correctly determines if a Unix-style path is absolute.'
);
@ -29,8 +33,8 @@ class URLTest extends WC_Unit_Test_Case {
/**
* @dataProvider path_expectations
*
* @param string $source_path
* @param string $expected_resolution
* @param string $source_path Source path to test.
* @param string $expected_resolution Expected result of the test.
*/
public function test_path_resolution( $source_path, $expected_resolution ) {
$this->assertEquals( $expected_resolution, ( new URL( $source_path ) )->get_path() );
@ -50,15 +54,15 @@ class URLTest extends WC_Unit_Test_Case {
array( '///nonempty/ /whitespace/ /is//kept', '/nonempty/ /whitespace/ /is/kept' ),
array( 'relative/../../should/remain/relative', '../should/remain/relative' ),
array( 'relative/../../../should/remain/relative', '../../should/remain/relative' ),
array( 'c:\\Windows\Server\HTTP\dump.xml', 'c:/Windows/Server/HTTP/dump.xml')
array( 'c:\\Windows\Server\HTTP\dump.xml', 'c:/Windows/Server/HTTP/dump.xml' ),
);
}
/**
* @dataProvider url_expectations
*
* @param string $source_url
* @param string $expected_resolution
* @param string $source_url URL to test.
* @param string $expected_resolution Expected result of the test.
*/
public function test_url_resolution( $source_url, $expected_resolution ) {
$this->assertEquals( $expected_resolution, ( new URL( $source_url ) )->get_url() );
@ -96,9 +100,9 @@ class URLTest extends WC_Unit_Test_Case {
/**
* @dataProvider parent_url_expectations
*
* @param string $source_path
* @param int $parent_level
* @param string|false $expectation
* @param string $source_path Path to test.
* @param int $parent_level Parent level to use for the test.
* @param string|false $expectation Expected result of the test.
*/
public function test_can_obtain_parent_url( string $source_path, int $parent_level, $expectation ) {
$this->assertEquals( $expectation, ( new URL( $source_path ) )->get_parent_url( $parent_level ) );
@ -135,8 +139,8 @@ class URLTest extends WC_Unit_Test_Case {
/**
* @dataProvider all_parent_url_expectations
*
* @param string $source_path
* @param array $expectation
* @param string $source_path Path to test.
* @param array $expectation Expected result of the test.
*/
public function test_can_obtain_all_parent_urls( string $source_path, array $expectation ) {
$this->assertEquals( $expectation, ( new URL( $source_path ) )->get_all_parent_urls() );
@ -193,7 +197,7 @@ class URLTest extends WC_Unit_Test_Case {
array(
'../../some.file',
array(
'file://../../'
'file://../../',
),
),
);