diff options
author | Joas Schilling <213943+nickvergessen@users.noreply.github.com> | 2021-04-26 13:56:01 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-04-26 13:56:01 +0200 |
commit | aa651fd629534e96432492c1a74e979b28222ce2 (patch) | |
tree | 63191b834673e30a9544ed589a2afba02ef54299 /tests | |
parent | e1a3000cbed2e0bfa29e53b8bbcb858604540da2 (diff) | |
parent | d80cc76ee7f3f1f347fc54cc300e5e38ba7d6e19 (diff) | |
download | nextcloud-server-aa651fd629534e96432492c1a74e979b28222ce2.tar.gz nextcloud-server-aa651fd629534e96432492c1a74e979b28222ce2.zip |
Merge pull request #26259 from nextcloud/feature/noid/validate-website-to-be-valid
Validate the website field input to be a valid URL
Diffstat (limited to 'tests')
-rw-r--r-- | tests/lib/Accounts/AccountManagerTest.php | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/tests/lib/Accounts/AccountManagerTest.php b/tests/lib/Accounts/AccountManagerTest.php index 27ebed69793..687ae29ff7b 100644 --- a/tests/lib/Accounts/AccountManagerTest.php +++ b/tests/lib/Accounts/AccountManagerTest.php @@ -455,4 +455,30 @@ class AccountManagerTest extends TestCase { self::assertEquals($phoneNumber, self::invokePrivate($instance, 'parsePhoneNumber', [$phoneInput])); } } + + public function dataParseWebsite(): array { + return [ + ['https://nextcloud.com', 'https://nextcloud.com'], + ['http://nextcloud.com', 'http://nextcloud.com'], + ['ftp://nextcloud.com', null], + ['//nextcloud.com/', null], + ['https:///?query', null], + ]; + } + + /** + * @dataProvider dataParseWebsite + * @param string $websiteInput + * @param string|null $websiteOutput + */ + public function testParseWebsite(string $websiteInput, ?string $websiteOutput): void { + $instance = $this->getInstance(); + + if ($websiteOutput === null) { + $this->expectException(\InvalidArgumentException::class); + self::invokePrivate($instance, 'parseWebsite', [$websiteInput]); + } else { + self::assertEquals($websiteOutput, self::invokePrivate($instance, 'parseWebsite', [$websiteInput])); + } + } } |