X-Git-Url: https://yaffs.net/gitweb/?a=blobdiff_plain;ds=sidebyside;f=web%2Fmodules%2Fcontrib%2Fblazy%2Ftests%2Fsrc%2FKernel%2FForm%2FBlazySettingsFormTest.php;fp=web%2Fmodules%2Fcontrib%2Fblazy%2Ftests%2Fsrc%2FKernel%2FForm%2FBlazySettingsFormTest.php;h=ad5d535d23f5393de86289f90020edf1cccbc309;hb=eba34333e3c89f208d2f72fa91351ad019a71583;hp=0000000000000000000000000000000000000000;hpb=a2bd1bf0c2c1f1a17d188f4dc0726a45494cefae;p=yaffs-website diff --git a/web/modules/contrib/blazy/tests/src/Kernel/Form/BlazySettingsFormTest.php b/web/modules/contrib/blazy/tests/src/Kernel/Form/BlazySettingsFormTest.php new file mode 100644 index 000000000..ad5d535d2 --- /dev/null +++ b/web/modules/contrib/blazy/tests/src/Kernel/Form/BlazySettingsFormTest.php @@ -0,0 +1,100 @@ +installConfig(static::$modules); + + $this->blazyManager = $this->container->get('blazy.manager'); + + $this->blazySettingsForm = new BlazySettingsForm( + $this->blazyManager->getConfigFactory() + ); + } + + /** + * Tests for \Drupal\blazy_ui\Form\BlazySettingsForm. + * + * @covers ::getFormId + * @covers ::getEditableConfigNames + * @covers ::buildForm + * @covers ::submitForm + */ + public function testBlazySettingsForm() { + // Emulate a form state of a submitted form. + $form_state = (new FormState())->setValues([ + 'admin_css' => TRUE, + 'responsive_image' => FALSE, + ]); + + $this->assertInstanceOf(FormInterface::class, $this->blazySettingsForm); + $this->assertTrue($this->blazyManager->getConfigFactory()->get('blazy.settings')->get('admin_css')); + + $id = $this->blazySettingsForm->getFormId(); + $this->assertEquals('blazy_settings', $id); + + $method = new \ReflectionMethod(BlazySettingsForm::class, 'getEditableConfigNames'); + $method->setAccessible(TRUE); + + $name = $method->invoke($this->blazySettingsForm); + $this->assertEquals(['blazy.settings'], $name); + + $form = $this->blazySettingsForm->buildForm([], $form_state); + $this->blazySettingsForm->submitForm($form, $form_state); + } + +} + +namespace Drupal\blazy_ui\Form; + +if (!function_exists('drupal_set_message')) { + + /** + * Dummy function. + */ + function drupal_set_message() { + // Empty block to satisfy coder. + } + +}