Skip to content

Commit

Permalink
fix tests (#181)
Browse files Browse the repository at this point in the history
  • Loading branch information
darkdef committed Jan 9, 2023
1 parent cdb239a commit d7c8553
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions tests/ConnectionTest.php
Expand Up @@ -11,6 +11,7 @@
use Yiisoft\Db\Exception\Exception;
use Yiisoft\Db\Exception\InvalidConfigException;
use Yiisoft\Db\Exception\NotSupportedException;
use Yiisoft\Db\Profiler\ProfilerInterface;
use Yiisoft\Db\Sqlite\Tests\Support\TestTrait;
use Yiisoft\Db\Tests\Common\CommonConnectionTest;
use Yiisoft\Db\Tests\Support\DbHelper;
Expand Down Expand Up @@ -45,25 +46,25 @@ public function testExceptionContainsRawQuery(): void

/* profiling and logging */
$db->setLogger(DbHelper::getLogger());
$db->setProfiler(DbHelper::getProfiler());
$db->setProfiler($this->createProfiler());

$this->runExceptionTest($db);

/* profiling only */
$db->setLogger(new NullLogger());
$db->setProfiler(DbHelper::getProfiler());
$db->setProfiler($this->createProfiler());

$this->runExceptionTest($db);

/* logging only */
$db->setLogger(DbHelper::getLogger());
$db->notProfiler();
$db->setProfiler(null);

$this->runExceptionTest($db);

/* disabled */
$db->setLogger(new NullLogger());
$db->notProfiler();
$db->setProfiler(null);

$this->runExceptionTest($db);
}
Expand Down Expand Up @@ -173,4 +174,9 @@ private function runExceptionTest(ConnectionInterface $db): void

$this->assertTrue($thrown, 'An exception should have been thrown by the command.');
}

private function createProfiler(): ProfilerInterface
{
return $this->createMock(ProfilerInterface::class);
}
}

0 comments on commit d7c8553

Please sign in to comment.