From f268f0733927fb6b4a5461c454b7bb0656662547 Mon Sep 17 00:00:00 2001 From: Jared Whiklo Date: Fri, 17 Sep 2021 20:09:43 -0500 Subject: [PATCH 1/6] Move getEntityUri to separate utility class. --- jsonld.api.php | 5 +- jsonld.services.yml | 7 +- src/Normalizer/ContentEntityNormalizer.php | 99 +++----------------- src/Normalizer/FileEntityNormalizer.php | 20 ++-- src/Utils/JsonldNormalizerUtils.php | 97 +++++++++++++++++++ src/Utils/JsonldNormalizerUtilsInterface.php | 27 ++++++ 6 files changed, 154 insertions(+), 101 deletions(-) create mode 100644 src/Utils/JsonldNormalizerUtils.php create mode 100644 src/Utils/JsonldNormalizerUtilsInterface.php diff --git a/jsonld.api.php b/jsonld.api.php index f304522..d6e2762 100644 --- a/jsonld.api.php +++ b/jsonld.api.php @@ -15,7 +15,10 @@ * @param array $normalized * The current normalized array. * @param array $context - * The context for the normalization. + * The context for the normalization + * + * $context['utils'] contains an instance of \Drupal\jsonld\Utils\JsonldNormalizerUtils, this provides + * the getEntityUri() method to correctly generate a URI with/without the ?format=jsonld suffix. */ function hook_jsonld_alter_normalized_array(EntityInterface $entity, array &$normalized, array $context) { if ($entity->getEntityTypeId() == 'node') { diff --git a/jsonld.services.yml b/jsonld.services.yml index 9f18315..50ad197 100644 --- a/jsonld.services.yml +++ b/jsonld.services.yml @@ -17,10 +17,10 @@ services: class: Drupal\jsonld\Normalizer\FileEntityNormalizer tags: - { name: normalizer, priority: 20 } - arguments: ['@entity_type.manager', '@http_client', '@hal.link_manager', '@module_handler', '@file_system', '@config.factory', '@language_manager', '@router.route_provider'] + arguments: ['@entity_type.manager', '@http_client', '@hal.link_manager', '@module_handler', '@file_system', '@jsonld.normalizer_utils'] serializer.normalizer.entity.jsonld: class: Drupal\jsonld\Normalizer\ContentEntityNormalizer - arguments: ['@hal.link_manager', '@entity_type.manager', '@module_handler', '@config.factory', '@language_manager', '@router.route_provider'] + arguments: ['@hal.link_manager', '@entity_type.manager', '@module_handler', '@jsonld.normalizer_utils'] tags: - { name: normalizer, priority: 10 } serializer.encoder.jsonld: @@ -37,3 +37,6 @@ services: jsonld.contextgenerator: class: Drupal\jsonld\ContextGenerator\JsonldContextGenerator arguments: ['@entity_field.manager','@entity_type.bundle.info','@entity_type.manager', '@cache.default', '@logger.channel.jsonld'] + jsonld.normalizer_utils: + class: Drupal\jsonld\Utils\JsonldNormalizerUtils + arguments: ['@config.factory', '@language_manager', '@router.route_provider'] diff --git a/src/Normalizer/ContentEntityNormalizer.php b/src/Normalizer/ContentEntityNormalizer.php index eb13b46..79c55b9 100644 --- a/src/Normalizer/ContentEntityNormalizer.php +++ b/src/Normalizer/ContentEntityNormalizer.php @@ -2,16 +2,10 @@ namespace Drupal\jsonld\Normalizer; -use Drupal\Core\Config\ConfigFactoryInterface; -use Drupal\Core\Entity\EntityInterface; use Drupal\Core\Entity\EntityTypeManagerInterface; use Drupal\Core\Extension\ModuleHandlerInterface; -use Drupal\Core\Language\LanguageManagerInterface; -use Drupal\Core\Routing\RouteProviderInterface; -use Drupal\Core\Url; use Drupal\hal\LinkManager\LinkManagerInterface; -use Drupal\jsonld\Form\JsonLdSettingsForm; -use Symfony\Component\Routing\Exception\RouteNotFoundException; +use Drupal\jsonld\Utils\JsonldNormalizerUtilsInterface; use Symfony\Component\Serializer\Exception\UnexpectedValueException; /** @@ -50,25 +44,11 @@ class ContentEntityNormalizer extends NormalizerBase { protected $moduleHandler; /** - * The configuration. + * Json-ld normalizer utilities. * - * @var \Drupal\Core\Config\ImmutableConfig + * @var \Drupal\Jsonld\Utils\JsonldNormalizerUtilsInterface */ - protected $config; - - /** - * The language manager. - * - * @var \Drupal\Core\Language\LanguageManagerInterface - */ - protected $languageManager; - - /** - * The route provider. - * - * @var \Drupal\Core\Routing\RouteProviderInterface - */ - protected $routeProvider; + protected $utils; /** * Constructs an ContentEntityNormalizer object. @@ -79,26 +59,18 @@ class ContentEntityNormalizer extends NormalizerBase { * The entity manager. * @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler * The module handler. - * @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory - * The configuration factory. - * @param \Drupal\Core\Language\LanguageManagerInterface $language_manager - * The language manager. - * @param \Drupal\Core\Routing\RouteProviderInterface $route_provider - * The route provider. + * @param \Drupal\Jsonld\Utils\JsonldNormalizerUtilsInterface $normalizer_utils + * The json-ld normalizer utilities. */ public function __construct(LinkManagerInterface $link_manager, EntityTypeManagerInterface $entity_manager, ModuleHandlerInterface $module_handler, - ConfigFactoryInterface $config_factory, - LanguageManagerInterface $language_manager, - RouteProviderInterface $route_provider) { + JsonldNormalizerUtilsInterface $normalizer_utils) { $this->linkManager = $link_manager; $this->entityManager = $entity_manager; $this->moduleHandler = $module_handler; - $this->config = $config_factory->get(JsonLdSettingsForm::CONFIG_NAME); - $this->languageManager = $language_manager; - $this->routeProvider = $route_provider; + $this->utils = $normalizer_utils; } /** @@ -151,8 +123,8 @@ public function normalize($entity, $format = NULL, array $context = []) { /** @var \Drupal\Core\Entity\ContentEntityInterface $entity */ $normalized = $normalized + [ '@graph' => [ - $this->getEntityUri($entity) => [ - '@id' => $this->getEntityUri($entity), + $this->utils->getEntityUri($entity) => [ + '@id' => $this->utils->getEntityUri($entity), '@type' => $types, ], ], @@ -172,7 +144,7 @@ public function normalize($entity, $format = NULL, array $context = []) { $fields = $entity->getFields(); } - $context['current_entity_id'] = $this->getEntityUri($entity); + $context['current_entity_id'] = $this->utils->getEntityUri($entity); $context['current_entity_rdf_mapping'] = $rdf_mappings; foreach ($fields as $name => $field) { @@ -201,6 +173,10 @@ public function normalize($entity, $format = NULL, array $context = []) { } if (isset($context['depth']) && $context['depth'] == 0) { + if (!isset($context['utils'])) { + // Pass the normalizer utils to the invoking methods. + $context['utils'] = $this->utils; + } $this->moduleHandler->invokeAll(self::NORMALIZE_ALTER_HOOK, [$entity, &$normalized, $context] ); @@ -279,51 +255,6 @@ public function denormalize($data, $class, $format = NULL, array $context = []) return $entity; } - /** - * Constructs the entity URI. - * - * @param \Drupal\Core\Entity\EntityInterface $entity - * The entity. - * - * @return string - * The entity URI. - * - * @throws \Drupal\Core\Entity\EntityMalformedException - * When $entity->toUrl() fails. - */ - protected function getEntityUri(EntityInterface $entity) { - - // Some entity types don't provide a canonical link template, at least call - // out to ->url(). - if ($entity->isNew() || !$entity->hasLinkTemplate('canonical')) { - if ($entity->getEntityTypeId() == 'file') { - return $entity->createFileUrl(FALSE); - } - return ""; - } - - try { - $undefined = $this->languageManager->getLanguage('und'); - $entity_type = $entity->getEntityTypeId(); - - // This throws the RouteNotFoundException if the route doesn't exist. - $this->routeProvider->getRouteByName("rest.entity.$entity_type.GET"); - - $url = Url::fromRoute( - "rest.entity.$entity_type.GET", - [$entity_type => $entity->id()], - ['absolute' => TRUE, 'language' => $undefined] - ); - } - catch (RouteNotFoundException $e) { - $url = $entity->toUrl('canonical', ['absolute' => TRUE]); - } - if (!$this->config->get(JsonLdSettingsForm::REMOVE_JSONLD_FORMAT)) { - $url->setRouteParameter('_format', 'jsonld'); - } - return $url->toString(); - } - /** * Gets the typed data IDs for a type URI. * diff --git a/src/Normalizer/FileEntityNormalizer.php b/src/Normalizer/FileEntityNormalizer.php index 56ed6b6..356f169 100644 --- a/src/Normalizer/FileEntityNormalizer.php +++ b/src/Normalizer/FileEntityNormalizer.php @@ -2,13 +2,11 @@ namespace Drupal\jsonld\Normalizer; -use Drupal\Core\Config\ConfigFactoryInterface; use Drupal\Core\Entity\EntityTypeManagerInterface; use Drupal\Core\Extension\ModuleHandlerInterface; use Drupal\Core\File\FileSystemInterface; -use Drupal\Core\Language\LanguageManagerInterface; -use Drupal\Core\Routing\RouteProviderInterface; use Drupal\hal\LinkManager\LinkManagerInterface; +use Drupal\jsonld\Utils\JsonldNormalizerUtilsInterface; use GuzzleHttp\ClientInterface; /** @@ -50,23 +48,17 @@ class FileEntityNormalizer extends ContentEntityNormalizer { * The module handler. * @param \Drupal\Core\File\FileSystemInterface $file_system * The file system handler. - * @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory - * The configuration factory. - * @param \Drupal\Core\Language\LanguageManagerInterface $language_manager - * The language manager. - * @param \Drupal\Core\Routing\RouteProviderInterface $route_provider - * The route provider. + * @param \Drupal\jsonld\Utils\JsonldNormalizerUtilsInterface $normalizer_utils + * The json-ld normalizer utils. */ public function __construct(EntityTypeManagerInterface $entity_manager, ClientInterface $http_client, LinkManagerInterface $link_manager, ModuleHandlerInterface $module_handler, FileSystemInterface $file_system, - ConfigFactoryInterface $config_factory, - LanguageManagerInterface $language_manager, - RouteProviderInterface $route_provider) { + JsonldNormalizerUtilsInterface $normalizer_utils) { - parent::__construct($link_manager, $entity_manager, $module_handler, $config_factory, $language_manager, $route_provider); + parent::__construct($link_manager, $entity_manager, $module_handler, $normalizer_utils); $this->httpClient = $http_client; $this->fileSystem = $file_system; @@ -79,7 +71,7 @@ public function normalize($entity, $format = NULL, array $context = []) { $data = parent::normalize($entity, $format, $context); // Replace the file url with a full url for the file. - $data['uri'][0]['value'] = $this->getEntityUri($entity); + $data['uri'][0]['value'] = $this->utils->getEntityUri($entity); return $data; } diff --git a/src/Utils/JsonldNormalizerUtils.php b/src/Utils/JsonldNormalizerUtils.php new file mode 100644 index 0000000..97a556c --- /dev/null +++ b/src/Utils/JsonldNormalizerUtils.php @@ -0,0 +1,97 @@ +config = $config_factory->get(JsonLdSettingsForm::CONFIG_NAME); + $this->languageManager = $language_manager; + $this->routeProvider = $route_provider; + } + + /** + * {@inheritdoc} + */ + public function getEntityUri(EntityInterface $entity) { + + // Some entity types don't provide a canonical link template, at least call + // out to ->url(). + if ($entity->isNew() || !$entity->hasLinkTemplate('canonical')) { + if ($entity->getEntityTypeId() == 'file') { + return $entity->createFileUrl(FALSE); + } + return ""; + } + + try { + $undefined = $this->languageManager->getLanguage('und'); + $entity_type = $entity->getEntityTypeId(); + + // This throws the RouteNotFoundException if the route doesn't exist. + $this->routeProvider->getRouteByName("rest.entity.$entity_type.GET"); + + $url = Url::fromRoute( + "rest.entity.$entity_type.GET", + [$entity_type => $entity->id()], + ['absolute' => TRUE, 'language' => $undefined] + ); + } + catch (RouteNotFoundException $e) { + $url = $entity->toUrl('canonical', ['absolute' => TRUE]); + } + if (!$this->config->get(JsonLdSettingsForm::REMOVE_JSONLD_FORMAT)) { + $url->setRouteParameter('_format', 'jsonld'); + } + return $url->toString(); + } + +} diff --git a/src/Utils/JsonldNormalizerUtilsInterface.php b/src/Utils/JsonldNormalizerUtilsInterface.php new file mode 100644 index 0000000..88092c5 --- /dev/null +++ b/src/Utils/JsonldNormalizerUtilsInterface.php @@ -0,0 +1,27 @@ +toUrl() fails. + */ + public function getEntityUri(EntityInterface $entity); + +} From 4954f992d4f4f9b796767f84fb9e841c38cbfbf2 Mon Sep 17 00:00:00 2001 From: Jared Whiklo Date: Mon, 20 Sep 2021 09:46:52 -0500 Subject: [PATCH 2/6] Coder review --- jsonld.api.php | 9 +++++---- src/Utils/JsonldNormalizerUtils.php | 8 ++++---- src/Utils/JsonldNormalizerUtilsInterface.php | 1 + 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/jsonld.api.php b/jsonld.api.php index d6e2762..6f65478 100644 --- a/jsonld.api.php +++ b/jsonld.api.php @@ -10,15 +10,16 @@ /** * Hook to alter the jsonld normalized array before it is encoded to json. * + * $context['utils'] contains an instance of + * \Drupal\jsonld\Utils\JsonldNormalizerUtils, this provides the getEntityUri() + * method to correctly generate a URI with/without the ?format=jsonld suffix. + * * @param \Drupal\Core\Entity\EntityInterface $entity * The entity we are normalizing. * @param array $normalized * The current normalized array. * @param array $context - * The context for the normalization - * - * $context['utils'] contains an instance of \Drupal\jsonld\Utils\JsonldNormalizerUtils, this provides - * the getEntityUri() method to correctly generate a URI with/without the ?format=jsonld suffix. + * The context for the normalization. */ function hook_jsonld_alter_normalized_array(EntityInterface $entity, array &$normalized, array $context) { if ($entity->getEntityTypeId() == 'node') { diff --git a/src/Utils/JsonldNormalizerUtils.php b/src/Utils/JsonldNormalizerUtils.php index 97a556c..66b291f 100644 --- a/src/Utils/JsonldNormalizerUtils.php +++ b/src/Utils/JsonldNormalizerUtils.php @@ -2,7 +2,6 @@ namespace Drupal\jsonld\Utils; - use Drupal\Core\Config\ConfigFactoryInterface; use Drupal\Core\Entity\EntityInterface; use Drupal\Core\Language\LanguageManagerInterface; @@ -13,6 +12,7 @@ /** * Utilities used both in JSON-LD and by modules utilizing the alter hook. + * * @package Drupal\jsonld\Utils */ class JsonldNormalizerUtils implements JsonldNormalizerUtilsInterface { @@ -42,11 +42,11 @@ class JsonldNormalizerUtils implements JsonldNormalizerUtilsInterface { * NormalizerUtils constructor. * * @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory - * The configuration factory + * The configuration factory. * @param \Drupal\Core\Language\LanguageManagerInterface $language_manager - * The language manager + * The language manager. * @param \Drupal\Core\Routing\RouteProviderInterface $route_provider - * The route provider + * The route provider. */ public function __construct( ConfigFactoryInterface $config_factory, diff --git a/src/Utils/JsonldNormalizerUtilsInterface.php b/src/Utils/JsonldNormalizerUtilsInterface.php index 88092c5..f9ead8c 100644 --- a/src/Utils/JsonldNormalizerUtilsInterface.php +++ b/src/Utils/JsonldNormalizerUtilsInterface.php @@ -6,6 +6,7 @@ /** * Interface for dependency injection of JSON-LD normalizer utilities. + * * @package Drupal\jsonld\Utils */ interface JsonldNormalizerUtilsInterface { From 8f92ebef7ce7992628aa535802d9851afc3029c1 Mon Sep 17 00:00:00 2001 From: Jared Whiklo Date: Mon, 20 Sep 2021 11:44:40 -0500 Subject: [PATCH 3/6] Fix tests to use PHPUnit Also add --debug to PHPUnit to see what tests are run. --- .github/workflows/build-8.x-1.x.yml | 11 ++- composer.json | 33 ++++++++- phpunit.xml | 74 +++++++++++++++++++ .../Functional/JsonldContextGeneratorTest.php | 2 +- .../src/Kernel/JsonldContextGeneratorTest.php | 2 +- tests/src/Kernel/JsonldHookTest.php | 2 +- tests/src/Kernel/JsonldKernelTestBase.php | 7 +- ...=> JsonldContentEntityNormalizerTests.php} | 7 +- 8 files changed, 123 insertions(+), 15 deletions(-) create mode 100644 phpunit.xml rename tests/src/Kernel/Normalizer/{ContentEntityNormalizerTests.php => JsonldContentEntityNormalizerTests.php} (93%) diff --git a/.github/workflows/build-8.x-1.x.yml b/.github/workflows/build-8.x-1.x.yml index 8aa4aba..ec6103b 100644 --- a/.github/workflows/build-8.x-1.x.yml +++ b/.github/workflows/build-8.x-1.x.yml @@ -6,7 +6,7 @@ name: CI on: # Triggers the workflow on push or pull request events but only for the 8.x branch push: - branches: [ 8.x-1.x, main] + branches: [ 8.x-1.x, main, issue-1766-test] pull_request: branches: [ 8.x-1.x, main] @@ -70,6 +70,7 @@ jobs: echo "DRUPAL_VERSION=${{ matrix.drupal-version }}" >> $GITHUB_ENV echo "SCRIPT_DIR=$GITHUB_WORKSPACE/islandora_ci" >> $GITHUB_ENV echo "DRUPAL_DIR=/opt/drupal" >> $GITHUB_ENV + echo "PHPUNIT_FILE=$GITHUB_WORKSPACE/build_dir/phpunit.xml" >> $GITHUB_ENV - name: Cache Composer dependencies uses: actions/cache@v2 @@ -98,11 +99,13 @@ jobs: cd $DRUPAL_DIR/web drush --uri=127.0.0.1:8282 en -y user jsonld + - name: Copy PHPunit file + run: cp $PHPUNIT_FILE $DRUPAL_DIR/web/core/phpunit.xml + - name: Test scripts run: $SCRIPT_DIR/travis_scripts.sh - name: PHPUNIT tests run: | - cd $DRUPAL_DIR/web - php core/scripts/run-tests.sh --suppress-deprecations --url http://127.0.0.1:8282 --verbose --php `which php` --module jsonld - + cd $DRUPAL_DIR/web/core + $DRUPAL_DIR/vendor/bin/phpunit --verbose --debug diff --git a/composer.json b/composer.json index 9c71d8a..1efd6f4 100644 --- a/composer.json +++ b/composer.json @@ -14,10 +14,37 @@ "role": "Owner" }, { - "name": "Diego Pino", - "email": "dpino@metro.org", + "name": "Jared Whiklo", + "email": "jwhiklo@gmail.com", "role": "Maintainer" } ], - "require": {} + "require-dev": { + "phpunit/phpunit": "^8", + "squizlabs/php_codesniffer": "^3", + "drupal/coder": "*", + "sebastian/phpcpd": "*" + }, + "autoload": { + "psr-4": { + "Drupal\\jsonld\\": "src/" + } + }, + "autoload-dev": { + "psr-4": { + "Drupal\\Tests\\jsonld\\": "tests/src/" + } + }, + "scripts": { + "post-install-cmd": [ + "./vendor/bin/phpcs --config-set installed_paths ~/.composer/vendor/drupal/coder/coder_sniffer" + ], + "post-update-cmd": [ + "./vendor/bin/phpcs --config-set installed_paths ~/.composer/vendor/drupal/coder/coder_sniffer" + ], + "check": [ + "./vendor/bin/phpcs --standard=Drupal --ignore=*.md,vendor --extensions=php,module,inc,install,test,profile,theme,css,info .", + "./vendor/bin/phpcpd --names='*.module,*.inc,*.test,*.php' --exclude=vendor ." + ] + } } diff --git a/phpunit.xml b/phpunit.xml new file mode 100644 index 0000000..5debb88 --- /dev/null +++ b/phpunit.xml @@ -0,0 +1,74 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ../modules/contrib/jsonld/tests/src/Kernel + + + ../modules/contrib/jsonld/tests/src/Functional + + + + + + + + + + + + + + + + + ./includes + ./lib + ./modules + ../modules + ../sites + + ./modules/*/src/Tests + ./modules/*/tests + ../modules/*/src/Tests + ../modules/*/tests + ../modules/*/*/src/Tests + ../modules/*/*/tests + + + + \ No newline at end of file diff --git a/tests/src/Functional/JsonldContextGeneratorTest.php b/tests/src/Functional/JsonldContextGeneratorTest.php index 28cf9a5..649e4f3 100644 --- a/tests/src/Functional/JsonldContextGeneratorTest.php +++ b/tests/src/Functional/JsonldContextGeneratorTest.php @@ -36,7 +36,7 @@ class JsonldContextGeneratorTest extends BrowserTestBase { /** * Initial setup tasks that for every method method. */ - public function setUp() { + public function setUp() : void { parent::setUp(); // Create a test content type. diff --git a/tests/src/Kernel/JsonldContextGeneratorTest.php b/tests/src/Kernel/JsonldContextGeneratorTest.php index 127f584..9aeff21 100644 --- a/tests/src/Kernel/JsonldContextGeneratorTest.php +++ b/tests/src/Kernel/JsonldContextGeneratorTest.php @@ -52,7 +52,7 @@ class JsonldContextGeneratorTest extends JsonldKernelTestBase { /** * {@inheritdoc} */ - public function setUp() { + public function setUp() :void { parent::setUp(); $types = ['schema:Thing']; diff --git a/tests/src/Kernel/JsonldHookTest.php b/tests/src/Kernel/JsonldHookTest.php index d8609e4..3fa76ba 100644 --- a/tests/src/Kernel/JsonldHookTest.php +++ b/tests/src/Kernel/JsonldHookTest.php @@ -27,7 +27,7 @@ class JsonldHookTest extends JsonldKernelTestBase { /** * {@inheritdoc} */ - public function setUp() { + public function setUp() : void { parent::setUp(); \Drupal::service('router.builder')->rebuild(); } diff --git a/tests/src/Kernel/JsonldKernelTestBase.php b/tests/src/Kernel/JsonldKernelTestBase.php index 8e9df3f..e75f419 100644 --- a/tests/src/Kernel/JsonldKernelTestBase.php +++ b/tests/src/Kernel/JsonldKernelTestBase.php @@ -10,6 +10,7 @@ use Drupal\jsonld\Normalizer\EntityReferenceItemNormalizer; use Drupal\jsonld\Normalizer\FieldItemNormalizer; use Drupal\jsonld\Normalizer\FieldNormalizer; +use Drupal\jsonld\Utils\JsonldNormalizerUtils; use Drupal\KernelTests\KernelTestBase; use Drupal\serialization\EntityResolver\ChainEntityResolver; use Drupal\serialization\EntityResolver\TargetIdResolver; @@ -87,7 +88,7 @@ abstract class JsonldKernelTestBase extends KernelTestBase { /** * {@inheritdoc} */ - protected function setUp() { + protected function setUp() : void { parent::setUp(); $this->languageManager = \Drupal::service('language_manager'); @@ -182,9 +183,11 @@ protected function setUp() { $jsonld_context_generator = $this->container->get('jsonld.contextgenerator'); + $normalizer_utils = new JsonldNormalizerUtils(\Drupal::service('config.factory'), $this->languageManager, $this->routeProvider); + // Set up the mock serializer. $normalizers = [ - new ContentEntityNormalizer($link_manager, $entity_manager, \Drupal::moduleHandler(), \Drupal::service('config.factory'), $this->languageManager, $this->routeProvider), + new ContentEntityNormalizer($link_manager, $entity_manager, \Drupal::moduleHandler(), $normalizer_utils), new EntityReferenceItemNormalizer($link_manager, $chain_resolver, $jsonld_context_generator), new FieldItemNormalizer($jsonld_context_generator), new FieldNormalizer(), diff --git a/tests/src/Kernel/Normalizer/ContentEntityNormalizerTests.php b/tests/src/Kernel/Normalizer/JsonldContentEntityNormalizerTests.php similarity index 93% rename from tests/src/Kernel/Normalizer/ContentEntityNormalizerTests.php rename to tests/src/Kernel/Normalizer/JsonldContentEntityNormalizerTests.php index a5ba771..13f8230 100644 --- a/tests/src/Kernel/Normalizer/ContentEntityNormalizerTests.php +++ b/tests/src/Kernel/Normalizer/JsonldContentEntityNormalizerTests.php @@ -5,16 +5,17 @@ use Drupal\Tests\jsonld\Kernel\JsonldKernelTestBase; /** - * Class ContentEntityTests. + * Tests the JSON-LD Normalizer. * * @group jsonld + * @package \Drupal\Tests\jsonld\Kernel\Normalizer */ -class ContentEntityNormalizerTests extends JsonldKernelTestBase { +class JsonldContentEntityNormalizerTests extends JsonldKernelTestBase { /** * {@inheritdoc} */ - protected function setUp() { + protected function setUp() :void { parent::setUp(); \Drupal::service('router.builder')->rebuild(); From f55e7f376e4219d181435f1e1bc1fe918413c425 Mon Sep 17 00:00:00 2001 From: Jared Whiklo Date: Mon, 20 Sep 2021 14:51:02 -0500 Subject: [PATCH 4/6] Fix test name to end with "Test" It was not picked up previously and may never have been run. --- ...izerTests.php => JsonldContentEntityNormalizerTest.php} | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) rename tests/src/Kernel/Normalizer/{JsonldContentEntityNormalizerTests.php => JsonldContentEntityNormalizerTest.php} (91%) diff --git a/tests/src/Kernel/Normalizer/JsonldContentEntityNormalizerTests.php b/tests/src/Kernel/Normalizer/JsonldContentEntityNormalizerTest.php similarity index 91% rename from tests/src/Kernel/Normalizer/JsonldContentEntityNormalizerTests.php rename to tests/src/Kernel/Normalizer/JsonldContentEntityNormalizerTest.php index 13f8230..27c2d64 100644 --- a/tests/src/Kernel/Normalizer/JsonldContentEntityNormalizerTests.php +++ b/tests/src/Kernel/Normalizer/JsonldContentEntityNormalizerTest.php @@ -8,9 +8,8 @@ * Tests the JSON-LD Normalizer. * * @group jsonld - * @package \Drupal\Tests\jsonld\Kernel\Normalizer */ -class JsonldContentEntityNormalizerTests extends JsonldKernelTestBase { +class JsonldContentEntityNormalizerTest extends JsonldKernelTestBase { /** * {@inheritdoc} @@ -25,11 +24,11 @@ protected function setUp() :void { * @covers \Drupal\jsonld\Normalizer\NormalizerBase::supportsNormalization * @covers \Drupal\jsonld\Normalizer\NormalizerBase::escapePrefix * @covers \Drupal\jsonld\Normalizer\ContentEntityNormalizer::normalize - * @covers \Drupal\jsonld\Normalizer\ContentEntityNormalizer::getEntityUri * @covers \Drupal\jsonld\Normalizer\FieldNormalizer::normalize * @covers \Drupal\jsonld\Normalizer\FieldNormalizer::normalizeFieldItems * @covers \Drupal\jsonld\Normalizer\FieldItemNormalizer::normalize * @covers \Drupal\jsonld\Normalizer\EntityReferenceItemNormalizer::normalize + * @covers \Drupal\jsonld\Utils\JsonldNormalizerUtils::getEntityUri */ public function testSimpleNormalizeJsonld() { @@ -44,11 +43,11 @@ public function testSimpleNormalizeJsonld() { * @covers \Drupal\jsonld\Normalizer\NormalizerBase::supportsNormalization * @covers \Drupal\jsonld\Normalizer\NormalizerBase::escapePrefix * @covers \Drupal\jsonld\Normalizer\ContentEntityNormalizer::normalize - * @covers \Drupal\jsonld\Normalizer\ContentEntityNormalizer::getEntityUri * @covers \Drupal\jsonld\Normalizer\FieldNormalizer::normalize * @covers \Drupal\jsonld\Normalizer\FieldNormalizer::normalizeFieldItems * @covers \Drupal\jsonld\Normalizer\FieldItemNormalizer::normalize * @covers \Drupal\jsonld\Normalizer\EntityReferenceItemNormalizer::normalize + * @covers \Drupal\jsonld\Utils\JsonldNormalizerUtils::getEntityUri */ public function testLocalizedNormalizeJsonld() { From 5e1aa3479b01d2a44eb19b84c48da835d64053a5 Mon Sep 17 00:00:00 2001 From: Jared Whiklo Date: Mon, 20 Sep 2021 15:08:47 -0500 Subject: [PATCH 5/6] Remove composer.lock --- composer.lock | 18 ------------------ 1 file changed, 18 deletions(-) delete mode 100644 composer.lock diff --git a/composer.lock b/composer.lock deleted file mode 100644 index 64ccfba..0000000 --- a/composer.lock +++ /dev/null @@ -1,18 +0,0 @@ -{ - "_readme": [ - "This file locks the dependencies of your project to a known state", - "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", - "This file is @generated automatically" - ], - "content-hash": "10e2ac0726ff75523d5a41125a2045ca", - "packages": [], - "packages-dev": [], - "aliases": [], - "minimum-stability": "stable", - "stability-flags": [], - "prefer-stable": false, - "prefer-lowest": false, - "platform": [], - "platform-dev": [], - "plugin-api-version": "2.0.0" -} From 30e5fc480d29604e9e5a3a6532984adf17f57e43 Mon Sep 17 00:00:00 2001 From: Jared Whiklo Date: Mon, 20 Sep 2021 15:24:01 -0500 Subject: [PATCH 6/6] Remove test branch --- .github/workflows/build-8.x-1.x.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-8.x-1.x.yml b/.github/workflows/build-8.x-1.x.yml index ec6103b..03c6344 100644 --- a/.github/workflows/build-8.x-1.x.yml +++ b/.github/workflows/build-8.x-1.x.yml @@ -6,7 +6,7 @@ name: CI on: # Triggers the workflow on push or pull request events but only for the 8.x branch push: - branches: [ 8.x-1.x, main, issue-1766-test] + branches: [ 8.x-1.x, main] pull_request: branches: [ 8.x-1.x, main]