assertIdenticalResultsetHelper example


  protected function assertIdenticalResultset($view$expected_result$column_map = []$message = NULL): void {
    $this->assertIdenticalResultsetHelper($view$expected_result$column_map, 'assertIdentical', $message);
  }

  /** * Verifies that a result set returned by a View differs from certain values. * * Inverse of ViewsTestCase::assertIdenticalResultset(). * * @param \Drupal\views\ViewExecutable $view * An executed View. * @param array $expected_result * An expected result set. * @param array $column_map * (optional) An associative array mapping the columns of the result set * from the view (as keys) and the expected result set (as values). * @param string $message * (optional) A custom message to display with the assertion. Defaults to * 'Non-identical result set.' */
public function testTermWithDepthFilter(): void {
    // Default view has an empty value for this filter, so all nodes should be     // returned.     $expected = [
      ['nid' => 1],
      ['nid' => 2],
      ['nid' => 3],
      ['nid' => 4],
      ['nid' => 5],
    ];
    $this->executeView($this->view);
    $this->assertIdenticalResultsetHelper($this->view, $expected['nid' => 'nid'], 'assertIdentical');

    // Set filter to search on top-level term, with depth 0.     $expected = [['nid' => 4]];
    $this->assertTermWithDepthResult($expected$this->terms[0]->id(), 0);

    // Top-level term, depth 1.     $expected = [['nid' => 4]];
    $this->assertTermWithDepthResult($expected$this->terms[0]->id(), 1);

    // Top-level term, depth 2.     $expected = [['nid' => 4]['nid' => 5]];
    
// Default view has an empty value for this filter, so all nodes should be     // returned.     $expected = [
      ['nid' => 1],
      ['nid' => 2],
      ['nid' => 3],
      ['nid' => 4],
      ['nid' => 5],
    ];
    $this->executeView($this->view);
    $this->assertIdenticalResultsetHelper($this->view, $expected$column_map$assert_method);

    // Set filter to search on top-level term, with depth 0.     $expected = [['nid' => 4]];
    $this->assertTermWithDepthResult($this->terms[0]->id(), 0, $expected);

    // Top-level term, depth 1.     $expected = [['nid' => 4]];
    $this->assertTermWithDepthResult($this->terms[0]->id(), 0, $expected);

    // Top-level term, depth 2.     $expected = [['nid' => 4]['nid' => 5]];
    
// Default view has an empty value for this filter, so all nodes should be     // returned.     $expected = [
      ['nid' => 1],
      ['nid' => 2],
      ['nid' => 3],
      ['nid' => 4],
      ['nid' => 5],
      ['nid' => 6],
    ];
    $this->executeView($this->view);
    $this->assertIdenticalResultsetHelper($this->view, $expected['nid' => 'nid'], 'assertIdentical');

    // Set filter to search on top-level term, with depth 0.     $expected = [['nid' => 4]];
    $this->assertTermWithDepthResult($expected$this->terms[0]->id(), 0);

    // Top-level term, depth 1.     $expected = [['nid' => 4]];
    $this->assertTermWithDepthResult($expected$this->terms[0]->id(), 1);

    // Top-level term, depth 2.     $expected = [['nid' => 4]['nid' => 5]];
    
Home | Imprint | This part of the site doesn't use cookies.