I am attempting to write a PHPUnit test for a service of mine.
My test looks like the following.
class CustomServiceTest extends UnitTestCase {
public function testDefaultBehavior() {
$service = new CustomService(\Drupal::service('custom_utils.some_resolver'), \Drupal::configFactory());
$service->execute();
}
}
However, it raises the following exception.
Drupal\Core\DependencyInjection\ContainerNotInitializedException:
\Drupal::$container is not initialized yet. \Drupal::setContainer() must be called with a real container.
What am I doing wrong?