Commit 4d2ba594 authored by Thalles Ferreira's avatar Thalles Ferreira Committed by Damien McKenna
Browse files

Issue #3103725 by thalles: Create kernel test to Form\MetatagSettingsForm.

parent e5eca776
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
Metatag 8.x-1.x-dev, xxxx-xx-xx
-------------------------------
#3102937 by yasmeensalah, Berdir: Plugin AlternateHandheld is misnamed.
#3103725 by thalles: Create kernel test to Form\MetatagSettingsForm.


Metatag 8.x-1.11, 2019-12-20
+64 −0
Original line number Diff line number Diff line
<?php

namespace Drupal\Tests\metatag\Kernel\Form;

use Drupal\Core\Form\FormInterface;
use Drupal\KernelTests\KernelTestBase;
use Drupal\metatag\Form\MetatagSettingsForm;

/**
 * Tests the metatag settings form.
 *
 * @coversDefaultClass \Drupal\metatag\Form\MetatagSettingsForm
 *
 * @group metatag
 */
class MetatagSettingsFormTest extends KernelTestBase {

  /**
   * The metatag form object under test.
   *
   * @var \Drupal\metatag\Form\MetatagSettingsForm
   */
  protected $metatagSettingsForm;

  /**
   * Modules to enable.
   *
   * @var array
   */
  public static $modules = [
    'system',
    'metatag',
  ];

  /**
   * {@inheritdoc}
   *
   * @covers ::__construct
   */
  protected function setUp() {
    parent::setUp();

    $this->installConfig(static::$modules);
    $this->metatagSettingsForm = new MetatagSettingsForm(
      $this->container->get('config.factory')
    );
  }

  /**
   * Tests for \Drupal\metatag\Form\MetatagSettingsForm.
   */
  public function testMetatagSettingsForm() {
    $this->assertInstanceOf(FormInterface::class, $this->metatagSettingsForm);

    $this->assertEquals('metatag_admin_settings', $this->metatagSettingsForm->getFormId());

    $method = new \ReflectionMethod(MetatagSettingsForm::class, 'getEditableConfigNames');
    $method->setAccessible(TRUE);

    $name = $method->invoke($this->metatagSettingsForm);
    $this->assertEquals(['metatag.settings'], $name);
  }

}