class ExtensionListCommandTest
Tests the 'ex:list' command.
Attributes
#[Group('Console')]
#[RunTestsInSeparateProcesses]
#[CoversClass(ExtensionListCommand::class)]
Hierarchy
- class \Drupal\Tests\DrupalTestCase uses \Drupal\Tests\DrupalTestCaseTrait extends \PHPUnit\Framework\TestCase
- class \Drupal\KernelTests\KernelTestBase implements \Drupal\Core\DependencyInjection\ServiceProviderInterface uses \Drupal\KernelTests\AssertContentTrait, \Drupal\Tests\RandomGeneratorTrait, \Drupal\Tests\ConfigTestTrait, \Drupal\Tests\ExtensionListTestTrait, \Prophecy\PhpUnit\ProphecyTrait, \Drupal\Tests\BrowserHtmlDebugTrait, \Drupal\Tests\HttpKernelUiHelperTrait extends \Drupal\Tests\DrupalTestCase
- class \Drupal\Tests\system\Kernel\Command\ExtensionListCommandTest uses \Drupal\KernelTests\DrupalApplicationTesterTrait extends \Drupal\KernelTests\KernelTestBase
- class \Drupal\KernelTests\KernelTestBase implements \Drupal\Core\DependencyInjection\ServiceProviderInterface uses \Drupal\KernelTests\AssertContentTrait, \Drupal\Tests\RandomGeneratorTrait, \Drupal\Tests\ConfigTestTrait, \Drupal\Tests\ExtensionListTestTrait, \Prophecy\PhpUnit\ProphecyTrait, \Drupal\Tests\BrowserHtmlDebugTrait, \Drupal\Tests\HttpKernelUiHelperTrait extends \Drupal\Tests\DrupalTestCase
Expanded class hierarchy of ExtensionListCommandTest
File
-
core/
modules/ system/ tests/ src/ Kernel/ Command/ ExtensionListCommandTest.php, line 18
Namespace
Drupal\Tests\system\Kernel\CommandView source
class ExtensionListCommandTest extends KernelTestBase {
use DrupalApplicationTesterTrait;
/**
* {@inheritdoc}
*/
protected static $modules = [
'system',
];
/**
* Tests the 'ex:list' command.
*/
public function testExtensionList() : void {
$tester = $this->applicationTester();
// Detailed testing using json output format.
$cmd = [
'command' => 'ex:list',
'--format' => 'json',
];
$this->assertEquals(Command::SUCCESS, $tester->run($cmd));
$json = json_decode($tester->getDisplay());
$this->assertSame('Field types', $json->datetime->package);
$this->assertSame('Datetime (datetime)', $json->datetime->display_name);
$this->assertSame('Uninstalled', $json->datetime->status);
$this->assertSame(\Drupal::VERSION, $json->datetime->version);
$this->assertSame('Installed', $json->system->status);
// Exercise the filtering options.
$cmd = [
'command' => 'ex:list',
'--format' => 'json',
'--type' => 'module',
'--installed' => TRUE,
];
$this->assertEquals(Command::SUCCESS, $tester->run($cmd));
$json = json_decode($tester->getDisplay());
$this->assertObjectHasProperty('system', $json);
$this->assertObjectNotHasProperty('datetime', $json);
$cmd = [
'command' => 'ex:list',
'--format' => 'json',
'--no-core' => TRUE,
];
$this->assertEquals(Command::SUCCESS, $tester->run($cmd));
$json = json_decode($tester->getDisplay());
$this->assertObjectNotHasProperty('system', $json);
$cmd = [
'command' => 'ex:list',
'--format' => 'json',
'--type' => 'theme',
];
$this->assertEquals(Command::SUCCESS, $tester->run($cmd));
$json = json_decode($tester->getDisplay());
$this->assertObjectNotHasProperty('system', $json);
// Sanity check the human readable output.
$this->assertEquals(Command::SUCCESS, $tester->run([
'command' => 'ex:list',
]));
$display = $tester->getDisplay();
$this->assertStringContainsString('Package', $display);
$this->assertStringContainsString('Version', $display);
$this->assertStringContainsString('User', $display);
$this->assertStringContainsString('Installed', $display);
$this->assertStringContainsString('Uninstalled', $display);
$this->assertStringContainsString(\Drupal::VERSION, $display);
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.