api-8.x-1.x-dev/tests/src/Functional/BranchSupportedTest.php

tests/src/Functional/BranchSupportedTest.php
<?php

namespace Drupal\Tests\api\Functional;

/**
 * Tests the supported attribute for branches.
 *
 * @group api
 */
class BranchSupportedTest extends WebPagesBase {

  /**
   * Array of branch information for the non-supported branch.
   *
   * @var array
   */
  protected $branchNotSupported;

  /**
   * Array of branch information for the supported branch.
   *
   * @var array
   */
  protected $branchSupported;

  /**
   * Array of branch information for the supported and preferred branch.
   *
   * @var array
   */
  protected $branchSupportedPreferred;

  /**
   * {@inheritdoc}
   */
  protected function setUp() : void {
    $this->baseSetUp();

    // Set up three branches for all three cases.
    $this->branchNotSupported = $this->setUpBranchUi(NULL, FALSE, [
      'supported' => FALSE,
      'branch_name' => 'test1',
    ]);
    $this->branchSupported = $this->setUpBranchUi(NULL, FALSE, [
      'supported' => TRUE,
      'branch_name' => 'test2',
    ]);
    $this->branchSupportedPreferred = $this->setUpBranchUi(NULL, TRUE, [
      'supported' => TRUE,
      'branch_name' => 'test3',
    ]);

    // We don't need the PHP branch for this test, so for speed, remove it.
    $this->removePhpBranch();

    // Parse the code.
    $this->clearCache();
    $this->cronRun();
    $this->processApiParseQueue();
  }

  /**
   * Tests that the supported and preferred messages show up when needed.
   */
  public function testSupported() {
    // Not supported.
    $this->drupalGet('api/' . $this->branchNotSupported['project'] . '/' . $this->branchNotSupported['branch_name']);
    $this->assertSession()->responseContains('not supported anymore');

    // Supported not preferred.
    $this->drupalGet('api/' . $this->branchSupported['project'] . '/' . $this->branchSupported['branch_name']);
    $this->assertSession()->responseContains('supported, but is not the latest');

    // Supported and preferred.
    $this->drupalGet('api/' . $this->branchSupportedPreferred['project'] . '/' . $this->branchSupportedPreferred['branch_name']);
    $this->assertSession()->responseNotContains('not supported anymore');
    $this->assertSession()->responseNotContains('supported, but is not the latest');
  }

}

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

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