diff options
author | Björn Schießle <bjoern@schiessle.org> | 2015-11-24 13:07:40 +0100 |
---|---|---|
committer | Björn Schießle <bjoern@schiessle.org> | 2015-11-24 13:15:55 +0100 |
commit | 9546b21d7ead7bae6ce942019de86f30a1ceddd6 (patch) | |
tree | fa2c11fcb3dd42fadd7bd222a7b9b94e1b59f55a /apps/federation/tests | |
parent | 964fa1fce3bc7734b6f7435f730e3b7394fc1cbf (diff) | |
download | nextcloud-server-9546b21d7ead7bae6ce942019de86f30a1ceddd6.tar.gz nextcloud-server-9546b21d7ead7bae6ce942019de86f30a1ceddd6.zip |
always store server url without a trailing slash
Diffstat (limited to 'apps/federation/tests')
-rw-r--r-- | apps/federation/tests/lib/dbhandlertest.php | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/apps/federation/tests/lib/dbhandlertest.php b/apps/federation/tests/lib/dbhandlertest.php index e47df092f8c..123eaaee450 100644 --- a/apps/federation/tests/lib/dbhandlertest.php +++ b/apps/federation/tests/lib/dbhandlertest.php @@ -67,17 +67,33 @@ class DbHandlerTest extends TestCase { $query->execute(); } - public function testAddServer() { - $id = $this->dbHandler->addServer('server1'); + /** + * @dataProvider dataTestAddServer + * + * @param string $url passed to the method + * @param string $expectedUrl the url we expect to be written to the db + * @param string $expectedHash the hash value we expect to be written to the db + */ + public function testAddServer($url, $expectedUrl, $expectedHash) { + $id = $this->dbHandler->addServer($url); $query = $this->connection->getQueryBuilder()->select('*')->from($this->dbTable); $result = $query->execute()->fetchAll(); $this->assertSame(1, count($result)); - $this->assertSame('server1', $result[0]['url']); + $this->assertSame($expectedUrl, $result[0]['url']); $this->assertSame($id, (int)$result[0]['id']); + $this->assertSame($expectedHash, $result[0]['url_hash']); $this->assertSame(TrustedServers::STATUS_PENDING, (int)$result[0]['status']); } + public function dataTestAddServer() { + return [ + ['http://owncloud.org', 'http://owncloud.org', md5('owncloud.org')], + ['https://owncloud.org', 'https://owncloud.org', md5('owncloud.org')], + ['http://owncloud.org/', 'http://owncloud.org', md5('owncloud.org')], + ]; + } + public function testRemove() { $id1 = $this->dbHandler->addServer('server1'); $id2 = $this->dbHandler->addServer('server2'); |