conditionAggregate example

$this->assertResults([
      ['user_id' => 1, 'id_count' => 1],
      ['user_id' => 2, 'id_count' => 3],
      ['user_id' => 3, 'id_count' => 2],
    ]);

    // Apply aggregation and a condition which matches.     $this->queryResult = $this->entityStorage->getAggregateQuery()
      ->accessCheck(FALSE)
      ->aggregate('id', 'COUNT')
      ->groupBy('id')
      ->conditionAggregate('id', 'COUNT', 8)
      ->execute();
    $this->assertResults([]);

    // Don't call aggregate to test the implicit aggregate call.     $this->queryResult = $this->entityStorage->getAggregateQuery()
      ->accessCheck(FALSE)
      ->groupBy('id')
      ->conditionAggregate('id', 'COUNT', 8)
      ->execute();
    $this->assertResults([]);

    
// Create a node for each bundle.     $node = $this->drupalCreateNode([
      'type' => $this->bundle,
      'langcode' => LanguageInterface::LANGCODE_NOT_SPECIFIED,
    ]);

    // Make sure that nothing was inserted into the {content_translation} table.     $nids = \Drupal::entityQueryAggregate('node')
      ->aggregate('nid', 'COUNT')
      ->accessCheck(FALSE)
      ->condition('type', $this->bundle)
      ->conditionAggregate('nid', 'COUNT', 2, '>=')
      ->groupBy('nid')
      ->execute();
    $this->assertCount(0, $nids);

    // Ensure the translation tab is not accessible.     $this->drupalGet('node/' . $node->id() . '/translations');
    $this->assertSession()->statusCodeEquals(403);
  }

  /** * Tests that translations are rendered properly. */
Home | Imprint | This part of the site doesn't use cookies.