diff --git a/tests/src/Unit/EventSubscriber/ResourceResponseSubscriberTest.php b/tests/src/Unit/EventSubscriber/ResourceResponseSubscriberTest.php index 06da13c..7fd8dd3 100644 --- a/tests/src/Unit/EventSubscriber/ResourceResponseSubscriberTest.php +++ b/tests/src/Unit/EventSubscriber/ResourceResponseSubscriberTest.php @@ -2,6 +2,8 @@ namespace Drupal\Tests\jsonapi\Unit\EventSubscriber; +use Drupal\Core\Extension\Extension; +use Drupal\Core\Extension\ModuleHandlerInterface; use Drupal\Core\Render\RendererInterface; use Drupal\jsonapi\EventSubscriber\ResourceResponseSubscriber; use Drupal\rest\ResourceResponse; @@ -15,6 +17,8 @@ use Symfony\Component\HttpFoundation\Request; use Symfony\Component\Routing\Route; use Symfony\Component\Serializer\Serializer; +define('DRUPAL_ROOT', dirname(dirname(dirname(dirname(dirname(__DIR__)))))); + /** * @coversDefaultClass \Drupal\jsonapi\EventSubscriber\ResourceResponseSubscriber * @group jsonapi @@ -37,10 +41,17 @@ class ResourceResponseSubscriberTest extends UnitTestCase { $this->fail('The JSON Schema validator is missing. You can install it with `composer require justinrainbow/json-schema`.'); } + $module_handler = $this->prophesize(ModuleHandlerInterface::class); + $module = $this->prophesize(Extension::class); + $module->getPath()->willReturn('jsonapi'); + $module_handler->getModule('jsonapi')->willReturn( + $module->reveal() + ); $subscriber = new ResourceResponseSubscriber( new Serializer([], [new JsonSchemaEncoder()]), $this->prophesize(RendererInterface::class)->reveal(), - $this->prophesize(LoggerInterface::class)->reveal() + $this->prophesize(LoggerInterface::class)->reveal(), + $module_handler->reveal() ); $subscriber->setValidator(); $this->subscriber = $subscriber;