SlickSettingsFormTest.php in Slick Carousel 8.2
File
tests/src/Kernel/Form/SlickSettingsFormTest.php
View source
<?php
namespace Drupal\Tests\slick\Kernel\Form;
use Drupal\Core\Form\FormInterface;
use Drupal\Core\Form\FormState;
use Drupal\KernelTests\KernelTestBase;
use Drupal\slick_ui\Form\SlickSettingsForm;
class SlickSettingsFormTest extends KernelTestBase {
protected $slickSettingsForm;
public static $modules = [
'system',
'file',
'image',
'media',
'blazy',
'slick',
'slick_ui',
];
protected function setUp() {
parent::setUp();
$this
->installConfig(static::$modules);
$this->slickManager = $this->container
->get('slick.manager');
$this->slickSettingsForm = SlickSettingsForm::create($this->container);
}
public function testSlickSettingsForm() {
$form_state = (new FormState())
->setValues([
'slick_css' => TRUE,
'module_css' => TRUE,
]);
$this
->assertInstanceOf(FormInterface::class, $this->slickSettingsForm);
$this
->assertTrue($this->slickManager
->getConfigFactory()
->get('slick.settings')
->get('slick_css'));
$id = $this->slickSettingsForm
->getFormId();
$this
->assertEquals('slick_settings_form', $id);
$method = new \ReflectionMethod(SlickSettingsForm::class, 'getEditableConfigNames');
$method
->setAccessible(TRUE);
$name = $method
->invoke($this->slickSettingsForm);
$this
->assertEquals([
'slick.settings',
], $name);
$form = $this->slickSettingsForm
->buildForm([], $form_state);
$this->slickSettingsForm
->submitForm($form, $form_state);
}
}