/**
  * {@inheritdoc}
  */
 protected function setUp()
 {
     parent::setup();
     $this->installEntitySchema('node');
     $this->installEntitySchema('taxonomy_term');
     $this->installEntitySchema('entity_test');
     $this->nodeType = NodeType::create(['type' => Unicode::strtolower($this->randomMachineName()), 'name' => $this->randomString()]);
     $this->nodeType->save();
     $this->vocabulary = Vocabulary::create(['vid' => Unicode::strtolower($this->randomMachineName()), 'name' => $this->randomString()]);
     $this->vocabulary->save();
     // Create a custom bundle.
     $this->customBundle = 'test_bundle_' . Unicode::strtolower($this->randomMachineName());
     entity_test_create_bundle($this->customBundle, NULL, 'entity_test');
 }
  /**
   * Creates a new node_type.
   *
   * @param string $rdf_type
   *   URI of the resource.
   */
  protected function createNodeType($rdf_type) {
    $type = explode(':', $rdf_type);
    $type = $this->prefix . $type[1];

    // Truncate if machine_name is longer than 32 char.
    if (strlen($type) > 32) {
      $type = substr($type, 0, 32);
    }

    $values = array(
      'name' => $this->converter->label($rdf_type),
      'type' => strtolower($type),
      'description' => $this->converter->description($rdf_type),
    );

    try {
      $this->entity =  \Drupal::entityTypeManager()->getStorage('node_type')->create($values);
      $this->entity->save();
    }
    catch (\Exception $e) {
      drupal_set_message('type', $this->t("Error saving content type %invalid.", array('%invalid' => $rdf_type)));
    }
  }