improvements-2.x-dev/modules/improvements_site_information/tests/src/Functional/ImprovementsSiteInformationTest.php

modules/improvements_site_information/tests/src/Functional/ImprovementsSiteInformationTest.php
<?php

namespace Drupal\Tests\improvements_site_information\Functional;

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

class ImprovementsSiteInformationTest extends BrowserTestBase {

  use ImprovementsTestTrait;

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

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

  /**
   * {@inheritDoc}
   */
  protected function setUp(): void {
    parent::setUp();
  }

  /**
   * Test third party site information.
   */
  public function testSiteInformationThirdPartySettings(): void {
    $this->drupalLoginAsRoot();
    $this->drupalGet('/admin/config/system/site-information');
    $this->dontSeeErrorMessage();
    $web_assert = $this->assertSession();
    $web_assert->fieldExists('company_name');
    $web_assert->fieldExists('mail_for_notifications');
    $web_assert->fieldExists('phone');

    $this->submitForm([
      'company_name' => 'OOO ' . __FUNCTION__,
      'mail_for_notifications' => __FUNCTION__ . '@example.com',
      'phone' => '123456789',
    ], 'Save configuration');
    $this->drupalGet('/admin/config/system/site-information');
    $this->dontSeeErrorMessage();
    $web_assert->fieldValueEquals('company_name', 'OOO ' . __FUNCTION__);
    $web_assert->fieldValueEquals('mail_for_notifications', __FUNCTION__ . '@example.com');
    $web_assert->fieldValueEquals('phone', '123456789');
  }

  /**
   * Test tokens [site:third_party_setting_name].
   */
  public function testTokenSiteThirdPartySettings(): void {
    $config_factory = $this->container->get('config.factory');
    $token_service = $this->container->get('token');

    $config_factory->getEditable('system.site')
      ->set('improvements.company_name', 'OOO ' . __FUNCTION__)
      ->set('improvements.mail_for_notifications', __FUNCTION__ . '@example.com')
      ->set('improvements.phone', '321654987')
      ->save();
    $this->assertEquals('OOO ' . __FUNCTION__, $token_service->replace('[site:company_name]'));
    $this->assertEquals(__FUNCTION__ . '@example.com', $token_service->replace('[site:mail_for_notifications]'));
    $this->assertEquals('321654987', $token_service->replace('[site:phone]'));
  }

}

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

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