refactor: simplify tests

This commit is contained in:
rugk
2025-09-03 13:48:28 +00:00
parent dbaa70ec11
commit f76704a88c
+17 -21
View File
@@ -58,15 +58,15 @@ class YourlsProxyTest extends TestCase
}
public function providerInvalidUrl() {
return array(
array(''),
array(' '),
array('foo'),
array('https://'),
array('https://example.com'), // missing path and query parameter,
array('https://example.com/'), // missing query parameter
array('https://example.com?paste=something'), // missing path parameter
);
return [
[''],
[' '],
['foo'],
['https://'],
['https://example.com'], // missing path and query parameter,
['https://example.com/'], // missing query parameter
['https://example.com?paste=something'] // missing path parameter
];
}
/**
@@ -81,7 +81,8 @@ class YourlsProxyTest extends TestCase
$this->assertTrue($yourls->isError());
$this->assertEquals($yourls->getError(), 'Trying to shorten a URL that isn\'t pointing at our instance.');
}
/**
/**
* @dataProvider providerForeignUrl
*/
public function testForeignUrl($url)
@@ -90,18 +91,13 @@ class YourlsProxyTest extends TestCase
$this->assertTrue($yourls->isError());
$this->assertEquals($yourls->getError(), 'Trying to shorten a URL that isn\'t pointing at our instance.');
}
public function providerForeignUrl() {
return array(
['ftp://example.com/?n=np'], // wrong protocol
['https://other.example.com/?foo#bar'] // wrong domain
);
}
public function testSneakyForeignUrl()
{
$yourls = new YourlsProxy($this->_conf, 'https://other.example.com/?q=https://example.com/?foo#bar');
$this->assertTrue($yourls->isError());
$this->assertEquals($yourls->getError(), 'Trying to shorten a URL that isn\'t pointing at our instance.');
public function providerForeignUrl() {
return [
['ftp://example.com/?n=np'], // wrong protocol
['https://other.example.com/?foo#bar'], // wrong domain
['https://other.example.com/?q=https://example.com/?foo#bar'] // domain included inside string
];
}
public function testYourlsError()