function RequireEventTraitTest::testGetPackages

Tests that runtime and dev packages are keyed correctly.

@dataProvider providerGetPackages

Parameters

string[] $runtime_packages: The runtime package constraints passed to the event constructor.

string[] $dev_packages: The dev package constraints passed to the event constructor.

string[] $expected_runtime_packages: The keyed runtime packages that should be returned by ::getRuntimePackages().

string[] $expected_dev_packages: The keyed dev packages that should be returned by ::getDevPackages().

File

core/modules/package_manager/tests/src/Unit/RequireEventTraitTest.php, line 31

Class

RequireEventTraitTest
@covers \Drupal\package_manager\Event\RequireEventTrait @group package_manager @internal

Namespace

Drupal\Tests\package_manager\Unit

Code

public function testGetPackages(array $runtime_packages, array $dev_packages, array $expected_runtime_packages, array $expected_dev_packages) : void {
    $stage = $this->createMock('\\Drupal\\package_manager\\StageBase');
    $events = [
        '\\Drupal\\package_manager\\Event\\PostRequireEvent',
        '\\Drupal\\package_manager\\Event\\PreRequireEvent',
    ];
    foreach ($events as $event) {
        
        /** @var \Drupal\package_manager\Event\RequireEventTrait $event */
        $event = new $event($stage, $runtime_packages, $dev_packages);
        $this->assertSame($expected_runtime_packages, $event->getRuntimePackages());
        $this->assertSame($expected_dev_packages, $event->getDevPackages());
    }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.