X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs-website;a=blobdiff_plain;f=web%2Fmodules%2Fcontrib%2Ffilefield_sources%2Fsrc%2FTests%2FEmptyValuesTest.php;fp=web%2Fmodules%2Fcontrib%2Ffilefield_sources%2Fsrc%2FTests%2FEmptyValuesTest.php;h=065ff57095c777adf256804bf1c0b329eca22258;hp=0000000000000000000000000000000000000000;hb=8acec36f19c470dfcda1ae2336826a782f41874c;hpb=e0411c4e83ba0d079034db83c3f7f55be24a0e35 diff --git a/web/modules/contrib/filefield_sources/src/Tests/EmptyValuesTest.php b/web/modules/contrib/filefield_sources/src/Tests/EmptyValuesTest.php new file mode 100644 index 000000000..065ff5709 --- /dev/null +++ b/web/modules/contrib/filefield_sources/src/Tests/EmptyValuesTest.php @@ -0,0 +1,90 @@ +setUpImce(); + } + + /** + * Tests all sources enabled. + */ + public function testAllSourcesEnabled() { + // Change allowed number of values. + $this->drupalPostForm('admin/structure/types/manage/' . $this->typeName . '/fields/node.' . $this->typeName . '.' . $this->fieldName . '/storage', array('cardinality' => FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED), t('Save field settings')); + + $this->enableSources(array( + 'upload' => TRUE, + 'remote' => TRUE, + 'clipboard' => TRUE, + 'reference' => TRUE, + 'attach' => TRUE, + 'imce' => TRUE, + )); + + // Upload a file by 'Remote' source. + $this->uploadFileByRemoteSource(); + + // Upload a file by 'Reference' source. + $this->uploadFileByReferenceSource(); + + // Upload a file by 'Clipboard' source. + $this->uploadFileByClipboardSource(); + + // Upload a file by 'Attach' source. + $this->uploadFileByAttachSource(); + + // Upload a file by 'Upload' source. + $this->uploadFileByUploadSource('', '', 0, TRUE); + + // Upload a file by 'Imce' source. + $this->uploadFileByImceSource(); + + $this->assertUniqueSubmitButtons(); + } + + /** + * Check that there is only one submit button of a source. + */ + protected function assertUniqueSubmitButtons() { + $buttons = array( + $this->fieldName . '_0_attach' => t('Attach'), + $this->fieldName . '_0_clipboard_upload_button' => t('Upload'), + $this->fieldName . '_0_autocomplete_select' => t('Select'), + $this->fieldName . '_0_transfer' => t('Transfer'), + $this->fieldName . '_0_upload_button' => t('Upload'), + $this->fieldName . '_0_imce_select' => t('Select'), + ); + foreach ($buttons as $button_name => $button_label) { + // Ensure that there is only one button with name. + $buttons = $this->xpath('//input[@name="' . $button_name . '" and @value="' . $button_label . '"]'); + $this->assertEqual(count($buttons), 1, format_string('There is only one button with name %name and label %label', array('%name' => $button_name, '%label' => $button_label))); + } + } + +}