mirror of
https://github.com/flarum/core.git
synced 2025-08-17 13:54:18 +02:00
Improved foundational backend unit tests (#1405)
* part one of adding tests, updating core
* Apply fixes from StyleCI
[ci skip] [skip ci]
* we need xdebug for code coverage, and hhvm was already removed
* forgot about the sidecar for mysql completely 🤦
* gitignore removed this installed json we need to fake that we have extensions
* using reguarded closure
This commit is contained in:
@@ -20,4 +20,6 @@ interface DataProviderInterface
|
||||
public function getAdminUser();
|
||||
|
||||
public function getSettings();
|
||||
|
||||
public function isDebugMode(): bool;
|
||||
}
|
||||
|
@@ -23,6 +23,8 @@ class DefaultsDataProvider implements DataProviderInterface
|
||||
'port' => '3306',
|
||||
];
|
||||
|
||||
protected $debug = false;
|
||||
|
||||
protected $baseUrl = 'http://flarum.local';
|
||||
|
||||
protected $adminUser = [
|
||||
@@ -96,4 +98,14 @@ class DefaultsDataProvider implements DataProviderInterface
|
||||
{
|
||||
$this->settings[$key] = $value;
|
||||
}
|
||||
|
||||
public function isDebugMode(): bool
|
||||
{
|
||||
return $this->debug;
|
||||
}
|
||||
|
||||
public function setDebugMode(bool $debug = true)
|
||||
{
|
||||
$this->debug = $debug;
|
||||
}
|
||||
}
|
||||
|
@@ -18,6 +18,7 @@ use Symfony\Component\Yaml\Yaml;
|
||||
class FileDataProvider implements DataProviderInterface
|
||||
{
|
||||
protected $default;
|
||||
protected $debug = false;
|
||||
protected $baseUrl = null;
|
||||
protected $databaseConfiguration = [];
|
||||
protected $adminUser = [];
|
||||
@@ -44,10 +45,11 @@ class FileDataProvider implements DataProviderInterface
|
||||
}
|
||||
|
||||
// Define configuration variables
|
||||
$this->debug = $configuration['debug'] ?? false;
|
||||
$this->baseUrl = isset($configuration['baseUrl']) ? rtrim($configuration['baseUrl'], '/') : null;
|
||||
$this->databaseConfiguration = isset($configuration['databaseConfiguration']) ? $configuration['databaseConfiguration'] : [];
|
||||
$this->adminUser = isset($configuration['adminUser']) ? $configuration['adminUser'] : [];
|
||||
$this->settings = isset($configuration['settings']) ? $configuration['settings'] : [];
|
||||
$this->databaseConfiguration = $configuration['databaseConfiguration'] ?? [];
|
||||
$this->adminUser = $configuration['adminUser'] ?? [];
|
||||
$this->settings = $configuration['settings'] ?? [];
|
||||
} else {
|
||||
throw new Exception('Configuration file does not exist.');
|
||||
}
|
||||
@@ -72,4 +74,9 @@ class FileDataProvider implements DataProviderInterface
|
||||
{
|
||||
return $this->settings + $this->default->getSettings();
|
||||
}
|
||||
|
||||
public function isDebugMode(): bool
|
||||
{
|
||||
return $this->debug;
|
||||
}
|
||||
}
|
||||
|
@@ -138,6 +138,7 @@ class InstallCommand extends AbstractCommand
|
||||
protected function install()
|
||||
{
|
||||
try {
|
||||
$this->debug = $this->dataSource->isDebugMode();
|
||||
$this->dbConfig = $this->dataSource->getDatabaseConfiguration();
|
||||
|
||||
$validation = $this->getValidator()->make(
|
||||
@@ -214,7 +215,7 @@ class InstallCommand extends AbstractCommand
|
||||
$dbConfig = $this->dbConfig;
|
||||
|
||||
$config = [
|
||||
'debug' => false,
|
||||
'debug' => $this->debug,
|
||||
'database' => [
|
||||
'driver' => $dbConfig['driver'],
|
||||
'host' => $dbConfig['host'],
|
||||
|
@@ -109,4 +109,9 @@ class UserDataProvider implements DataProviderInterface
|
||||
|
||||
return $this->questionHelper->ask($this->input, $this->output, $question);
|
||||
}
|
||||
|
||||
public function isDebugMode(): bool
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user