diff --git a/.github/workflows/module-test.yml b/.github/workflows/module-test.yml new file mode 100644 index 0000000..795d8d4 --- /dev/null +++ b/.github/workflows/module-test.yml @@ -0,0 +1,49 @@ +name: Run module tests + +on: + pull_request: + paths-ignore: + - '**.md' + + schedule: + - cron: '0 6 * * *' + +env: + DRUPAL_TESTING_TEST_CODING_STYLES: false + DRUPAL_TESTING_DATABASE_USER: root + DRUPAL_TESTING_DATABASE_PASSWORD: root + DRUPAL_TESTING_DATABASE_ENGINE: mysql + DRUPAL_TESTING_DRUPAL_VERSION: '~8.8.0' + +jobs: + build: + + runs-on: ubuntu-latest + + strategy: + matrix: + PHP: ['7.3', '7.4'] + + steps: + - uses: actions/checkout@v1 + + - uses: shivammathur/setup-php@v2 + with: + coverage: none + php-version: ${{ matrix.PHP }} + + - name: Start MySql service + run: sudo /etc/init.d/mysql start + + - name: Cache composer dependencies + uses: actions/cache@v1 + with: + path: ~/.composer/cache + key: ${{ runner.os }}-composer-cache-${{ hashFiles('**/composer.json') }} + restore-keys: ${{ runner.os }}-composer-cache- + + - name: Get build environment + run: composer global require thunder/drupal-testing + + - name: Run the tests + run: test-drupal-project diff --git a/.github/workflows/reviewdog.yml b/.github/workflows/reviewdog.yml new file mode 100644 index 0000000..a3f8995 --- /dev/null +++ b/.github/workflows/reviewdog.yml @@ -0,0 +1,39 @@ +name: Check coding styles + +on: [pull_request] + +jobs: + eslint: + name: runner / eslint + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v1 + + - name: eslint + uses: reviewdog/action-eslint@v1 + with: + github_token: ${{ secrets.github_token }} + + phpcs: + name: runner / phpcs + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v1 + + - name: phpcs + uses: chrfritsch/action-drupal-coder@v1 + with: + github_token: ${{ secrets.github_token }} + level: error + + misspell: + name: runner / misspell + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: reviewdog/action-misspell@v1 + with: + github_token: ${{ secrets.github_token }} + reporter: github-check + level: warning + locale: "US" diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index e5ac875..0000000 --- a/.travis.yml +++ /dev/null @@ -1,33 +0,0 @@ -language: php -dist: xenial - -services: - - mysql - -cache: - apt: true - directories: - - "$HOME/.composer/cache" - - "$HOME/.drush/cache" - - "$HOME/.npm" - -php: - - 7.2 - -branches: - only: - - /^8\.([0-9]+|x)\-[0-9]+\.([0-9]+|x)$/ - -env: - global: - - DRUPAL_TRAVIS_TEST_JAVASCRIPT=false - - PATH="$PATH:$HOME/.composer/vendor/bin" - -before_install: - - composer global require thunder/travis - -script: - - test-drupal-module - -notifications: - email: false diff --git a/composer.json b/composer.json index 1944ca2..bc66ab7 100644 --- a/composer.json +++ b/composer.json @@ -5,7 +5,8 @@ "license": "GPL-2.0-or-later", "minimum-stability": "dev", "require": { - "drupal/breakpoint_js_settings": "~1.0" + "drupal/breakpoint_js_settings": "~1.0", + "drupal/token": "^1.7" }, "require-dev": { "burdamagazinorg/thunder-dev-tools": "dev-master" diff --git a/config/schema/ivw_integration.schema.yml b/config/schema/ivw_integration.schema.yml index c880eec..22ddb5a 100644 --- a/config/schema/ivw_integration.schema.yml +++ b/config/schema/ivw_integration.schema.yml @@ -1,3 +1,41 @@ +field.value.ivw_integration_settings: + type: mapping + label: 'Default value' + mapping: + offering: + type: string + label: 'Offering' + language: + type: string + label: 'Language' + frabo: + type: string + label: 'Frabo' + frabo_mobile: + type: string + label: 'Frabo mobile' + format: + type: string + label: 'Format' + creator: + type: string + label: 'Creator' + homepage: + type: string + label: 'Homepage' + delivery: + type: string + label: 'Delivery' + app: + type: string + label: 'App' + paid: + type: string + label: 'Paid' + content: + type: string + label: 'Content' + ivw_integration.settings: type: config_object label: 'IVW Settings' @@ -24,38 +62,38 @@ ivw_integration.settings: type: boolean label: 'Offering setting is overridable' language_default: - type: integer - label: 'Default language code' + type: integer + label: 'Default language code' language_overridable: type: boolean label: 'Language setting is overridable' format_default: - type: integer - label: 'Default format code' + type: integer + label: 'Default format code' format_overridable: type: boolean label: 'Format setting is overridable' creator_default: - type: integer - label: 'Default creator code' + type: integer + label: 'Default creator code' creator_overridable: type: boolean label: 'Creator setting is overridable' homepage_default: - type: integer - label: 'Default homepage code' + type: integer + label: 'Default homepage code' homepage_overridable: type: boolean label: 'Homepage setting is overridable' delivery_default: - type: integer - label: 'Default delivery code' + type: integer + label: 'Default delivery code' delivery_overridable: type: boolean label: 'Delivery setting is overridable' app_default: - type: integer - label: 'Default app flag' + type: integer + label: 'Default app flag' app_overridable: type: boolean label: 'App setting is overridable' @@ -66,8 +104,8 @@ ivw_integration.settings: type: boolean label: 'Paid setting is overridable' content_default: - type: string - label: 'Default content code' + type: string + label: 'Default content code' content_overridable: type: boolean label: 'Content setting is overridable' diff --git a/src/IvwLookupService.php b/src/IvwLookupService.php index 52a6efb..ea22b5d 100644 --- a/src/IvwLookupService.php +++ b/src/IvwLookupService.php @@ -238,6 +238,7 @@ public function byTerm($name, TermInterface $term, $parentOnly = FALSE) { * The property value. */ protected function searchEntity($name, ContentEntityInterface $entity, $parentOnly = FALSE) { + $termOverride = NULL; // Search for ivw_integration_settings field. foreach ($entity->getFieldDefinitions() as $fieldDefinition) { $fieldType = $fieldDefinition->getType(); @@ -246,14 +247,15 @@ protected function searchEntity($name, ContentEntityInterface $entity, $parentOn * If settings are found, check if an overridden value for the * given setting is found and return that */ - $overiddenSetting = $this->getOverriddenIvwSetting($name, $fieldDefinition, $entity); + $overiddenSetting = $this->getOverriddenIvwSetting($name, + $fieldDefinition, $entity); if (isset($overiddenSetting)) { return $overiddenSetting; } } // Check for fallback categories if no ivw_integration_setting is found. - if ($fieldType === 'entity_reference' && $fieldDefinition->getSetting('target_type') === 'taxonomy_term') { + if (!isset($termOverride) && $fieldType === 'entity_reference' && $fieldDefinition->getSetting('target_type') === 'taxonomy_term') { $fieldName = $fieldDefinition->getName(); if ($tid = $entity->$fieldName->target_id) { /** @var \Drupal\taxonomy\TermInterface $term */ @@ -265,14 +267,10 @@ protected function searchEntity($name, ContentEntityInterface $entity, $parentOn } } } - - // Return found termOverride. - if (isset($termOverride)) { - return $termOverride; - } } - return NULL; + // Return found termOverride. + return $termOverride ?? NULL; } /** diff --git a/tests/modules/ivw_integration_test/config/install/block.block.ivwcall.yml b/tests/modules/ivw_integration_test/config/install/block.block.ivwcall.yml new file mode 100644 index 0000000..87e5ccb --- /dev/null +++ b/tests/modules/ivw_integration_test/config/install/block.block.ivwcall.yml @@ -0,0 +1,19 @@ +langcode: en +status: true +dependencies: + module: + - ivw_integration + theme: + - stark +id: ivwcall +theme: stark +region: header +weight: 0 +provider: null +plugin: ivw_integration_call_block +settings: + id: ivw_integration_call_block + label: 'IVW call' + provider: ivw_integration + label_display: visible +visibility: { } diff --git a/tests/modules/ivw_integration_test/config/install/core.entity_form_display.node.ivw_test.default.yml b/tests/modules/ivw_integration_test/config/install/core.entity_form_display.node.ivw_test.default.yml new file mode 100644 index 0000000..8dea21d --- /dev/null +++ b/tests/modules/ivw_integration_test/config/install/core.entity_form_display.node.ivw_test.default.yml @@ -0,0 +1,79 @@ +langcode: en +status: true +dependencies: + config: + - field.field.node.ivw_test.field_a + - field.field.node.ivw_test.field_ivw_settings + - field.field.node.ivw_test.field_z + - node.type.ivw_test + module: + - ivw_integration +id: node.ivw_test.default +targetEntityType: node +bundle: ivw_test +mode: default +content: + created: + type: datetime_timestamp + weight: 2 + region: content + settings: { } + third_party_settings: { } + field_a: + weight: 26 + settings: { } + third_party_settings: { } + type: options_select + region: content + field_ivw_settings: + type: ivw_integration_widget + weight: 6 + region: content + settings: { } + third_party_settings: { } + field_z: + weight: 27 + settings: { } + third_party_settings: { } + type: options_select + region: content + promote: + type: boolean_checkbox + settings: + display_label: true + weight: 3 + region: content + third_party_settings: { } + status: + type: boolean_checkbox + settings: + display_label: true + weight: 5 + region: content + third_party_settings: { } + sticky: + type: boolean_checkbox + settings: + display_label: true + weight: 4 + region: content + third_party_settings: { } + title: + type: string_textfield + weight: 0 + region: content + settings: + size: 60 + placeholder: '' + third_party_settings: { } + uid: + type: entity_reference_autocomplete + weight: 1 + settings: + match_operator: CONTAINS + size: 60 + placeholder: '' + match_limit: 10 + region: content + third_party_settings: { } +hidden: { } diff --git a/tests/modules/ivw_integration_test/config/install/core.entity_form_display.taxonomy_term.ivw_taxonomy.default.yml b/tests/modules/ivw_integration_test/config/install/core.entity_form_display.taxonomy_term.ivw_taxonomy.default.yml new file mode 100644 index 0000000..ce760d9 --- /dev/null +++ b/tests/modules/ivw_integration_test/config/install/core.entity_form_display.taxonomy_term.ivw_taxonomy.default.yml @@ -0,0 +1,44 @@ +langcode: en +status: true +dependencies: + config: + - field.field.taxonomy_term.ivw_taxonomy.field_ivw_settings + - taxonomy.vocabulary.ivw_taxonomy + module: + - ivw_integration + - text +id: taxonomy_term.ivw_taxonomy.default +targetEntityType: taxonomy_term +bundle: ivw_taxonomy +mode: default +content: + description: + type: text_textfield + weight: 0 + region: content + settings: + size: 60 + placeholder: '' + third_party_settings: { } + field_ivw_settings: + weight: 101 + settings: { } + third_party_settings: { } + type: ivw_integration_widget + region: content + name: + type: string_textfield + weight: -5 + region: content + settings: + size: 60 + placeholder: '' + third_party_settings: { } + status: + type: boolean_checkbox + settings: + display_label: true + weight: 100 + region: content + third_party_settings: { } +hidden: { } diff --git a/tests/modules/ivw_integration_test/config/install/core.entity_view_display.node.ivw_test.default.yml b/tests/modules/ivw_integration_test/config/install/core.entity_view_display.node.ivw_test.default.yml new file mode 100644 index 0000000..de881f2 --- /dev/null +++ b/tests/modules/ivw_integration_test/config/install/core.entity_view_display.node.ivw_test.default.yml @@ -0,0 +1,38 @@ +langcode: en +status: true +dependencies: + config: + - field.field.node.ivw_test.field_a + - field.field.node.ivw_test.field_ivw_settings + - field.field.node.ivw_test.field_z + - node.type.ivw_test + module: + - user +id: node.ivw_test.default +targetEntityType: node +bundle: ivw_test +mode: default +content: + field_a: + weight: 1 + label: above + settings: + link: true + third_party_settings: { } + type: entity_reference_label + region: content + field_z: + weight: 2 + label: above + settings: + link: true + third_party_settings: { } + type: entity_reference_label + region: content + links: + weight: 0 + region: content + settings: { } + third_party_settings: { } +hidden: + field_ivw_settings: true diff --git a/tests/modules/ivw_integration_test/config/install/field.field.node.ivw_test.field_a.yml b/tests/modules/ivw_integration_test/config/install/field.field.node.ivw_test.field_a.yml new file mode 100644 index 0000000..d2d7036 --- /dev/null +++ b/tests/modules/ivw_integration_test/config/install/field.field.node.ivw_test.field_a.yml @@ -0,0 +1,28 @@ +langcode: en +status: true +dependencies: + config: + - field.storage.node.field_a + - node.type.ivw_test + - taxonomy.vocabulary.ivw_taxonomy +id: node.ivw_test.field_a +field_name: field_a +entity_type: node +bundle: ivw_test +label: a +description: '' +required: false +translatable: false +default_value: { } +default_value_callback: '' +settings: + handler: 'default:taxonomy_term' + handler_settings: + target_bundles: + ivw_taxonomy: ivw_taxonomy + sort: + field: name + direction: asc + auto_create: false + auto_create_bundle: '' +field_type: entity_reference diff --git a/tests/modules/ivw_integration_test/config/install/field.field.node.ivw_test.field_ivw_settings.yml b/tests/modules/ivw_integration_test/config/install/field.field.node.ivw_test.field_ivw_settings.yml new file mode 100644 index 0000000..f1027b5 --- /dev/null +++ b/tests/modules/ivw_integration_test/config/install/field.field.node.ivw_test.field_ivw_settings.yml @@ -0,0 +1,32 @@ +langcode: en +status: true +dependencies: + config: + - field.storage.node.field_ivw_settings + - node.type.ivw_test + module: + - ivw_integration +id: node.ivw_test.field_ivw_settings +field_name: field_ivw_settings +entity_type: node +bundle: ivw_test +label: 'ivw settings' +description: '' +required: false +translatable: false +default_value: + - + offering: null + language: null + frabo: null + frabo_mobile: null + format: '' + creator: '' + homepage: null + delivery: null + app: null + paid: null + content: '' +default_value_callback: '' +settings: { } +field_type: ivw_integration_settings diff --git a/tests/modules/ivw_integration_test/config/install/field.field.node.ivw_test.field_z.yml b/tests/modules/ivw_integration_test/config/install/field.field.node.ivw_test.field_z.yml new file mode 100644 index 0000000..cfccb8e --- /dev/null +++ b/tests/modules/ivw_integration_test/config/install/field.field.node.ivw_test.field_z.yml @@ -0,0 +1,28 @@ +langcode: en +status: true +dependencies: + config: + - field.storage.node.field_z + - node.type.ivw_test + - taxonomy.vocabulary.ivw_taxonomy +id: node.ivw_test.field_z +field_name: field_z +entity_type: node +bundle: ivw_test +label: z +description: '' +required: false +translatable: false +default_value: { } +default_value_callback: '' +settings: + handler: 'default:taxonomy_term' + handler_settings: + target_bundles: + ivw_taxonomy: ivw_taxonomy + sort: + field: name + direction: asc + auto_create: false + auto_create_bundle: '' +field_type: entity_reference diff --git a/tests/modules/ivw_integration_test/config/install/field.field.taxonomy_term.ivw_taxonomy.field_ivw_settings.yml b/tests/modules/ivw_integration_test/config/install/field.field.taxonomy_term.ivw_taxonomy.field_ivw_settings.yml new file mode 100644 index 0000000..d5752b4 --- /dev/null +++ b/tests/modules/ivw_integration_test/config/install/field.field.taxonomy_term.ivw_taxonomy.field_ivw_settings.yml @@ -0,0 +1,20 @@ +langcode: en +status: true +dependencies: + config: + - field.storage.taxonomy_term.field_ivw_settings + - taxonomy.vocabulary.ivw_taxonomy + module: + - ivw_integration +id: taxonomy_term.ivw_taxonomy.field_ivw_settings +field_name: field_ivw_settings +entity_type: taxonomy_term +bundle: ivw_taxonomy +label: 'ivw settings' +description: '' +required: false +translatable: false +default_value: { } +default_value_callback: '' +settings: { } +field_type: ivw_integration_settings diff --git a/tests/modules/ivw_integration_test/config/install/field.storage.node.field_a.yml b/tests/modules/ivw_integration_test/config/install/field.storage.node.field_a.yml new file mode 100644 index 0000000..e92ffaf --- /dev/null +++ b/tests/modules/ivw_integration_test/config/install/field.storage.node.field_a.yml @@ -0,0 +1,19 @@ +langcode: en +status: true +dependencies: + module: + - node + - taxonomy +id: node.field_a +field_name: field_a +entity_type: node +type: entity_reference +settings: + target_type: taxonomy_term +module: core +locked: false +cardinality: 1 +translatable: true +indexes: { } +persist_with_no_fields: false +custom_storage: false diff --git a/tests/modules/ivw_integration_test/config/install/field.storage.node.field_ivw_settings.yml b/tests/modules/ivw_integration_test/config/install/field.storage.node.field_ivw_settings.yml new file mode 100644 index 0000000..fdb1143 --- /dev/null +++ b/tests/modules/ivw_integration_test/config/install/field.storage.node.field_ivw_settings.yml @@ -0,0 +1,18 @@ +langcode: en +status: true +dependencies: + module: + - ivw_integration + - node +id: node.field_ivw_settings +field_name: field_ivw_settings +entity_type: node +type: ivw_integration_settings +settings: { } +module: ivw_integration +locked: false +cardinality: 1 +translatable: true +indexes: { } +persist_with_no_fields: false +custom_storage: false diff --git a/tests/modules/ivw_integration_test/config/install/field.storage.node.field_z.yml b/tests/modules/ivw_integration_test/config/install/field.storage.node.field_z.yml new file mode 100644 index 0000000..dfe93f6 --- /dev/null +++ b/tests/modules/ivw_integration_test/config/install/field.storage.node.field_z.yml @@ -0,0 +1,19 @@ +langcode: en +status: true +dependencies: + module: + - node + - taxonomy +id: node.field_z +field_name: field_z +entity_type: node +type: entity_reference +settings: + target_type: taxonomy_term +module: core +locked: false +cardinality: 1 +translatable: true +indexes: { } +persist_with_no_fields: false +custom_storage: false diff --git a/tests/modules/ivw_integration_test/config/install/field.storage.taxonomy_term.field_ivw_settings.yml b/tests/modules/ivw_integration_test/config/install/field.storage.taxonomy_term.field_ivw_settings.yml new file mode 100644 index 0000000..d4ff395 --- /dev/null +++ b/tests/modules/ivw_integration_test/config/install/field.storage.taxonomy_term.field_ivw_settings.yml @@ -0,0 +1,18 @@ +langcode: en +status: true +dependencies: + module: + - ivw_integration + - taxonomy +id: taxonomy_term.field_ivw_settings +field_name: field_ivw_settings +entity_type: taxonomy_term +type: ivw_integration_settings +settings: { } +module: ivw_integration +locked: false +cardinality: 1 +translatable: true +indexes: { } +persist_with_no_fields: false +custom_storage: false diff --git a/tests/modules/ivw_integration_test/config/install/node.type.ivw_test.yml b/tests/modules/ivw_integration_test/config/install/node.type.ivw_test.yml new file mode 100644 index 0000000..10cfb3d --- /dev/null +++ b/tests/modules/ivw_integration_test/config/install/node.type.ivw_test.yml @@ -0,0 +1,10 @@ +langcode: en +status: true +dependencies: { } +name: 'ivw test' +type: ivw_test +description: '' +help: '' +new_revision: true +preview_mode: 1 +display_submitted: true diff --git a/tests/modules/ivw_integration_test/config/install/taxonomy.vocabulary.ivw_taxonomy.yml b/tests/modules/ivw_integration_test/config/install/taxonomy.vocabulary.ivw_taxonomy.yml new file mode 100644 index 0000000..f136c9a --- /dev/null +++ b/tests/modules/ivw_integration_test/config/install/taxonomy.vocabulary.ivw_taxonomy.yml @@ -0,0 +1,7 @@ +langcode: en +status: true +dependencies: { } +name: 'ivw taxonomy' +vid: ivw_taxonomy +description: '' +weight: 0 diff --git a/tests/modules/ivw_integration_test/ivw_integration_test.info.yml b/tests/modules/ivw_integration_test/ivw_integration_test.info.yml new file mode 100644 index 0000000..d2eb1a3 --- /dev/null +++ b/tests/modules/ivw_integration_test/ivw_integration_test.info.yml @@ -0,0 +1,10 @@ +name: 'IVW integration test' +type: module +description: 'Support module for IVW integration tests.' +package: Testing +dependencies: + - ivw_integration:ivw_integration + - drupal:field + - drupal:node + - drupal:block + - drupal:taxonomy diff --git a/tests/src/Functional/IvwIntegrationOverrideTest.php b/tests/src/Functional/IvwIntegrationOverrideTest.php new file mode 100644 index 0000000..6f65dc7 --- /dev/null +++ b/tests/src/Functional/IvwIntegrationOverrideTest.php @@ -0,0 +1,231 @@ +adminUser = $this->drupalCreateUser([ + 'create ivw_test content', + 'administer ivw integration configuration', + 'create terms in ivw_taxonomy', + ]); + + // Setting defaults. To provide sane defaults and have a quick reference for + // the actual tests. + $this->config('ivw_integration.settings')->set('site', 'TestSiteName') + ->set('mobile_site', 'TestMobileSiteName') + ->set('frabo_default', 'IN') + ->set('frabo_mobile_default', 'mo') + ->set('frabo_overridable', 0) + ->set('frabo_mobile_overridable', 0) + ->set('code_template', '[ivw:offering]L[ivw:language]F[ivw:format]S[ivw:creator]H[ivw:homepage]D[ivw:delivery]A[ivw:app]P[ivw:paid]C[ivw:content]') + ->set('responsive', 1) + ->set('mobile_width', 480) + ->set('offering_default', '01') + ->set('offering_overridable', 0) + ->set('language_default', 1) + ->set('language_overridable', 0) + ->set('format_default', 1) + ->set('format_overridable', 0) + ->set('creator_default', 1) + ->set('creator_overridable', 0) + ->set('homepage_default', 2) + ->set('homepage_overridable', 0) + ->set('delivery_default', 1) + ->set('delivery_overridable', 0) + ->set('app_default', 1) + ->set('app_overridable', 0) + ->set('paid_default', 1) + ->set('paid_overridable', 0) + ->set('content_default', '01') + ->set('content_overridable', 0) + ->set('mcvd', 0) + ->save(); + + $this->drupalLogin($this->adminUser); + } + + /** + * Tests overriding of site values. + * + * @dataProvider overrideTestCases + */ + public function testOverride($settings, $termFieldOverrides, $nodeOverrides, $expectedOutput) { + if (!empty($settings)) { + $ivwSettings = $this->config('ivw_integration.settings'); + foreach ($settings as $settingName => $settingValue) { + $ivwSettings->set($settingName, $settingValue); + } + $ivwSettings->save(); + } + + $nodeEdit = [ + 'title[0][value]' => $this->randomString(), + ]; + + if (!empty($nodeOverrides)) { + foreach ($nodeOverrides as $nodeOverrideName => $nodeOverrideValue) { + $nodeEdit["field_ivw_settings[0][$nodeOverrideName]"] = $nodeOverrideValue; + } + } + + if (!empty($termFieldOverrides)) { + $field_name = array_key_first($termFieldOverrides); + + // Load the term edit page. + $this->drupalGet('admin/structure/taxonomy/manage/ivw_taxonomy/add'); + $this->assertSession()->statusCodeEquals(200); + + $termName = $this->randomString(); + $termEdit = [ + 'name[0][value]' => $termName, + ]; + + foreach ($termFieldOverrides[$field_name] as $termOverrideName => $termOverrideValue) { + $termEdit["field_ivw_settings[0][$termOverrideName]"] = $termOverrideValue; + } + + $this->drupalPostForm(NULL, $termEdit, 'Save'); + + $terms = taxonomy_term_load_multiple_by_name($termName); + $term = reset($terms); + $nodeEdit[$field_name] = $term->id(); + } + + // Load the node edit page. + $this->drupalGet('node/add/ivw_test'); + $this->assertSession()->statusCodeEquals(200); + + $this->drupalPostForm(NULL, $nodeEdit, 'Save'); + $this->assertSession()->pageTextContains($expectedOutput); + } + + /** + * A data provider for testOverride. + */ + public function overrideTestCases() { + return [ + 'No overrides' => [ + [ + 'content_default' => '01', + 'content_overridable' => 0, + 'code_template' => 'IVWContent-[ivw:content]', + ], + [], + [], + 'IVWContent-01', + ], + 'Override enabled, but no override value given in node' => [ + [ + 'content_default' => '01', + 'content_overridable' => 1, + 'code_template' => 'IVWContent-[ivw:content]', + ], + [], + [], + 'IVWContent-01', + ], + 'Override with value given in node' => [ + [ + 'content_default' => '01', + 'content_overridable' => 1, + 'code_template' => 'IVWContent-[ivw:content]', + ], + [], + [ + 'content' => '02', + ], + 'IVWContent-02', + ], + 'Override with value given in taxonomy' => [ + [ + 'content_default' => '01', + 'content_overridable' => 1, + 'code_template' => 'IVWContent-[ivw:content]', + ], + [ + 'field_a' => + [ + 'content' => '03', + ], + ], + [], + 'IVWContent-03', + ], + 'Override with value given in taxonomy field a and node' => [ + [ + 'content_default' => '01', + 'content_overridable' => 1, + 'code_template' => 'IVWContent-[ivw:content]', + ], + [ + 'field_a' => + [ + 'content' => '04', + ], + ], + [ + 'content' => '05', + ], + 'IVWContent-05', + ], + 'Override with value given in taxonomy field z and node' => [ + [ + 'content_default' => '01', + 'content_overridable' => 1, + 'code_template' => 'IVWContent-[ivw:content]', + ], + [ + 'field_z' => + [ + 'content' => '04', + ], + ], + [ + 'content' => '05', + ], + 'IVWContent-05', + ], + ]; + } + +} diff --git a/tests/src/Unit/IvwLookupServiceTest.php b/tests/src/Unit/IvwLookupServiceTest.php index 2de6e68..06282f8 100644 --- a/tests/src/Unit/IvwLookupServiceTest.php +++ b/tests/src/Unit/IvwLookupServiceTest.php @@ -39,8 +39,8 @@ class IvwLookupServiceTest extends UnitTestCase { */ public static function getInfo() { return [ - 'name' => "IvwLookupServic's controller functionality", - 'description' => 'Test Unit for module ivw_integration and service IvwLookupServic.', + 'name' => "IvwLookupService's controller functionality", + 'description' => 'Test Unit for module ivw_integration and service IvwLookupService.', ]; } @@ -67,8 +67,8 @@ protected function setUpConfigFactoryMock() { $config = new Config('ivw_integration', $storage, $event_dispatcher, $typed_config); $config->set('site', 'TestSiteName'); $config->set('mobile_site', 'TestMobileSiteName'); - $config->set('frabo', 'IN'); - $config->set('frabo_mobile', 'mo'); + $config->set('frabo_default', 'IN'); + $config->set('frabo_mobile_default', 'mo'); $config->set('frabo_overridable', 0); $config->set('frabo_mobile_overridable', 0); $config->set('code_template', '[ivw:offering]L[ivw:language]F[ivw:format]S[ivw:creator]H[ivw:homepage]D[ivw:delivery]A[ivw:app]P[ivw:paid]C[ivw:content]');