/** * Create REST resource configuration entities. * * @see rest_update_8201() * @see https://www.drupal.org/node/2308745 */ function rest_post_update_create_rest_resource_config_entities() { $resources = \Drupal::state()->get('rest_update_8201_resources', []); foreach ($resources as $key => $resource) { $resource = RestResourceConfig::create(['id' => str_replace(':', '.', $key), 'granularity' => RestResourceConfigInterface::METHOD_GRANULARITY, 'configuration' => $resource]); $resource->save(); } }
/** * @covers ::onDependencyRemoval * @covers ::onDependencyRemovalForResourceGranularity * * @dataProvider providerOnDependencyRemovalForResourceGranularity */ public function testOnDependencyRemovalForResourceGranularity(array $configuration, $module, $expected_configuration) { assert('is_string($module)'); assert('$expected_configuration === FALSE || is_array($expected_configuration)'); $config_dependencies = new ConfigDependencies(['hal_json' => 'hal', 'json' => 'serialization'], ['basic_auth' => 'basic_auth']); $rest_config = RestResourceConfig::create($configuration); $this->assertSame(!empty($expected_configuration), $config_dependencies->onDependencyRemoval($rest_config, ['module' => [$module]])); if (!empty($expected_configuration)) { $this->assertEquals($expected_configuration, $rest_config->get('configuration')); } }
/** * @covers ::calculateDependencies */ public function testCalculateDependencies() { $rest_config = RestResourceConfig::create(['plugin_id' => 'entity:entity_test', 'granularity' => RestResourceConfigInterface::METHOD_GRANULARITY, 'configuration' => ['GET' => ['supported_auth' => ['cookie'], 'supported_formats' => ['json']], 'POST' => ['supported_auth' => ['basic_auth'], 'supported_formats' => ['hal_json']]]]); $rest_config->calculateDependencies(); $this->assertEquals(['module' => ['basic_auth', 'entity_test', 'hal', 'serialization', 'user']], $rest_config->getDependencies()); }