improvements-2.x-dev/modules/improvements_node/tests/src/Functional/ImprovementsNodeTest.php

modules/improvements_node/tests/src/Functional/ImprovementsNodeTest.php
<?php

namespace Drupal\Tests\improvements_node\Functional;

use Drupal\Tests\BrowserTestBase;
use Drupal\Tests\improvements\Traits\ImprovementsTestTrait;
use Drupal\Tests\node\Traits\NodeCreationTrait;

class ImprovementsNodeTest extends BrowserTestBase {

  use ImprovementsTestTrait;
  use NodeCreationTrait;

  /**
   * {@inheritDoc}
   */
  protected $defaultTheme = 'stark';

  /**
   * {@inheritDoc}
   */
  protected static $modules = ['improvements_node'];

  /**
   * {@inheritDoc}
   */
  protected function setUp(): void {
    parent::setUp();
    $this->createContentType(['type' => 'page', 'name' => 'Page']);
  }

  /**
   * Test node improvements.
   *
   * @TODO Separate to small tests
   */
  public function testNodeImprovements(): void {
    $this->installModule('field', 'field_ui');
    $this->drupalLoginAsRoot();
    $web_assert = $this->assertSession();

    // Test "Node form" without advances settings
    $this->drupalGet('/node/add/page');
    $this->dontSeeErrorMessage();
    $web_assert->elementExists('css', '#edit-revision-information');
    $web_assert->elementExists('css', '.entity-content-form-footer .field--name-status');
    $web_assert->elementAttributeExists('css', '#edit-title-0-value', 'autofocus');

    // Test "Node type form"
    $this->drupalGet('/admin/structure/types/manage/page');
    $this->dontSeeErrorMessage();
    $web_assert->elementExists('css', '#edit-hide-revision-group');
    $web_assert->elementExists('css', '#edit-move-status-to-vertical-tab');

    // Test change advanced settings in "Node type form"
    $this->submitForm([
      'options[revision]' => FALSE,
      'hide_revision_group' => TRUE,
      'move_status_to_vertical_tab' => TRUE,
    ], 'Save');
    $this->dontSeeErrorMessage();
    $this->drupalGet('/admin/structure/types/manage/page');
    $this->dontSeeErrorMessage();
    $web_assert->checkboxChecked('hide_revision_group');
    $web_assert->checkboxChecked('move_status_to_vertical_tab');

    // Test "Node form" with advanced settings
    $this->drupalGet('/node/add/page');
    $this->dontSeeErrorMessage();
    $web_assert->elementNotExists('css', '#edit-revision-information');
    $web_assert->elementNotExists('css', '.entity-content-form-footer .field--name-status');
    $web_assert->elementExists('css', '#edit-options .field--name-status');

    // Test "Node form" default settings
    $this->drupalGet('/admin/structure/types/add');
    $this->dontSeeErrorMessage();
    // @TODO Fix
    //$web_assert->checkboxNotChecked('menu_options[main]');
    $web_assert->elementAttributeExists('css', '#edit-preview-mode-0', 'checked');
    $web_assert->checkboxNotChecked('options[promote]');
    $web_assert->checkboxNotChecked('options[revision]');
    $web_assert->checkboxNotChecked('display_submitted');

    // Test "Title" field in display options
    $this->drupalGet('/admin/structure/types/manage/page/display');
    $this->dontSeeErrorMessage();
    $web_assert->elementExists('css', 'tr#title');
    $web_assert->fieldExists('fields[title][type]');
    // @TODO Check render field in node page
  }

}

Главная | Обратная связь

drupal hosting | друпал хостинг | it patrol .inc