diff --git a/devel_generate/tests/src/Functional/DevelGenerateCommandsTest.php b/devel_generate/tests/src/Functional/DevelGenerateCommandsTest.php index 98ac00aa6021f0ca8d4dda7f4b275fb2d3d06b2f..9771fa6ab2425dde9346f3a2410972fbf6a7eefa 100644 --- a/devel_generate/tests/src/Functional/DevelGenerateCommandsTest.php +++ b/devel_generate/tests/src/Functional/DevelGenerateCommandsTest.php @@ -12,92 +12,75 @@ use Drupal\Tests\devel_generate\Traits\DevelGenerateSetupTrait; use Drupal\user\Entity\User; use Drush\TestTraits\DrushTestTrait; -if (trait_exists('DrushTestTrait')) { +/** + * Note: Drush must be in the Composer project. See https://cgit.drupalcode.org/devel/tree/drupalci.yml?h=8.x-2.x and its docs at + * https://www.drupal.org/drupalorg/docs/drupal-ci/customizing-drupalci-testing-for-projects + */ + +/** + * @coversDefaultClass \Drupal\devel_generate\Commands\DevelGenerateCommands + * @group devel-generate + */ +class DevelGenerateCommandsTest extends BrowserTestBase +{ + use DrushTestTrait; + use DevelGenerateSetupTrait; /** - * Note: Drush must be in the Composer project. See https://cgit.drupalcode.org/devel/tree/drupalci.yml?h=8.x-2.x and its docs at - * https://www.drupal.org/drupalorg/docs/drupal-ci/customizing-drupalci-testing-for-projects + * Modules to enable. + * + * @var array */ + public static $modules = array('menu_ui', 'node', 'comment', 'taxonomy', 'path', 'devel_generate'); /** - * @coversDefaultClass \Drupal\devel_generate\Commands\DevelGenerateCommands - * @group devel-generate + * Prepares the testing environment */ - class DevelGenerateCommandsTest extends BrowserTestBase { - - use DrushTestTrait; - use DevelGenerateSetupTrait; - - /** - * Modules to enable. - * - * @var array - */ - public static $modules = [ - 'menu_ui', - 'node', - 'comment', - 'taxonomy', - 'path', - 'devel_generate' - ]; - - /** - * Prepares the testing environment - */ - public function setUp() { - parent::setUp(); - $this->setUpData(); - } + public function setUp() { + parent::setUp(); + $this->setUpData(); + } - public function testGeneration() { - // Make sure users get created, and with correct roles. - $this->drush('devel-generate-users', [55], [ - 'kill' => NULL, - 'roles' => 'administrator' - ]); - $user = User::load(55); - $this->assertTrue($user->hasRole('administrator')); + public function testGeneration() { + // Make sure users get created, and with correct roles. + $this->drush('devel-generate-users', [55], ['kill' => null, 'roles' => 'administrator']); + $user = User::load(55); + $this->assertTrue($user->hasRole('administrator')); - // Make sure terms get created, and with correct vocab. - $this->drush('devel-generate-terms', [ - $this->vocabulary->id(), - 55 - ], ['kill' => NULL]); - $term = Term::load(55); - $this->assertEquals($this->vocabulary->id(), $term->bundle()); + // Make sure terms get created, and with correct vocab. + $this->drush('devel-generate-terms', [$this->vocabulary->id(), 55], ['kill' => null]); + $term = Term::load(55); + $this->assertEquals($this->vocabulary->id(), $term->bundle()); - // Make sure vocabs get created. - $this->drush('devel-generate-vocabs', [5], ['kill' => NULL]); - $vocabs = Vocabulary::loadMultiple(); - $this->assertGreaterThan(4, count($vocabs)); - $vocab = array_pop($vocabs); - $this->assertNotEmpty($vocab); + // Make sure vocabs get created. + $this->drush('devel-generate-vocabs', [5], ['kill' => null]); + $vocabs = Vocabulary::loadMultiple(); + $this->assertGreaterThan(4, count($vocabs)); + $vocab = array_pop($vocabs); + $this->assertNotEmpty($vocab); - // Make sure menus, and with correct properties. - $this->drush('devel-generate-menus', [1, 5], ['kill' => NULL]); - $menus = Menu::loadMultiple(); - foreach ($menus as $key => $menu) { - if (strstr($menu->id(), 'devel-') !== FALSE) { - // We have a menu that we created. - break; - } + // Make sure menus, and with correct properties. + $this->drush('devel-generate-menus', [1, 5], ['kill' => null]); + $menus = Menu::loadMultiple(); + foreach ($menus as $key => $menu) { + if (strstr($menu->id(), 'devel-') !== FALSE) { + // We have a menu that we created. + break; } - $link = MenuLinkContent::load(5); - $this->assertEquals($menu->id(), $link->getMenuName()); + } + $link = MenuLinkContent::load(5); + $this->assertEquals($menu->id(), $link->getMenuName()); - // Make sure content gets created, with comments. - $this->drush('devel-generate-content', [21, 9], ['kill' => NULL]); - $node = Node::load(3); - $this->assertNotEmpty($node); - $comment = Comment::load(1); - $this->assertNotEmpty($comment); + // Make sure content gets created, with comments. + $this->drush('devel-generate-content', [21, 9], ['kill' => null]); + $node = Node::load(3); + $this->assertNotEmpty($node); + $comment = Comment::load(1); + $this->assertNotEmpty($comment); - // Do same, but with a higher number that triggers batch running. - $this->drush('devel-generate-content', [55], ['kill' => NULL]); - $node = Node::load(55); - $this->assertNotEmpty($node); - } + // Do same, but with a higher number that triggers batch running. + $this->drush('devel-generate-content', [55], ['kill' => null]); + $node = Node::load(55); + $this->assertNotEmpty($node); } - } diff --git a/tests/src/Functional/DevelCommandsTest.php b/tests/src/Functional/DevelCommandsTest.php index aac6b4358b9a2832afacedad52f855ddeafecc7f..1004ae49d3614337b5249f06f215de948a1ffd16 100644 --- a/tests/src/Functional/DevelCommandsTest.php +++ b/tests/src/Functional/DevelCommandsTest.php @@ -5,42 +5,38 @@ namespace Drupal\Tests\devel\Functional; use Drupal\Tests\BrowserTestBase; use Drush\TestTraits\DrushTestTrait; -if (trait_exists('DrushTestTrait')) { +/** + * Note: Drush must be installed. See + * https://cgit.drupalcode.org/devel/tree/drupalci.yml?h=8.x-2.x and its docs + * at + * https://www.drupal.org/drupalorg/docs/drupal-ci/customizing-drupalci-testing-for-projects + */ + +/** + * @coversDefaultClass \Drupal\devel\Commands\DevelCommands + * @group devel + */ +class DevelCommandsTest extends BrowserTestBase { + + use DrushTestTrait; /** - * Note: Drush must be installed. See - * https://cgit.drupalcode.org/devel/tree/drupalci.yml?h=8.x-2.x and its docs - * at - * https://www.drupal.org/drupalorg/docs/drupal-ci/customizing-drupalci-testing-for-projects + * {@inheritdoc} */ + public static $modules = ['devel']; /** - * @coversDefaultClass \Drupal\devel\Commands\DevelCommands - * @group devel + * Tests drush commands. */ - class DevelCommandsTest extends BrowserTestBase { - - use DrushTestTrait; - - /** - * {@inheritdoc} - */ - public static $modules = ['devel']; - - /** - * Tests drush commands. - */ - public function testCommands() { - $this->drush('devel:token', [], ['format' => 'json']); - $output = $this->getOutputFromJSON(); - $tokens = array_column($output, 'token'); - $this->assertContains('account-name', $tokens); - - $this->drush('devel:services', [], ['format' => 'json']); - $output = $this->getOutputFromJSON(); - $this->assertContains('current_user', $output); - } - + public function testCommands() { + $this->drush('devel:token', [], ['format' => 'json']); + $output = $this->getOutputFromJSON(); + $tokens = array_column($output, 'token'); + $this->assertContains('account-name', $tokens); + + $this->drush('devel:services', [], ['format' => 'json']); + $output = $this->getOutputFromJSON(); + $this->assertContains('current_user', $output); } }