class IconPackExtractorFormTest

@coversDefaultClass \Drupal\Core\Theme\Icon\IconPackExtractorForm

@group icon

Hierarchy

Expanded class hierarchy of IconPackExtractorFormTest

File

core/tests/Drupal/Tests/Core/Theme/Icon/IconPackExtractorFormTest.php, line 17

Namespace

Drupal\Tests\Core\Theme\Icon
View source
class IconPackExtractorFormTest extends UnitTestCase {
  
  /**
   * The icon pack form.
   *
   * @var \Drupal\Core\Theme\Icon\IconPackExtractorForm
   */
  private IconPackExtractorForm $iconPackForm;
  
  /**
   * The plugin form.
   *
   * @var \Drupal\Core\Plugin\PluginWithFormsInterface
   */
  private PluginWithFormsInterface $plugin;
  
  /**
   * The form state.
   *
   * @var \Drupal\Core\Form\FormStateInterface|\Prophecy\Prophecy\ObjectProphecy
   */
  private $formState;
  
  /**
   * {@inheritdoc}
   */
  protected function setUp() : void {
    parent::setUp();
    $this->plugin = new TestPluginWithForm();
    $this->formState = $this->prophesize(FormStateInterface::class);
    $this->iconPackForm = new IconPackExtractorForm();
    $this->iconPackForm
      ->setPlugin($this->plugin);
  }
  
  /**
   * Test the IconPackExtractorForm::buildConfigurationForm method.
   */
  public function testBuildConfigurationForm() : void {
    $form = [
      'test_form' => 'test_form',
    ];
    /** @var \Drupal\Core\Form\FormStateInterface $formState */
    $formState = $this->formState
      ->reveal();
    $result = $this->iconPackForm
      ->buildConfigurationForm($form, $formState);
    $this->assertSame('plugin_build_form', $result['plugin_build_form']);
    $this->assertSame($form['test_form'], $result['test_form']);
  }
  
  /**
   * Test the IconPackExtractorForm::validateConfigurationForm method.
   */
  public function testValidateConfigurationForm() : void {
    $form = [];
    /** @var \Drupal\Core\Form\FormStateInterface $formState */
    $formState = $this->formState
      ->reveal();
    $this->iconPackForm
      ->validateConfigurationForm($form, $formState);
    $this->assertArrayHasKey('plugin_validate_form', $form);
  }
  
  /**
   * Test the IconPackExtractorForm::submitConfigurationForm method.
   */
  public function testSubmitConfigurationForm() : void {
    $form = [];
    /** @var \Drupal\Core\Form\FormStateInterface $formState */
    $formState = $this->formState
      ->reveal();
    $this->iconPackForm
      ->submitConfigurationForm($form, $formState);
    $this->assertArrayHasKey('plugin_submit_form', $form);
  }

}

Members

Title Sort descending Modifiers Object type Summary Overriden Title
ExpectDeprecationTrait::expectDeprecation public function Adds an expected deprecation.
ExpectDeprecationTrait::setUpErrorHandler public function Sets up the test error handler.
ExpectDeprecationTrait::tearDownErrorHandler public function Tears down the test error handler.
IconPackExtractorFormTest::$formState private property The form state.
IconPackExtractorFormTest::$iconPackForm private property The icon pack form.
IconPackExtractorFormTest::$plugin private property The plugin form.
IconPackExtractorFormTest::setUp protected function Overrides UnitTestCase::setUp
IconPackExtractorFormTest::testBuildConfigurationForm public function Test the IconPackExtractorForm::buildConfigurationForm method.
IconPackExtractorFormTest::testSubmitConfigurationForm public function Test the IconPackExtractorForm::submitConfigurationForm method.
IconPackExtractorFormTest::testValidateConfigurationForm public function Test the IconPackExtractorForm::validateConfigurationForm method.
RandomGeneratorTrait::getRandomGenerator protected function Gets the random generator for the utility methods.
RandomGeneratorTrait::randomMachineName protected function Generates a unique random string containing letters and numbers.
RandomGeneratorTrait::randomObject public function Generates a random PHP object.
RandomGeneratorTrait::randomString public function Generates a pseudo-random string of ASCII characters of codes 32 to 126.
UnitTestCase::$root protected property The app root.
UnitTestCase::getClassResolverStub protected function Returns a stub class resolver.
UnitTestCase::getConfigFactoryStub public function Returns a stub config factory that behaves according to the passed array.
UnitTestCase::getContainerWithCacheTagsInvalidator protected function Sets up a container with a cache tags invalidator.
UnitTestCase::getStringTranslationStub public function Returns a stub translation manager that just returns the passed string.
UnitTestCase::setDebugDumpHandler public static function Registers the dumper CLI handler when the DebugDump extension is enabled.
UnitTestCase::setupMockIterator protected function Set up a traversable class mock to return specific items when iterated.

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.