Skip to content

Commit

Permalink
Handle inline column comments in DbHandlerTest.php
Browse files Browse the repository at this point in the history
  • Loading branch information
phil-davis committed Nov 28, 2019
1 parent 13a1b6c commit 967ccac
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions apps/federation/tests/DbHandlerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,16 @@ public function testAddToken() {
$this->dbHandler->addServer('server1');
$query = $this->connection->getQueryBuilder()->select('*')->from($this->dbTable);
$result = $query->execute()->fetchAll();
$resultToken = $result[0]['token'];
// MySQL and sqLite support inline column comments in doctrine/dbal
// When the result is null, and the database has been created with column comments,
// then dbal can return a string like:
// 'NULL --token used to exchange the shared secret'
if (\is_string($resultToken) && (\substr($resultToken, 0, 4) === 'NULL')) {
$resultToken = null;
}
$this->assertCount(1, $result);
$this->assertNull($result[0]['token']);
$this->assertNull($resultToken);
$this->dbHandler->addToken('http://server1', 'token');
$query = $this->connection->getQueryBuilder()->select('*')->from($this->dbTable);
$result = $query->execute()->fetchAll();
Expand All @@ -182,8 +190,16 @@ public function testAddSharedSecret() {
$this->dbHandler->addServer('server1');
$query = $this->connection->getQueryBuilder()->select('*')->from($this->dbTable);
$result = $query->execute()->fetchAll();
$resultToken = $result[0]['shared_secret'];
// MySQL and sqLite support inline column comments in doctrine/dbal
// When the result is null, and the database has been created with column comments,
// then dbal can return a string like:
// 'NULL --shared secret used to authenticate'
if (\is_string($resultToken) && (\substr($resultToken, 0, 4) === 'NULL')) {
$resultToken = null;
}
$this->assertCount(1, $result);
$this->assertNull($result[0]['shared_secret']);
$this->assertNull($resultToken);
$this->dbHandler->addSharedSecret('http://server1', 'secret');
$query = $this->connection->getQueryBuilder()->select('*')->from($this->dbTable);
$result = $query->execute()->fetchAll();
Expand Down

0 comments on commit 967ccac

Please sign in to comment.