function DevelGenerateCommandsTest::testDrushGenerateTerms

Same name and namespace in other branches
  1. 5.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 74

Class

DevelGenerateCommandsTest
Test class for the Devel Generate drush commands.

Namespace

Drupal\Tests\devel_generate\Functional

Code

public function testDrushGenerateTerms() {
    // Make sure terms get created, and with correct vocab.
    $this->drush('devel-generate-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('devel-generate-terms', [
        10,
    ], [
        'kill' => NULL,
        'bundles' => $this->vocabulary
            ->id(),
        'languages' => 'fr',
    ]);
    $term = Term::load(60);
    $this->assertEquals($term->language()
        ->getId(), 'fr');
    // Make sure terms gets created, with proper translation.
    $this->drush('devel-generate-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'));
}