tests: add test start/end markers to log and dump all SQL at end
This commit is contained in:
parent
af4fd62b55
commit
338d02a2f6
|
|
@ -24,6 +24,7 @@ abstract class Base extends PHPUnit\Framework\TestCase
|
|||
{
|
||||
date_default_timezone_set('UTC');
|
||||
$_SESSION = array();
|
||||
$test = get_class($this)."::".$this->getName();
|
||||
|
||||
if (DB_DRIVER === 'mysql') {
|
||||
$pdo = new PDO('mysql:host='.DB_HOSTNAME, DB_USERNAME, DB_PASSWORD);
|
||||
|
|
@ -50,6 +51,7 @@ abstract class Base extends PHPUnit\Framework\TestCase
|
|||
$this->container->register(new Kanboard\ServiceProvider\FormatterProvider());
|
||||
$this->container->register(new Kanboard\ServiceProvider\JobProvider());
|
||||
$this->container->register(new Kanboard\ServiceProvider\QueueProvider());
|
||||
$this->container->register(new Kanboard\ServiceProvider\LoggingProvider());
|
||||
$this->container->register(new Kanboard\ServiceProvider\ExternalTaskProvider());
|
||||
|
||||
$this->container['dispatcher'] = new TraceableEventDispatcher(
|
||||
|
|
@ -60,7 +62,6 @@ abstract class Base extends PHPUnit\Framework\TestCase
|
|||
$this->dispatcher = $this->container['dispatcher'];
|
||||
|
||||
$this->container['db']->getStatementHandler()->withLogging();
|
||||
$this->container['logger'] = new Logger();
|
||||
$this->container['cli'] = new \Symfony\Component\Console\Application('Kanboard', 'test');
|
||||
|
||||
$this->container['httpClient'] = $this
|
||||
|
|
@ -96,11 +97,18 @@ abstract class Base extends PHPUnit\Framework\TestCase
|
|||
$loader = new ClassLoader();
|
||||
$loader->addPsr4('Kanboard\Plugin\\', PLUGINS_DIR);
|
||||
$loader->register();
|
||||
|
||||
$this->container['logger']->debug("Finished setUp() for test $test");
|
||||
}
|
||||
|
||||
protected function tearDown(): void
|
||||
{
|
||||
$test = get_class($this)."::".$this->getName();
|
||||
foreach ($this->container['db']->getLogMessages() as $msg) {
|
||||
$this->container['logger']->debug('SQL: '.$msg);
|
||||
}
|
||||
$this->container['db']->closeConnection();
|
||||
$this->container['logger']->debug("Finishing tearDown() for test $test");
|
||||
unset ($this->container);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue