Skip to content

Commit

Permalink
Fix NODB tests etc
Browse files Browse the repository at this point in the history
Signed-off-by: Roeland Jago Douma <[email protected]>
  • Loading branch information
rullzer committed Mar 20, 2017
1 parent 0351fab commit 38068ed
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions tests/lib/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ protected function setUp() {
if (is_null(self::$realDatabase)) {
self::$realDatabase = \OC::$server->getDatabaseConnection();
}
\OC::$server->registerService('DatabaseConnection', function () {
\OC::$server->registerService(IDBConnection::class, function () {
$this->fail('Your test case is not allowed to access the database.');
});
}
Expand All @@ -157,7 +157,7 @@ protected function realOnNotSuccessfulTest() {

// restore database connection
if (!$this->IsDatabaseAccessAllowed()) {
\OC::$server->registerService('DatabaseConnection', function () {
\OC::$server->registerService(IDBConnection::class, function () {
return self::$realDatabase;
});
}
Expand All @@ -168,7 +168,7 @@ protected function tearDown() {

// restore database connection
if (!$this->IsDatabaseAccessAllowed()) {
\OC::$server->registerService('DatabaseConnection', function () {
\OC::$server->registerService(IDBConnection::class, function () {
return self::$realDatabase;
});
}
Expand Down Expand Up @@ -256,7 +256,7 @@ public static function tearDownAfterClass() {
if (!self::$wasDatabaseAllowed && self::$realDatabase !== null) {
// in case an error is thrown in a test, PHPUnit jumps straight to tearDownAfterClass,
// so we need the database again
\OC::$server->registerService('DatabaseConnection', function () {
\OC::$server->registerService(IDBConnection::class, function () {
return self::$realDatabase;
});
}
Expand Down

0 comments on commit 38068ed

Please sign in to comment.