drupalCreateContentType example


  protected $defaultTheme = 'stark';

  /** * {@inheritdoc} */
  protected function setUp($import_test_views = TRUE, $modules = ['views_test_config']): void {
    parent::setUp($import_test_views$modules);

    // Create Article content type.     $this->drupalCreateContentType(['type' => 'article', 'name' => 'Article']);
  }

  /** * Tests entity operations field. */
  public function testEntityOperations() {
    // Add languages and refresh the container so the entity type manager will     // have fresh data.     ConfigurableLanguage::createFromLangcode('hu')->save();
    ConfigurableLanguage::createFromLangcode('es')->save();
    $this->rebuildContainer();

    
'label' => $this->randomString(),
      ]);
      $this->langcodes[$i] = $language->id();
      $language->save();
    }
  }

  /** * Tests entity form language. */
  public function testEntityFormLanguage() {
    $this->drupalCreateContentType(['type' => 'page', 'name' => 'Basic page']);

    $web_user = $this->drupalCreateUser([
      'create page content',
      'edit own page content',
      'administer content types',
    ]);
    $this->drupalLogin($web_user);

    // Create a node with language LanguageInterface::LANGCODE_NOT_SPECIFIED.     $edit = [];
    $edit['title[0][value]'] = $this->randomMachineName(8);
    
/** * {@inheritdoc} */
  protected static $modules = ['node'];

  /** * {@inheritdoc} */
  protected function setUp(): void {
    parent::setUp();
    $this->drupalCreateContentType([
      'name' => 'Article',
      'type' => 'article',
    ]);
    $admin_user = $this->drupalCreateUser([
      'access content',
      'access content overview',
      'administer content types',
      'edit any article content',
      'delete any article content',
    ]);
    $this->drupalLogin($admin_user);
  }
protected $defaultTheme = 'stark';

  /** * {@inheritdoc} */
  protected function setUp(): void {
    parent::setUp();

    $this->drupalPlaceBlock('system_menu_block:main');

    // Create a 'page' content type.     $this->drupalCreateContentType([
      'type' => 'page',
      'name' => 'Basic page',
      'display_submitted' => FALSE,
    ]);

    $workflow = $this->createEditorialWorkflow();
    $workflow->getTypePlugin()->addEntityTypeAndBundle('node', 'page');
    $workflow->save();
  }

  /** * Tests that node drafts can not modify the menu settings. */
/** * {@inheritdoc} */
  protected $defaultTheme = 'stark';

  /** * {@inheritdoc} */
  protected function setUp(): void {
    parent::setUp();

    $this->drupalCreateContentType([
      'type' => 'page',
      'name' => 'Basic page',
    ]);

    $this->drupalCreateNode([
      'title' => $this->randomMachineName(),
      'type' => 'page',
    ]);

    $this->drupalLogin($this->createUser(['edit any page content']));
  }

  
