Skip to content

Commit 41bd267

Browse files
MFTF-33782: Added empty query and fragment testing to the UrlFormatterTest
1 parent cc0fc8b commit 41bd267

File tree

1 file changed

+28
-22
lines changed

1 file changed

+28
-22
lines changed

dev/tests/unit/Magento/FunctionalTestFramework/Util/Path/UrlFormatterTest.php

Lines changed: 28 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -3,51 +3,53 @@
33
* Copyright © Magento, Inc. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
6+
declare(strict_types=1);
7+
68
namespace tests\unit\Magento\FunctionalTestFramework\Util\Path;
79

8-
use tests\unit\Util\MagentoTestCase;
9-
use Magento\FunctionalTestingFramework\Util\Path\UrlFormatter;
1010
use Magento\FunctionalTestingFramework\Exceptions\TestFrameworkException;
11+
use Magento\FunctionalTestingFramework\Util\Path\UrlFormatter;
12+
use tests\unit\Util\MagentoTestCase;
1113

1214
class UrlFormatterTest extends MagentoTestCase
1315
{
1416
/**
15-
* Test url format
17+
* Test url format.
1618
*
17-
* @dataProvider formatDataProvider
1819
* @param string $path
19-
* @param boolean $withTrailingSeparator
20-
* @param mixed string|boolean $expectedPath
20+
* @param bool $withTrailingSeparator
21+
* @param string $expectedPath
22+
*
2123
* @return void
22-
* @throws TestFrameworkException
24+
* @dataProvider formatDataProvider
2325
*/
24-
public function testFormat($path, $withTrailingSeparator, $expectedPath)
26+
public function testFormat(string $path, bool $withTrailingSeparator, string $expectedPath): void
2527
{
2628
$this->assertEquals($expectedPath, UrlFormatter::format($path, $withTrailingSeparator));
2729
}
2830

2931
/**
30-
* Test url format with exception
32+
* Test url format with exception.
3133
*
32-
* @dataProvider formatExceptionDataProvider
3334
* @param string $path
34-
* @param boolean $withTrailingSeparator
35+
* @param bool $withTrailingSeparator
36+
*
3537
* @return void
36-
* @throws TestFrameworkException
38+
* @dataProvider formatExceptionDataProvider
3739
*/
38-
public function testFormatWithException($path, $withTrailingSeparator)
40+
public function testFormatWithException(string $path, bool $withTrailingSeparator): void
3941
{
4042
$this->expectException(TestFrameworkException::class);
4143
$this->expectExceptionMessage("Invalid url: $path\n");
4244
UrlFormatter::format($path, $withTrailingSeparator);
4345
}
4446

4547
/**
46-
* Data input
48+
* Data input.
4749
*
4850
* @return array
4951
*/
50-
public function formatDataProvider()
52+
public function formatDataProvider(): array
5153
{
5254
$url1 = 'http://magento.local/index.php';
5355
$url2 = $url1 . '/';
@@ -58,34 +60,38 @@ public function formatDataProvider()
5860
$url7 = 'http://127.0.0.1:8200';
5961
$url8 = 'wwøw.goåoøgle.coøm';
6062
$url9 = 'http://www.google.com';
63+
6164
return [
62-
[$url1, null, $url1],
65+
[$url1, false, $url1],
6366
[$url1, false, $url1],
6467
[$url1, true, $url2],
65-
[$url2, null, $url1],
68+
[$url2, false, $url1],
6669
[$url2, false, $url1],
6770
[$url2, true, $url2],
68-
[$url3, null, $url3],
71+
[$url3, false, $url3],
6972
[$url3, false, $url3],
7073
[$url3, true, $url4],
71-
[$url4, null, $url3],
74+
[$url4, false, $url3],
7275
[$url4, false, $url3],
7376
[$url4, true, $url4],
7477
[$url5, true, $url6],
7578
[$url7, false, $url7],
7679
[$url8, false, $url9],
80+
['https://magento.local/path?', false, 'https://magento.local/path?'],
81+
['https://magento.local/path#', false, 'https://magento.local/path#'],
82+
['https://magento.local/path?#', false, 'https://magento.local/path?#']
7783
];
7884
}
7985

8086
/**
81-
* Invalid data input
87+
* Invalid data input.
8288
*
8389
* @return array
8490
*/
85-
public function formatExceptionDataProvider()
91+
public function formatExceptionDataProvider(): array
8692
{
8793
return [
88-
['', null],
94+
['', false]
8995
];
9096
}
9197
}

0 commit comments

Comments
 (0)