diff --git a/tests/modules/iiif_media_source_test/config/install/core.entity_form_display.node.iiif_test.default.yml b/tests/modules/iiif_media_source_test/config/install/core.entity_form_display.node.iiif_test.default.yml new file mode 100644 index 0000000..c574a41 --- /dev/null +++ b/tests/modules/iiif_media_source_test/config/install/core.entity_form_display.node.iiif_test.default.yml @@ -0,0 +1,131 @@ +langcode: en +status: true +dependencies: + config: + - field.field.node.iiif_test.field_iiif_test_1 + - field.field.node.iiif_test.field_iiif_test_2 + - field.field.node.iiif_test.field_iiif_test_3 + - field.field.node.iiif_test.field_iiif_test_4 + - field.field.node.iiif_test.field_iiif_test_5 + - node.type.iiif_test + module: + - iiif_media_source + - iiif_media_source_test + - path + enforced: + module: + - iiif_media_source_test +id: node.iiif_test.default +targetEntityType: node +bundle: iiif_test +mode: default +content: + created: + type: datetime_timestamp + weight: 3 + region: content + settings: { } + third_party_settings: { } + field_iiif_test_1: + type: iiif_id_widget + weight: 10 + region: content + settings: + size: 60 + placeholder: '' + third_party_settings: { } + field_iiif_test_2: + type: iiif_image_widget + weight: 11 + region: content + settings: + size: 60 + placeholder: '' + third_party_settings: { } + field_iiif_test_3: + type: iiif_image_widget + weight: 12 + region: content + settings: + size: 60 + placeholder: '' + third_party_settings: { } + field_iiif_test_4: + type: iiif_image_widget + weight: 13 + region: content + settings: + size: 60 + placeholder: '' + third_party_settings: { } + field_iiif_test_5: + type: iiif_image_widget + weight: 14 + region: content + settings: + size: 60 + placeholder: '' + third_party_settings: { } + langcode: + type: language_select + weight: 1 + region: content + settings: + include_locked: true + third_party_settings: { } + path: + type: path + weight: 7 + region: content + settings: { } + third_party_settings: { } + promote: + type: boolean_checkbox + weight: 5 + region: content + settings: + display_label: true + third_party_settings: { } + simple_sitemap: + weight: 4 + region: content + settings: { } + third_party_settings: { } + status: + type: boolean_checkbox + weight: 9 + region: content + settings: + display_label: true + third_party_settings: { } + sticky: + type: boolean_checkbox + weight: 6 + region: content + settings: + display_label: true + third_party_settings: { } + title: + type: string_textfield + weight: 0 + region: content + settings: + size: 60 + placeholder: '' + third_party_settings: { } + uid: + type: entity_reference_autocomplete + weight: 2 + region: content + settings: + match_operator: CONTAINS + match_limit: 10 + size: 60 + placeholder: '' + third_party_settings: { } + url_redirects: + weight: 8 + region: content + settings: { } + third_party_settings: { } +hidden: { } diff --git a/tests/modules/iiif_media_source_test/config/install/core.entity_view_display.node.iiif_test.default.yml b/tests/modules/iiif_media_source_test/config/install/core.entity_view_display.node.iiif_test.default.yml new file mode 100644 index 0000000..f7dfce7 --- /dev/null +++ b/tests/modules/iiif_media_source_test/config/install/core.entity_view_display.node.iiif_test.default.yml @@ -0,0 +1,117 @@ +langcode: en +status: true +dependencies: + config: + - field.field.node.iiif_test.field_iiif_test_1 + - field.field.node.iiif_test.field_iiif_test_2 + - field.field.node.iiif_test.field_iiif_test_3 + - field.field.node.iiif_test.field_iiif_test_4 + - field.field.node.iiif_test.field_iiif_test_5 + - node.type.iiif_test + module: + - iiif_media_source + - iiif_media_source_test + - user + enforced: + module: + - iiif_media_source_test +id: node.iiif_test.default +targetEntityType: node +bundle: iiif_test +mode: default +content: + field_iiif_test_1: + type: iiif_id_formatter + label: above + settings: + link_to_entity: false + third_party_settings: { } + weight: 0 + region: content + field_iiif_test_2: + type: iiif_image_formatter + label: above + settings: + region: full + region_x: '' + region_y: '' + region_w: '' + region_h: '' + size: full + size_w: '' + size_h: '' + rotation: 0 + quality: default + format: png + image_loading: + attribute: lazy + link_to_entity: false + third_party_settings: { } + weight: 1 + region: content + field_iiif_test_3: + type: iiif_image_formatter + label: above + settings: + region: full + region_x: '' + region_y: '' + region_w: '' + region_h: '' + size: 'w,' + size_w: '600' + size_h: '' + rotation: 0 + quality: default + format: png + image_loading: + attribute: eager + link_to_entity: false + third_party_settings: { } + weight: 2 + region: content + field_iiif_test_4: + type: iiif_image_formatter + label: above + settings: + link_to_entity: false + region: full + region_x: '' + region_y: '' + region_w: '' + region_h: '' + size: max + size_w: '' + size_h: '' + rotation: 0 + quality: default + format: png + image_loading: + attribute: lazy + third_party_settings: { } + weight: 3 + region: content + field_iiif_test_5: + type: iiif_image_formatter + label: above + settings: + link_to_entity: false + region: full + region_x: '' + region_y: '' + region_w: '' + region_h: '' + size: max + size_w: '' + size_h: '' + rotation: 0 + quality: default + format: png + image_loading: + attribute: lazy + third_party_settings: { } + weight: 4 + region: content +hidden: + langcode: true + links: true diff --git a/tests/modules/iiif_media_source_test/config/install/field.field.node.iiif_test.field_iiif_test_1.yml b/tests/modules/iiif_media_source_test/config/install/field.field.node.iiif_test.field_iiif_test_1.yml new file mode 100644 index 0000000..7c32370 --- /dev/null +++ b/tests/modules/iiif_media_source_test/config/install/field.field.node.iiif_test.field_iiif_test_1.yml @@ -0,0 +1,27 @@ +langcode: en +status: true +dependencies: + config: + - field.storage.node.field_iiif_test_1 + - node.type.iiif_test + module: + - iiif_media_source + - iiif_media_source_test + enforced: + module: + - iiif_media_source_test +id: node.iiif_test.field_iiif_test_1 +field_name: field_iiif_test_1 +entity_type: node +bundle: iiif_test +label: 'IIIF Test 1' +description: '' +required: false +translatable: false +default_value: { } +default_value_callback: '' +settings: + server: 'https://media.nga.gov' + prefix: iiif + img_api_version: '2' +field_type: iiif_id diff --git a/tests/modules/iiif_media_source_test/config/install/field.field.node.iiif_test.field_iiif_test_2.yml b/tests/modules/iiif_media_source_test/config/install/field.field.node.iiif_test.field_iiif_test_2.yml new file mode 100644 index 0000000..44d1ae2 --- /dev/null +++ b/tests/modules/iiif_media_source_test/config/install/field.field.node.iiif_test.field_iiif_test_2.yml @@ -0,0 +1,27 @@ +langcode: en +status: true +dependencies: + config: + - field.storage.node.field_iiif_test_2 + - node.type.iiif_test + module: + - iiif_media_source + - iiif_media_source_test + enforced: + module: + - iiif_media_source_test +id: node.iiif_test.field_iiif_test_2 +field_name: field_iiif_test_2 +entity_type: node +bundle: iiif_test +label: 'IIIF Test 2' +description: '' +required: false +translatable: false +default_value: { } +default_value_callback: '' +settings: + server: 'https://media.nga.gov' + prefix: iiif + img_api_version: '2' +field_type: iiif_id diff --git a/tests/modules/iiif_media_source_test/config/install/field.field.node.iiif_test.field_iiif_test_3.yml b/tests/modules/iiif_media_source_test/config/install/field.field.node.iiif_test.field_iiif_test_3.yml new file mode 100644 index 0000000..2c43525 --- /dev/null +++ b/tests/modules/iiif_media_source_test/config/install/field.field.node.iiif_test.field_iiif_test_3.yml @@ -0,0 +1,27 @@ +langcode: en +status: true +dependencies: + config: + - field.storage.node.field_iiif_test_3 + - node.type.iiif_test + module: + - iiif_media_source + - iiif_media_source_test + enforced: + module: + - iiif_media_source_test +id: node.iiif_test.field_iiif_test_3 +field_name: field_iiif_test_3 +entity_type: node +bundle: iiif_test +label: 'IIIF Test 3' +description: '' +required: false +translatable: false +default_value: { } +default_value_callback: '' +settings: + server: 'https://media.nga.gov' + prefix: iiif + img_api_version: '2' +field_type: iiif_id diff --git a/tests/modules/iiif_media_source_test/config/install/field.field.node.iiif_test.field_iiif_test_4.yml b/tests/modules/iiif_media_source_test/config/install/field.field.node.iiif_test.field_iiif_test_4.yml new file mode 100644 index 0000000..806dc33 --- /dev/null +++ b/tests/modules/iiif_media_source_test/config/install/field.field.node.iiif_test.field_iiif_test_4.yml @@ -0,0 +1,27 @@ +langcode: en +status: true +dependencies: + config: + - field.storage.node.field_iiif_test_4 + - node.type.iiif_test + module: + - iiif_media_source + - iiif_media_source_test + enforced: + module: + - iiif_media_source_test +id: node.iiif_test.field_iiif_test_4 +field_name: field_iiif_test_4 +entity_type: node +bundle: iiif_test +label: 'IIIF Test 4' +description: '' +required: false +translatable: false +default_value: { } +default_value_callback: '' +settings: + server: 'https://media.nga.gov' + prefix: iiif + img_api_version: '2' +field_type: iiif_id diff --git a/tests/modules/iiif_media_source_test/config/install/field.field.node.iiif_test.field_iiif_test_5.yml b/tests/modules/iiif_media_source_test/config/install/field.field.node.iiif_test.field_iiif_test_5.yml new file mode 100644 index 0000000..4554f24 --- /dev/null +++ b/tests/modules/iiif_media_source_test/config/install/field.field.node.iiif_test.field_iiif_test_5.yml @@ -0,0 +1,27 @@ +langcode: en +status: true +dependencies: + config: + - field.storage.node.field_iiif_test_5 + - node.type.iiif_test + module: + - iiif_media_source + - iiif_media_source_test + enforced: + module: + - iiif_media_source_test +id: node.iiif_test.field_iiif_test_5 +field_name: field_iiif_test_5 +entity_type: node +bundle: iiif_test +label: 'IIIF Test 5' +description: '' +required: false +translatable: false +default_value: { } +default_value_callback: '' +settings: + server: 'https://media.nga.gov' + prefix: iiif + img_api_version: '2' +field_type: iiif_id diff --git a/tests/modules/iiif_media_source_test/config/install/field.storage.node.field_iiif_test_1.yml b/tests/modules/iiif_media_source_test/config/install/field.storage.node.field_iiif_test_1.yml new file mode 100644 index 0000000..8dcab16 --- /dev/null +++ b/tests/modules/iiif_media_source_test/config/install/field.storage.node.field_iiif_test_1.yml @@ -0,0 +1,25 @@ +langcode: en +status: true +dependencies: + module: + - iiif_media_source + - iiif_media_source_test + - node + enforced: + module: + - iiif_media_source_test +id: node.field_iiif_test_1 +field_name: field_iiif_test_1 +entity_type: node +type: iiif_id +settings: + max_length: 255 + is_ascii: false + case_sensitive: false +module: iiif_media_source +locked: false +cardinality: 1 +translatable: true +indexes: { } +persist_with_no_fields: false +custom_storage: false diff --git a/tests/modules/iiif_media_source_test/config/install/field.storage.node.field_iiif_test_2.yml b/tests/modules/iiif_media_source_test/config/install/field.storage.node.field_iiif_test_2.yml new file mode 100644 index 0000000..b02b13b --- /dev/null +++ b/tests/modules/iiif_media_source_test/config/install/field.storage.node.field_iiif_test_2.yml @@ -0,0 +1,25 @@ +langcode: en +status: true +dependencies: + module: + - iiif_media_source + - iiif_media_source_test + - node + enforced: + module: + - iiif_media_source_test +id: node.field_iiif_test_2 +field_name: field_iiif_test_2 +entity_type: node +type: iiif_id +settings: + max_length: 255 + is_ascii: false + case_sensitive: false +module: iiif_media_source +locked: false +cardinality: 1 +translatable: true +indexes: { } +persist_with_no_fields: false +custom_storage: false diff --git a/tests/modules/iiif_media_source_test/config/install/field.storage.node.field_iiif_test_3.yml b/tests/modules/iiif_media_source_test/config/install/field.storage.node.field_iiif_test_3.yml new file mode 100644 index 0000000..21d5757 --- /dev/null +++ b/tests/modules/iiif_media_source_test/config/install/field.storage.node.field_iiif_test_3.yml @@ -0,0 +1,25 @@ +langcode: en +status: true +dependencies: + module: + - iiif_media_source + - iiif_media_source_test + - node + enforced: + module: + - iiif_media_source_test +id: node.field_iiif_test_3 +field_name: field_iiif_test_3 +entity_type: node +type: iiif_id +settings: + max_length: 255 + is_ascii: false + case_sensitive: false +module: iiif_media_source +locked: false +cardinality: 1 +translatable: true +indexes: { } +persist_with_no_fields: false +custom_storage: false diff --git a/tests/modules/iiif_media_source_test/config/install/field.storage.node.field_iiif_test_4.yml b/tests/modules/iiif_media_source_test/config/install/field.storage.node.field_iiif_test_4.yml new file mode 100644 index 0000000..a69e20d --- /dev/null +++ b/tests/modules/iiif_media_source_test/config/install/field.storage.node.field_iiif_test_4.yml @@ -0,0 +1,25 @@ +langcode: en +status: true +dependencies: + module: + - iiif_media_source + - iiif_media_source_test + - node + enforced: + module: + - iiif_media_source_test +id: node.field_iiif_test_4 +field_name: field_iiif_test_4 +entity_type: node +type: iiif_id +settings: + max_length: 255 + is_ascii: false + case_sensitive: false +module: iiif_media_source +locked: false +cardinality: 1 +translatable: true +indexes: { } +persist_with_no_fields: false +custom_storage: false diff --git a/tests/modules/iiif_media_source_test/config/install/field.storage.node.field_iiif_test_5.yml b/tests/modules/iiif_media_source_test/config/install/field.storage.node.field_iiif_test_5.yml new file mode 100644 index 0000000..60b203e --- /dev/null +++ b/tests/modules/iiif_media_source_test/config/install/field.storage.node.field_iiif_test_5.yml @@ -0,0 +1,25 @@ +langcode: en +status: true +dependencies: + module: + - iiif_media_source + - iiif_media_source_test + - node + enforced: + module: + - iiif_media_source_test +id: node.field_iiif_test_5 +field_name: field_iiif_test_5 +entity_type: node +type: iiif_id +settings: + max_length: 255 + is_ascii: false + case_sensitive: false +module: iiif_media_source +locked: false +cardinality: 1 +translatable: true +indexes: { } +persist_with_no_fields: false +custom_storage: false diff --git a/tests/modules/iiif_media_source_test/config/install/node.type.iiif_test.yml b/tests/modules/iiif_media_source_test/config/install/node.type.iiif_test.yml new file mode 100644 index 0000000..b9139ac --- /dev/null +++ b/tests/modules/iiif_media_source_test/config/install/node.type.iiif_test.yml @@ -0,0 +1,14 @@ +langcode: en +status: true +dependencies: + module: + enforced: + module: + - iiif_media_source_test +name: IIIF Test +type: iiif_test +description: '' +help: '' +new_revision: true +preview_mode: 0 +display_submitted: true diff --git a/tests/modules/iiif_media_source_test/iiif_media_source_test.info.yml b/tests/modules/iiif_media_source_test/iiif_media_source_test.info.yml new file mode 100644 index 0000000..60f6cb0 --- /dev/null +++ b/tests/modules/iiif_media_source_test/iiif_media_source_test.info.yml @@ -0,0 +1,10 @@ +name: IIIF Media Source TEST +type: module +description: 'Required config for testing IIIF Fields' +core_version_requirement: ^10 +package: Testing +dependencies: + - drupal:node + - drupal:path + - drupal:user + - iiif_media_source:iiif_media_source diff --git a/tests/src/Functional/FieldFormatterTest.php b/tests/src/Functional/FieldFormatterTest.php new file mode 100644 index 0000000..680d47e --- /dev/null +++ b/tests/src/Functional/FieldFormatterTest.php @@ -0,0 +1,155 @@ +adminUser = $this->drupalCreateUser([ + 'access administration pages', + 'access content', + ], "Bob", TRUE); + $this->authenticatedUser = $this->drupalCreateUser([ + 'access content', + 'bypass node access', + ]); + + // echo $this->adminUser->id(); + // echo "\r\n"; + // echo $this->authenticatedUser->id(); + // echo "\r\n"; + + $this->testNode = $this->drupalCreateNode([ + 'type' => 'iiif_test', + 'status' => 1, + 'title' => "Test Node", + 'field_iiif_test_1' => '6dc9ca49-ea8c-4314-985a-ba2cfc3965cd', + 'field_iiif_test_2' => '3a81bf90-a961-468d-ae12-1d981e11247a', + 'field_iiif_test_3' => '7a4bba6e-7c21-42fe-bdd5-7ba7bdeffd16', + 'field_iiif_test_4' => 'fdfa01c4-7334-4a34-a1fa-64429773e96e', + 'field_iiif_test_5' => 'ab18bc0e-2b0e-48db-bf7a-d57f24f9c6a3', + ]); + + // echo "setUp3\r\n"; + // echo $this->testNode->id(); + } + + /** + * Test loading attribute for IIIF Image Formatter. + */ + public function testLoadingAttribute() { + + // Goto the Test Node detail page. + $session = $this->assertSession(); + $this->assertTrue(TRUE); + + $this->drupalLogin($this->adminUser); + + $this->drupalGet('admin/structure/types'); + $session->statusCodeEquals(200); + + // Form Dispaly Settings. + $this->drupalGet('admin/structure/types/manage/iiif_test/form-display'); + $session->statusCodeEquals(200); + + $this->drupalGet('node/' . $this->testNode->id() . "/edit"); + $session->statusCodeEquals(200); + + $this->drupalGet('node/' . $this->testNode->id()); + $session->statusCodeEquals(200); + $session->responseContains('
6dc9ca49-ea8c-4314-985a-ba2cfc3965cd
'); + $session->responseContains('https://media.nga.gov/iiif/3a81bf90-a961-468d-ae12-1d981e11247a/full/full/0/default.png'); + $session->responseContains('responseContains('https://media.nga.gov/iiif/fdfa01c4-7334-4a34-a1fa-64429773e96e/full/max/0/default.png', "img url"); + $session->responseContains('responseContains('https://media.nga.gov/iiif/3a81bf90-a961-468d-ae12-1d981e11247a/full/full/0/default.png'); + + // View Display Settings. + $this->drupalGet('admin/structure/types/manage/iiif_test/display'); + $session->statusCodeEquals(200); + + // Click Gear, to change field display settings. + $this->click('input[name="field_iiif_test_4_settings_edit"]'); + + $form_html_id = "entity-view-display-edit-form"; + $form = $form = $session->elementExists('xpath', "//form[@id='{$form_html_id}']"); + $field_name = "fields[field_iiif_test_4][settings_edit_form][settings][format]"; + $field = $session->fieldExists($field_name, $form); + $field->setValue("jpg"); + + $this->click('input[name="field_iiif_test_4_plugin_settings_update"]'); + $this->click('input[name="op"][value="Save"]'); + + + + $this->drupalGet('node/' . $this->testNode->id()); + $session->statusCodeEquals(200); + + $session->responseContains('