isSticky example


    $this->drupalLogin($admin_user);

    $this->drupalGet('test_bulk_form');

    // Set all nodes to sticky and check that.     $edit += ['action' => 'node_make_sticky_action'];
    $this->submitForm($edit, 'Apply to selected items');

    foreach ($nodes as $node) {
      $changed_node = $node_storage->load($node->id());
      $this->assertTrue($changed_node->isSticky()new FormattableMarkup('Node @nid got marked as sticky.', ['@nid' => $node->id()]));
    }

    $this->assertSession()->pageTextContains('Make content sticky was applied to 10 items.');

    // Unpublish just one node.     $node = $node_storage->load($nodes[0]->id());
    $this->assertTrue($node->isPublished(), 'The node is published.');

    $edit = ['node_bulk_form[0]' => TRUE, 'action' => 'node_unpublish_action'];
    $this->submitForm($edit, 'Apply to selected items');

    

  public function createIndex(NodeInterface $node) {
    $query = $this->database->insert('forum_index')
      ->fields(['nid', 'title', 'tid', 'sticky', 'created', 'comment_count', 'last_comment_timestamp']);
    foreach ($node->getTranslationLanguages() as $langcode => $language) {
      $translation = $node->getTranslation($langcode);
      foreach ($translation->taxonomy_forums as $item) {
        $query->values([
          'nid' => $node->id(),
          'title' => $translation->label(),
          'tid' => $item->target_id,
          'sticky' => (int) $node->isSticky(),
          'created' => $node->getCreatedTime(),
          'comment_count' => 0,
          'last_comment_timestamp' => $node->getCreatedTime(),
        ]);
      }
    }
    $query->execute();
    // The logic for determining last_comment_count is fairly complex, so     // update the index too.     if ($node->isNew()) {
      $this->updateIndex($node);
    }
$this->drupalGet($url$options);
      $this->submitForm($edit$this->getFormSubmitAction($entity$langcode));
    }

    $storage->resetCache([$this->entityId]);
    $entity = $storage->load($this->entityId);
    foreach ($this->langcodes as $langcode) {
      $translation = $entity->getTranslation($langcode);
      $metadata = $this->manager->getTranslationMetadata($translation);
      $this->assertEquals($values[$langcode]['uid']$metadata->getAuthor()->id(), 'Translation author correctly stored.');
      $this->assertEquals($values[$langcode]['created']$metadata->getCreatedTime(), 'Translation date correctly stored.');
      $this->assertEquals($values[$langcode]['sticky']$translation->isSticky(), 'Sticky of Translation correctly stored.');
      $this->assertEquals($values[$langcode]['promote']$translation->isPromoted(), 'Promoted of Translation correctly stored.');
    }
  }

  /** * Tests that translation page inherits admin status of edit page. */
  public function testTranslationLinkTheme() {
    $this->drupalLogin($this->administrator);
    $article = $this->drupalCreateNode(['type' => 'article', 'langcode' => $this->langcodes[0]]);

    
// Publish action.     $edit = [
      'node_bulk_form[0]' => TRUE,
      'action' => 'node_publish_action',
    ];
    $this->submitForm($edit, 'Apply to selected items');
    $node = $this->loadNode($node->id());
    $this->assertTrue($node->isPublished(), 'Node has been published again');

    // Make sticky action.     $this->assertFalse($node->isSticky(), 'Node is not sticky');
    $this->assertFalse($node->getTranslation('en-gb')->isSticky(), 'Node translation is not sticky');
    $this->assertFalse($node->getTranslation('it')->isSticky(), 'Node translation is not sticky');
    $edit = [
      'node_bulk_form[0]' => TRUE,
      'action' => 'node_make_sticky_action',
    ];
    $this->submitForm($edit, 'Apply to selected items');
    $node = $this->loadNode($node->id());
    $this->assertTrue($node->isSticky(), 'Node has been made sticky');
    $this->assertFalse($node->getTranslation('en-gb')->isSticky(), 'Node translation has not been made sticky');
    $this->assertFalse($node->getTranslation('it')->isSticky(), 'Node translation has not been made sticky');

    
$this->assertSame(14, $results['node']);
    $this->assertSame(0, $results['node_complete']);
    $node = Node::load(1);
    $this->assertSame('1', $node->id(), 'Node 1 loaded.');
    $this->assertSame('und', $node->langcode->value);
    $this->assertSame('body test rev 3', $node->body->value);
    $this->assertSame('teaser test rev 3', $node->body->summary);
    $this->assertSame('filtered_html', $node->body->format);
    $this->assertSame('story', $node->getType(), 'Node has the correct bundle.');
    $this->assertSame('Test title rev 3', $node->getTitle(), 'Node has the correct title.');
    $this->assertSame('1390095702', $node->getCreatedTime(), 'Node has the correct created time.');
    $this->assertFalse($node->isSticky());
    $this->assertSame('1', $node->getOwnerId());
    $this->assertSame('1420861423', $node->getRevisionCreationTime());

    /** @var \Drupal\node\NodeInterface $node_revision */
    $node_revision = \Drupal::entityTypeManager()->getStorage('node')->loadRevision(2001);
    $this->assertSame('Test title rev 3', $node_revision->getTitle());
    $this->assertSame('2', $node_revision->getRevisionUser()->id(), 'Node revision has the correct user');
    $this->assertSame('1', $node_revision->id(), 'Node 1 loaded.');
    $this->assertSame('2001', $node_revision->getRevisionId(), 'Node 1 revision 2001 loaded.');
    // This is empty on the first revision.     $this->assertSame('modified rev 3', $node_revision->revision_log->value);
    
$this->assertInstanceOf(NodeInterface::class$node);
    $this->assertEquals($type$node->getType());
    $this->assertEquals($langcode$node->langcode->value);
    $this->assertEquals($title$node->getTitle());
    $this->assertEquals($uid$node->getOwnerId());
    $this->assertEquals($status$node->isPublished());
    $this->assertEquals($created$node->getCreatedTime());
    if (isset($changed)) {
      $this->assertEquals($changed$node->getChangedTime());
    }
    $this->assertEquals($promoted$node->isPromoted());
    $this->assertEquals($sticky$node->isSticky());
  }

  /** * Asserts various aspects of a node revision. * * @param int $id * The revision ID. * @param string $title * The expected title. * @param int $uid * The revision author ID. * @param string|null $log * The revision log message. * @param int $timestamp * The revision's time stamp. * * @internal */
Home | Imprint | This part of the site doesn't use cookies.