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

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

namespace Drupal\Tests\api\Functional;

/**
 * Test whether an empty class inherits properly.
 *
 * @group api
 */
class EmptyClassTest extends TestBase {

  /**
   * Set up the branch just with the folder we need for this test.
   */
  protected function setUpBranchApiCall($prefix = NULL, $default = TRUE, array $info = []) {
    $base_path = $prefix ?? $this->apiModulePath;
    $info['directory'] = $base_path . '/tests/files/plugin';
    return parent::setUpBranchApiCall($prefix, $default, $info);
  }

  /**
   * Test if members are filled.
   */
  public function testPluginFilled() {
    $result = \Drupal::database()->query('
        SELECT member.object_name AS member, class.namespaced_name AS class
        FROM {api_branch_docblock_class_member} dcm
        INNER JOIN {api_branch_docblock} member ON dcm.docblock = member.id
        INNER JOIN {api_branch_docblock} class ON dcm.class_docblock = class.id
        ORDER BY class, member');
    $members = [];
    foreach ($result as $row) {
      $members[$row->class][] = $row->member;
    }
    foreach (['\Drupal\Core\Messenger\MessengerTrait', '\Drupal\Component\Plugin\PluginBase'] as $class) {
      // Make sure there are actually members in the class Core\PluginBase
      // inherits from otherwise this test asserts nothing.
      $this->assertTrue(count($members[$class]) > 0);
      // The core plugin class has no members on its own.
      foreach ($members[$class] as $member) {
        $this->assertTrue(in_array($member, $members['\Drupal\Core\Plugin\PluginBase']));
      }
    }
  }

}

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

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