Skip to content

Support obtaining custom services from static methods #58

@rthideaway

Description

@rthideaway

I love the feature to define custom services in behat tests and then use them across Context(s). However I experienced the problem when they are not accessible from static methods. This make it unable to access any custom service from behat hooks like

  /**
   * Creates the test entities before the test suite starts.
   *
   * @BeforeFeature @sometest
   */
  public static function createTestEntities(): void {
     // Custom behat service is obviously not presented in drupal's container
     // and there is no way to access the plugin's one.
     $service_not_recognized = \Drupal::service('my_test.behat.service');
  }

Would it be possible to implement the way to obtain plugin's container to get the custom services from static methods as well? Or by some other way? That would be really really amazing. I searched for a way if I be able to get the container from static methods, but had no luck so far.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions