Im writing a functional javascript test for my project where im facing a problem with my feature. I have created a group entity just above it and referencing a parent group.

This doesn't work:

  $query = \Drupal::entityQuery('group')
        ->condition('field_parent_site', $group->id());
      $gids = $query->execute();

This works:

  $connection = \Drupal::database();
  $query = $connection->select('group__field_parent_site', 'p');
  $query->fields('p', ['entity_id']);
  $query->condition('p.field_parent_site_target_id', $group->id());
  $result = $query->execute();

I even tried resetting cache programmatically but that too had no effect. I don't have any problem with it while testing it through browser.

  • Welcome to Drupal Answers! 👋I guess we need a bit more info about the tests and from where exactly you are calling that code expecting what to return exactly.
    – leymannx
    Aug 26, 2020 at 9:42
  • I have solved it looks like access check for entityQuery was returning false for some cases.
    – Saw
    Aug 26, 2020 at 14:13


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Browse other questions tagged or ask your own question.