Commit 5f26b44c authored by Adam G-H's avatar Adam G-H
Browse files

Issue #3303703 by phenaproxima: Deprecate the ComponentDiscovery class

parent 763ad748
Loading
Loading
Loading
Loading
+1 −0
Changes for src/ComponentDiscovery.php: 1 added line, 0 removed lines.
Original line number Diff line number Diff line
@@ -43,6 +43,7 @@ class ComponentDiscovery {
   *   The application root directory.
   */
  public function __construct($app_root) {
    @trigger_error(__CLASS__ . ' is deprecated in lightning_core:6.0.0 and removed in lightning_core:7.0.0. There is no replacement. See https://www.drupal.org/node/3303704', E_USER_DEPRECATED);
    $this->discovery = new ExtensionDiscovery($app_root);
  }

+0 −74
Changes for tests/src/Kernel/ComponentDiscoveryTest.php: 0 added lines, 74 removed lines.
Original line number Diff line number Diff line
<?php

namespace Drupal\Tests\lightning_core\Kernel;

use Drupal\Core\Extension\Extension;
use Drupal\KernelTests\KernelTestBase;
use Drupal\lightning_core\ComponentDiscovery;

/**
 * @group lightning
 * @group lightning_core
 *
 * @coversDefaultClass \Drupal\lightning_core\ComponentDiscovery
 */
class ComponentDiscoveryTest extends KernelTestBase {

  /**
   * The ComponentDiscovery under test.
   *
   * @var \Drupal\lightning_core\ComponentDiscovery
   */
  protected $discovery;

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

    $this->discovery = new ComponentDiscovery(
      $this->container->get('app.root')
    );
  }

  /**
   * @covers ::getAll
   */
  public function testGetAll() {
    $components = $this->discovery->getAll();

    $this->assertInstanceOf(Extension::class, $components['lightning_core']);
    $this->assertInstanceOf(Extension::class, $components['lightning_search']);
    $this->assertArrayNotHasKey('panels', $components);
    $this->assertArrayNotHasKey('views', $components);
  }

  /**
   * @covers ::getMainComponents
   */
  public function testGetMainComponents() {
    $components = $this->discovery->getMainComponents();

    $this->assertInstanceOf(Extension::class, $components['lightning_core']);

    $this->assertArrayNotHasKey('lightning_contact_form', $components);
    $this->assertArrayNotHasKey('lightning_page', $components);
    $this->assertArrayNotHasKey('lightning_roles', $components);
    $this->assertArrayNotHasKey('lightning_search', $components);
  }

  /**
   * @covers ::getSubComponents
   */
  public function testGetSubComponents() {
    $components = $this->discovery->getSubComponents();

    $this->assertInstanceOf(Extension::class, $components['lightning_contact_form']);
    $this->assertInstanceOf(Extension::class, $components['lightning_page']);
    $this->assertInstanceOf(Extension::class, $components['lightning_roles']);
    $this->assertInstanceOf(Extension::class, $components['lightning_search']);
    $this->assertArrayNotHasKey('lightning_core', $components);
  }

}