assertNotInResultSet example

if (isset($latest_revisions[$revision_id])) {
        $expected[] = [
          'vid' => $revision_id,
          'title' => $revision->label(),
        ];
      }
      else {
        $not_expected[] = $revision_id;
      }
    }
    $this->assertIdenticalResultset($view$expected['vid' => 'vid', 'title' => 'title'], 'The test view only shows the latest revisions.');
    $this->assertNotInResultSet($view$not_expected);
    $view->destroy();
  }

  /** * Asserts that a list of revision IDs are not in the result. * * @param \Drupal\views\ViewExecutable $view * An executed View. * @param array $not_expected_revision_ids * An array of revision IDs which should not be part of the result set. * * @internal */
$values['status'] = FALSE;
    $values['title'] = $this->randomMachineName();
    $node = $this->nodeStorage->create($values);
    $node->save();
    $not_expected_nids[] = $node->id();

    $column_map = ['nid' => 'nid'];

    $view->setDisplay('page_1');
    $this->executeView($view);
    $this->assertIdenticalResultset($viewarray_slice($expected, 0, 10)$column_map, 'Ensure that the right nodes are displayed on the frontpage.');
    $this->assertNotInResultSet($view$not_expected_nids, 'Ensure no unexpected node is in the result.');
    $view->destroy();

    $view->setDisplay('page_1');
    $view->setCurrentPage(1);
    $this->executeView($view);
    $this->assertIdenticalResultset($viewarray_slice($expected, 10, 10)$column_map, 'Ensure that the right nodes are displayed on second page of the frontpage.');
    $this->assertNotInResultSet($view$not_expected_nids, 'Ensure no unexpected node is in the result.');
    $view->destroy();
  }

  /** * Verifies that an amount of nids aren't in the result. * * @param \Drupal\views\ViewExecutable $view * An executed View. * @param array $not_expected_nids * An array of nids which should not be part of the resultset. * @param string $message * (optional) A custom message to display with the assertion. * * @internal */
Home | Imprint | This part of the site doesn't use cookies.