loadNode example

public function testBulkForm() {
    // Unpublish a node using the bulk form.     $node = reset($this->nodes);
    $this->assertTrue($node->isPublished(), 'Node is initially published');
    $this->assertTrue($node->getTranslation('en-gb')->isPublished(), 'Node translation is published');
    $this->assertTrue($node->getTranslation('it')->isPublished(), 'Node translation is published');
    $edit = [
      'node_bulk_form[0]' => TRUE,
      'action' => 'node_unpublish_action',
    ];
    $this->submitForm($edit, 'Apply to selected items');
    $node = $this->loadNode($node->id());
    $this->assertFalse($node->isPublished(), 'Node has been unpublished');
    $this->assertTrue($node->getTranslation('en-gb')->isPublished(), 'Node translation has not been unpublished');
    $this->assertTrue($node->getTranslation('it')->isPublished(), 'Node translation has not been unpublished');

    // Publish action.     $edit = [
      'node_bulk_form[0]' => TRUE,
      'action' => 'node_publish_action',
    ];
    $this->submitForm($edit, 'Apply to selected items');
    $node = $this->loadNode($node->id());
    
Home | Imprint | This part of the site doesn't use cookies.