function DevelGenerateCommandsTest::testDrushGenerateTerms

Same name in other branches
  1. 4.x devel_generate/tests/src/Functional/DevelGenerateCommandsTest.php \Drupal\Tests\devel_generate\Functional\DevelGenerateCommandsTest::testDrushGenerateTerms()

Tests generating terms.

File

devel_generate/tests/src/Functional/DevelGenerateCommandsTest.php, line 79

Class

DevelGenerateCommandsTest
Test class for the Devel Generate drush commands.

Namespace

Drupal\Tests\devel_generate\Functional

Code

public function testDrushGenerateTerms() : void {
    // Make sure terms get created, and with correct vocab.
    $this->drush(DevelGenerateCommands::TERMS, [
        '55',
    ], [
        'kill' => NULL,
        'bundles' => $this->vocabulary
            ->id(),
    ]);
    $term = Term::load(55);
    $this->assertEquals($this->vocabulary
        ->id(), $term->bundle());
    // Make sure terms get created, with proper language.
    $this->drush(DevelGenerateCommands::TERMS, [
        '10',
    ], [
        'kill' => NULL,
        'bundles' => $this->vocabulary
            ->id(),
        'languages' => 'fr',
    ]);
    $term = Term::load(60);
    $this->assertEquals('fr', $term->language()
        ->getId());
    // Make sure terms gets created, with proper translation.
    $this->drush(DevelGenerateCommands::TERMS, [
        '10',
    ], [
        'kill' => NULL,
        'bundles' => $this->vocabulary
            ->id(),
        'languages' => 'fr',
        'translations' => 'de',
    ]);
    $term = Term::load(70);
    $this->assertTrue($term->hasTranslation('de'));
    $this->assertTrue($term->hasTranslation('fr'));
}