Unverified Commit 3c5fc5f3 authored by Alex Pott's avatar Alex Pott
Browse files

task: #3517299 Convert functional tests in help module to kernel tests

By: mstrelan
By: dww
By: joachim
By: alexpott
(cherry picked from commit 2129f980)
parent 89337e25
Loading
Loading
Loading
Loading
Loading
+7 −7
Original line number Diff line number Diff line
@@ -16426,28 +16426,28 @@
	'path' => __DIR__ . '/modules/help/src/HelpTopicTwigLoader.php',
];
$ignoreErrors[] = [
	'message' => '#^Method Drupal\\\\Tests\\\\help\\\\Functional\\\\HelpTopicTest\\:\\:assertBreadcrumb\\(\\) has no return type specified\\.$#',
	'message' => '#^Method Drupal\\\\Tests\\\\help\\\\Kernel\\\\HelpTopicTest\\:\\:assertBreadcrumb\\(\\) has no return type specified\\.$#',
	'identifier' => 'missingType.return',
	'count' => 1,
	'path' => __DIR__ . '/modules/help/tests/src/Functional/HelpTopicTest.php',
	'path' => __DIR__ . '/modules/help/tests/src/Kernel/HelpTopicTest.php',
];
$ignoreErrors[] = [
	'message' => '#^Method Drupal\\\\Tests\\\\help\\\\Functional\\\\HelpTopicTest\\:\\:assertBreadcrumbParts\\(\\) has no return type specified\\.$#',
	'message' => '#^Method Drupal\\\\Tests\\\\help\\\\Kernel\\\\HelpTopicTest\\:\\:assertBreadcrumbParts\\(\\) has no return type specified\\.$#',
	'identifier' => 'missingType.return',
	'count' => 1,
	'path' => __DIR__ . '/modules/help/tests/src/Functional/HelpTopicTest.php',
	'path' => __DIR__ . '/modules/help/tests/src/Kernel/HelpTopicTest.php',
];
$ignoreErrors[] = [
	'message' => '#^Method Drupal\\\\Tests\\\\help\\\\Functional\\\\HelpTopicTest\\:\\:assertMenuActiveTrail\\(\\) has no return type specified\\.$#',
	'message' => '#^Method Drupal\\\\Tests\\\\help\\\\Kernel\\\\HelpTopicTest\\:\\:assertMenuActiveTrail\\(\\) has no return type specified\\.$#',
	'identifier' => 'missingType.return',
	'count' => 1,
	'path' => __DIR__ . '/modules/help/tests/src/Functional/HelpTopicTest.php',
	'path' => __DIR__ . '/modules/help/tests/src/Kernel/HelpTopicTest.php',
];
$ignoreErrors[] = [
	'message' => '#^Variable \\$parts in empty\\(\\) always exists and is always falsy\\.$#',
	'identifier' => 'empty.variable',
	'count' => 1,
	'path' => __DIR__ . '/modules/help/tests/src/Functional/HelpTopicTest.php',
	'path' => __DIR__ . '/modules/help/tests/src/Kernel/HelpTopicTest.php',
];
$ignoreErrors[] = [
	'message' => '#^Method Drupal\\\\Tests\\\\help\\\\Unit\\\\HelpTopicTwigTest\\:\\:getTwigMock\\(\\) has no return type specified\\.$#',
+15 −13
Original line number Diff line number Diff line
@@ -2,9 +2,12 @@

declare(strict_types=1);

namespace Drupal\Tests\help\Functional;
namespace Drupal\Tests\help\Kernel;

use Drupal\Tests\BrowserTestBase;
use Drupal\KernelTests\KernelTestBase;
use Drupal\Tests\HttpKernelUiHelperTrait;
use Drupal\Tests\user\Traits\UserCreationTrait;
use Drupal\user\UserInterface;
use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\Attributes\RunTestsInSeparateProcesses;

@@ -13,7 +16,10 @@
 */
#[Group('help')]
#[RunTestsInSeparateProcesses]
class ExperimentalHelpTest extends BrowserTestBase {
class ExperimentalHelpTest extends KernelTestBase {

  use HttpKernelUiHelperTrait;
  use UserCreationTrait;

  /**
   * Modules to install.
@@ -27,33 +33,29 @@ class ExperimentalHelpTest extends BrowserTestBase {
    'help',
    'experimental_module_test',
    'help_page_test',
    'user',
    'system',
  ];

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

  /**
   * The admin user.
   *
   * @var \Drupal\user\UserInterface
   */
  protected $adminUser;
  protected UserInterface $adminUser;

  /**
   * {@inheritdoc}
   */
  protected function setUp(): void {
    parent::setUp();
    $this->adminUser = $this->drupalCreateUser(['access help pages']);
    $this->installEntitySchema('user');
    $this->adminUser = $this->createUser(['access help pages']);
    $this->setCurrentUser($this->adminUser);
  }

  /**
   * Verifies that a warning message is displayed for experimental modules.
   */
  public function testExperimentalHelp(): void {
    $this->drupalLogin($this->adminUser);
    $this->drupalGet('admin/help/experimental_module_test');
    $this->assertSession()->statusMessageContains('This module is experimental.', 'warning');

+13 −8
Original line number Diff line number Diff line
@@ -2,9 +2,11 @@

declare(strict_types=1);

namespace Drupal\Tests\help\Functional;
namespace Drupal\Tests\help\Kernel;

use Drupal\Tests\BrowserTestBase;
use Drupal\KernelTests\KernelTestBase;
use Drupal\Tests\block\Traits\BlockCreationTrait;
use Drupal\Tests\HttpKernelUiHelperTrait;
use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\Attributes\RunTestsInSeparateProcesses;

@@ -13,7 +15,10 @@
 */
#[Group('help')]
#[RunTestsInSeparateProcesses]
class HelpBlockTest extends BrowserTestBase {
class HelpBlockTest extends KernelTestBase {

  use HttpKernelUiHelperTrait;
  use BlockCreationTrait;

  /**
   * {@inheritdoc}
@@ -23,13 +28,10 @@ class HelpBlockTest extends BrowserTestBase {
    'help_page_test',
    'block',
    'more_help_page_test',
    'system',
    'user',
  ];

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

  /**
   * The help block instance.
   *
@@ -42,6 +44,9 @@ class HelpBlockTest extends BrowserTestBase {
   */
  protected function setUp(): void {
    parent::setUp();
    $this->installEntitySchema('block');
    $this->container->get('theme_installer')->install(['stark']);
    $this->config('system.theme')->set('default', 'stark')->save();
    $this->helpBlock = $this->placeBlock('help_block');
  }

+12 −13
Original line number Diff line number Diff line
@@ -2,9 +2,11 @@

declare(strict_types=1);

namespace Drupal\Tests\help\Functional;
namespace Drupal\Tests\help\Kernel;

use Drupal\Tests\BrowserTestBase;
use Drupal\KernelTests\KernelTestBase;
use Drupal\Tests\HttpKernelUiHelperTrait;
use Drupal\Tests\user\Traits\UserCreationTrait;
use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\Attributes\RunTestsInSeparateProcesses;

@@ -13,24 +15,22 @@
 */
#[Group('help')]
#[RunTestsInSeparateProcesses]
class HelpPageOrderTest extends BrowserTestBase {
class HelpPageOrderTest extends KernelTestBase {

  /**
   * {@inheritdoc}
   */
  protected static $modules = ['help', 'help_page_test'];
  use HttpKernelUiHelperTrait;
  use UserCreationTrait;

  /**
   * {@inheritdoc}
   */
  protected $defaultTheme = 'stark';
  protected static $modules = ['help', 'help_page_test', 'system', 'user'];

  /**
   * Strings to search for on admin/help, in order.
   *
   * @var string[]
   */
  protected $stringOrder = [
  protected array $stringOrder = [
    'Module overviews are provided',
    'This description should appear',
  ];
@@ -40,14 +40,13 @@ class HelpPageOrderTest extends BrowserTestBase {
   */
  protected function setUp(): void {
    parent::setUp();
    $this->installEntitySchema('user');

    // Create and log in user.
    $account = $this->drupalCreateUser([
    $account = $this->createUser([
      'access help pages',
      'view the administration theme',
      'administer permissions',
    ]);
    $this->drupalLogin($account);
    $this->setCurrentUser($account);
  }

  /**
+2 −7
Original line number Diff line number Diff line
@@ -2,7 +2,7 @@

declare(strict_types=1);

namespace Drupal\Tests\help\Functional;
namespace Drupal\Tests\help\Kernel;

use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\Attributes\RunTestsInSeparateProcesses;
@@ -19,11 +19,6 @@ class HelpPageReverseOrderTest extends HelpPageOrderTest {
   */
  protected static $modules = ['more_help_page_test'];

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

  /**
   * Strings to search for on admin/help, in order.
   *
@@ -31,7 +26,7 @@ class HelpPageReverseOrderTest extends HelpPageOrderTest {
   *
   * @var string[]
   */
  protected $stringOrder = [
  protected array $stringOrder = [
    'This description should appear',
    'Module overviews are provided',
  ];
Loading