public function DevelGenerateCommandsTest::testGeneration in Devel 8.2
File
- devel_generate/
tests/ src/ Functional/ DevelGenerateCommandsTest.php, line 44
Class
- DevelGenerateCommandsTest
- @coversDefaultClass \Drupal\devel_generate\Commands\DevelGenerateCommands @group devel-generate
Namespace
Drupal\Tests\devel_generate\FunctionalCode
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 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;
}
}
$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);
// 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);
}