View source
<?php
namespace Drupal\Tests\devel_generate\Functional;
use Drupal\comment\Entity\Comment;
use Drupal\menu_link_content\Entity\MenuLinkContent;
use Drupal\node\Entity\Node;
use Drupal\system\Entity\Menu;
use Drupal\taxonomy\Entity\Term;
use Drupal\taxonomy\Entity\Vocabulary;
use Drupal\Tests\BrowserTestBase;
use Drupal\Tests\devel_generate\Traits\DevelGenerateSetupTrait;
use Drupal\user\Entity\User;
use Drush\TestTraits\DrushTestTrait;
class DevelGenerateCommandsTest extends BrowserTestBase {
use DrushTestTrait;
use DevelGenerateSetupTrait;
public static $modules = array(
'menu_ui',
'node',
'comment',
'taxonomy',
'path',
'devel_generate',
);
public function setUp() {
parent::setUp();
$this
->setUpData();
}
public function testGeneration() {
$this
->drush('devel-generate-users', [
55,
], [
'kill' => null,
'roles' => 'administrator',
]);
$user = User::load(55);
$this
->assertTrue($user
->hasRole('administrator'));
$this
->drush('devel-generate-terms', [
$this->vocabulary
->id(),
55,
], [
'kill' => null,
]);
$term = Term::load(55);
$this
->assertEquals($this->vocabulary
->id(), $term
->bundle());
$this
->drush('devel-generate-vocabs', [
5,
], [
'kill' => null,
]);
$vocabs = Vocabulary::loadMultiple();
$this
->assertGreaterThan(4, count($vocabs));
$vocab = array_pop($vocabs);
$this
->assertNotEmpty($vocab);
$this
->drush('devel-generate-menus', [
1,
5,
], [
'kill' => null,
]);
$menus = Menu::loadMultiple();
foreach ($menus as $key => $menu) {
if (strstr($menu
->id(), 'devel-') !== FALSE) {
break;
}
}
$link = MenuLinkContent::load(5);
$this
->assertEquals($menu
->id(), $link
->getMenuName());
$this
->drush('devel-generate-content', [
21,
9,
], [
'kill' => null,
]);
$node = Node::load(3);
$this
->assertNotEmpty($node);
$comment = Comment::load(1);
$this
->assertNotEmpty($comment);
$this
->drush('devel-generate-content', [
55,
], [
'kill' => null,
]);
$node = Node::load(55);
$this
->assertNotEmpty($node);
}
}