feat(test): Make it possible to extend SetupScript (#3643)

* Make it possible to extend Flarum\Testing\integration\Setup\SetupScript and added public methods to add settings or extensions to in initial installation pipeline

* Fix syntax error, unexpected 'static'

* Remove `addExtensions` method and document `addSettings`
This commit is contained in:
Rafael Horvat 2022-09-23 13:44:17 +02:00 committed by GitHub
parent 267f6759f8
commit 7ce9d63ed6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -66,7 +66,13 @@ class SetupScript
/**
* @var DatabaseConfig
*/
private $dbConfig;
protected $dbConfig;
/**
* Settings to be applied during installation.
* @var array
*/
protected $settings = ['mail_driver' => 'log'];
public function __construct()
{
@ -124,7 +130,7 @@ class SetupScript
'password',
'admin@machine.local'
))
->settings(['mail_driver' => 'log'])
->settings($this->settings)
->extensions([])
->build();
@ -145,4 +151,20 @@ class SetupScript
$builder->dropAllViews();
}))->run();
}
/**
* Can be used to add settings to the Flarum installation.
* Use this only when it is really needed.
* This can be useful in rare cases where the settings are required to be set
* already when extensions Extenders are executed. In those cases, setting the
* settings with the `setting()` method of the `TestCase` will not work.
*
* @param string $settings (key => value)
*/
public function addSettings(array $settings): self
{
$this->settings = array_merge($this->settings, $settings);
return $this;
}
}