0

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.

2
  • 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 '20 at 9:42
  • I have solved it looks like access check for entityQuery was returning false for some cases. – Saw Aug 26 '20 at 14:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.