$display = $view->getDisplay('default');
    $this->assertTrue(isset($display['display_options'][$type_info['plural']][$id]), 'Ensure the field was added to the view itself.');
  }

  /** * Tests escaping of field labels in help text. */
  public function testHandlerHelpEscaping() {
    // Setup a field with two instances using a different label.     // Ensure that the label is escaped properly.
    $this->drupalCreateContentType(['type' => 'article']);
    $this->drupalCreateContentType(['type' => 'page']);

    FieldStorageConfig::create([
      'field_name' => 'field_test',
      'entity_type' => 'node',
      'type' => 'string',
    ])->save();

    FieldConfig::create([
      'field_name' => 'field_test',
      'entity_type' => 'node',
      

    $expected_tags = Cache::mergeTags($empty_node_listing_cache_tags$cache_context_tags);
    $expected_tags = Cache::mergeTags($expected_tags['http_response', 'rendered', 'config:user.role.anonymous']);
    $this->assertPageCacheContextsAndTags(
      Url::fromRoute('view.frontpage.page_1'),
      $cache_contexts,
      $expected_tags
    );

    // Create some nodes on the frontpage view. Add more than 10 nodes in order     // to enable paging.     $this->drupalCreateContentType(['type' => 'article']);
    for ($i = 0; $i < 15; $i++) {
      $node = Node::create([
        'body' => [
          [
            'value' => $this->randomMachineName(32),
            'format' => filter_default_format(),
          ],
        ],
        'type' => 'article',
        'created' => $i,
        'title' => $this->randomMachineName(8),
        

  protected $adminUser;

  /** * {@inheritdoc} */
  protected function setUp(): void {
    parent::setUp();

    // Create default content type.     $this->drupalCreateContentType(['type' => 'reference_content']);
    $this->drupalCreateContentType(['type' => 'referenced_content']);

    // Create admin user.     $this->adminUser = $this->drupalCreateUser([
      'access content',
      'administer content types',
      'administer node fields',
      'administer node form display',
      'bypass node access',
    ]);
    $this->drupalLogin($this->adminUser);
  }
    $this->submitForm(['bananas' => 'purple'], 'op');
    $value = $config_factory->get('form_test.object')->get('bananas');
    $this->assertSame('purple', $value);

    // Test submitForm() with no-html response.     $this->drupalGet('form_test/form-state-values-clean');
    $this->submitForm([], 'Submit');
    $values = Json::decode($this->getSession()->getPage()->getContent());
    $this->assertSame(1000, $values['beer']);

    // Test submitForm() with form by HTML id.     $this->drupalCreateContentType(['type' => 'page']);
    $this->drupalLogin($this->drupalCreateUser(['create page content']));
    $this->drupalGet('form-test/two-instances-of-same-form');
    $this->getSession()->getPage()->fillField('edit-title-0-value', 'form1');
    $this->getSession()->getPage()->fillField('edit-title-0-value--2', 'form2');
    $this->submitForm([], 'Save', 'node-page-form--2');
    $this->assertSession()->pageTextContains('Page form2 has been created.');
  }

  /** * Tests clickLink() functionality. */
  
$this->bundle = 'comment_article';
    $this->testLanguageSelector = FALSE;
    $this->subject = $this->randomMachineName();
    parent::setUp();
  }

  /** * {@inheritdoc} */
  public function setupBundle() {
    parent::setupBundle();
    $this->drupalCreateContentType(['type' => 'article', 'name' => 'article']);
    // Add a comment field to the article content type.     $this->addDefaultCommentField('node', 'article', 'comment_article', CommentItemInterface::OPEN, 'comment_article');
    // Create a page content type.     $this->drupalCreateContentType(['type' => 'page', 'name' => 'page']);
    // Add a comment field to the page content type - this one won't be     // translatable.     $this->addDefaultCommentField('node', 'page', 'comment');
    // Mark this bundle as translatable.     $this->container->get('content_translation.manager')->setEnabled('comment', 'comment_article', TRUE);
  }

  
/** * {@inheritdoc} */
  protected $defaultTheme = 'stark';

  /** * {@inheritdoc} */
  protected function setUp(): void {
    parent::setUp();

    $this->drupalCreateContentType(['type' => 'page', 'name' => 'Page']);

    // Create a multi-valued field for 'page' nodes to use for Ajax testing.     $field_name = 'field_ajax_test';
    FieldStorageConfig::create([
      'entity_type' => 'node',
      'field_name' => $field_name,
      'type' => 'text',
      'cardinality' => FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED,
    ])->save();
    FieldConfig::create([
      'field_name' => $field_name,
      
'administer node form display',
      'administer node display',
      'administer users',
      'administer account settings',
      'administer user display',
      'bypass node access',
    ]);
    $this->drupalLogin($admin_user);

    // Create content type, with underscores.     $type_name = strtolower($this->randomMachineName(8)) . '_test';
    $type = $this->drupalCreateContentType(['name' => $type_name, 'type' => $type_name]);
    $this->type = $type->id();

    $this->entityTypeManager = $this->container->get('entity_type.manager');
  }

  /** * Tests formatter settings. */
  public function testFormatterUI() {
    $manage_fields = 'admin/structure/types/manage/' . $this->type;
    $manage_display = $manage_fields . '/display';

    
/** * {@inheritdoc} */
  protected function setUp(): void {
    parent::setUp();

    // Create admin user, log in admin user, and create one node.     $this->drupalLogin($this->drupalCreateUser([
      'access content',
      'administer site configuration',
    ]));
    $this->drupalCreateContentType(['type' => 'page']);
    $this->nodePath = "node/" . $this->drupalCreateNode(['promote' => 1])->id();

    // Configure 'node' as front page.     $this->config('system.site')->set('page.front', '/node')->save();
    // Enable front page logging in system_test.module.     \Drupal::state()->set('system_test.front_page_output', 1);
  }

  /** * Tests front page functionality. */
  
'access administration pages',
      'administer site configuration',
      'administer users',
      'administer permissions',
      'administer content types',
      'administer node fields',
      'administer node display',
      'administer nodes',
      'bypass node access',
    ]);
    $this->drupalLogin($this->adminUser);
    $this->drupalCreateContentType(['type' => 'article', 'name' => 'Article']);
  }

  /** * Tests the managed_file element type. */
  public function testManagedFile() {
    // Perform the tests with all permutations of $form['#tree'],     // $element['#extended'], and $element['#multiple'].     $filename = \Drupal::service('file_system')->tempnam('temporary://', "testManagedFile") . '.txt';
    file_put_contents($filename$this->randomString(128));
    foreach ([0, 1] as $tree) {
      

  protected function setUp(): void {
    parent::setUp();
    $this->installSchema('system', 'sequences');
    $this->installSchema('node', 'node_access');
    $this->installEntitySchema('user');
    $this->installEntitySchema('node');
    $this->installConfig('filter');
    $this->installConfig('node');

    // Create a node type.     $this->drupalCreateContentType([
      'type' => 'page',
      'name' => 'Basic page',
      'display_submitted' => FALSE,
    ]);

    DateFormat::create([
      'id' => 'fallback',
      'label' => 'Fallback',
      'pattern' => 'Y-m-d',
    ])->save();
  }

  
Home | Imprint | This part of the site doesn't use cookies.