function ResourceResponseValidatorTest::setUp

Same name in this branch
  1. 11.x core/modules/jsonapi/tests/src/Unit/EventSubscriber/ResourceResponseValidatorTest.php \Drupal\Tests\jsonapi\Unit\EventSubscriber\ResourceResponseValidatorTest::setUp()
Same name and namespace in other branches
  1. 10 core/modules/jsonapi/tests/src/Unit/EventSubscriber/ResourceResponseValidatorTest.php \Drupal\Tests\jsonapi\Unit\EventSubscriber\ResourceResponseValidatorTest::setUp()
  2. 9 core/modules/jsonapi/tests/src/Unit/EventSubscriber/ResourceResponseValidatorTest.php \Drupal\Tests\jsonapi\Unit\EventSubscriber\ResourceResponseValidatorTest::setUp()
  3. 8.9.x core/modules/jsonapi/tests/src/Unit/EventSubscriber/ResourceResponseValidatorTest.php \Drupal\Tests\jsonapi\Unit\EventSubscriber\ResourceResponseValidatorTest::setUp()

Overrides UnitTestCase::setUp

File

core/modules/jsonapi/tests/modules/jsonapi_response_validator/tests/src/Unit/EventSubscriber/ResourceResponseValidatorTest.php, line 41

Class

ResourceResponseValidatorTest
Tests Drupal\jsonapi_response_validator\EventSubscriber\ResourceResponseValidator.

Namespace

Drupal\Tests\jsonapi_response_validator\Unit\EventSubscriber

Code

protected function setUp() : void {
  parent::setUp();
  // Check that the validation class is available.
  if (!class_exists("\\JsonSchema\\Validator")) {
    $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_path = dirname(__DIR__, 7);
  $module->getPath()
    ->willReturn($module_path);
  $module_handler->getModule('jsonapi')
    ->willReturn($module->reveal());
  $subscriber = new ResourceResponseValidator($this->prophesize(LoggerInterface::class)
    ->reveal(), $module_handler->reveal(), '');
  $this->subscriber = $subscriber;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.