5 * Definition of Drupal\filefield_sources\Tests\EmptyValuesTest.
8 namespace Drupal\filefield_sources\Tests;
10 use Drupal\Core\Field\FieldStorageDefinitionInterface;
15 * @group filefield_sources
17 class EmptyValuesTest extends FileFieldSourcesTestBase {
24 public static $modules = array('imce');
27 * Sets up for empty values test case.
29 protected function setUp() {
35 * Tests all sources enabled.
37 public function testAllSourcesEnabled() {
38 // Change allowed number of values.
39 $this->drupalPostForm('admin/structure/types/manage/' . $this->typeName . '/fields/node.' . $this->typeName . '.' . $this->fieldName . '/storage', array('cardinality' => FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED), t('Save field settings'));
41 $this->enableSources(array(
50 // Upload a file by 'Remote' source.
51 $this->uploadFileByRemoteSource();
53 // Upload a file by 'Reference' source.
54 $this->uploadFileByReferenceSource();
56 // Upload a file by 'Clipboard' source.
57 $this->uploadFileByClipboardSource();
59 // Upload a file by 'Attach' source.
60 $this->uploadFileByAttachSource();
62 // Upload a file by 'Upload' source.
63 $this->uploadFileByUploadSource('', '', 0, TRUE);
65 // Upload a file by 'Imce' source.
66 $this->uploadFileByImceSource();
68 $this->assertUniqueSubmitButtons();
72 * Check that there is only one submit button of a source.
74 protected function assertUniqueSubmitButtons() {
76 $this->fieldName . '_0_attach' => t('Attach'),
77 $this->fieldName . '_0_clipboard_upload_button' => t('Upload'),
78 $this->fieldName . '_0_autocomplete_select' => t('Select'),
79 $this->fieldName . '_0_transfer' => t('Transfer'),
80 $this->fieldName . '_0_upload_button' => t('Upload'),
81 $this->fieldName . '_0_imce_select' => t('Select'),
83 foreach ($buttons as $button_name => $button_label) {
84 // Ensure that there is only one button with name.
85 $buttons = $this->xpath('//input[@name="' . $button_name . '" and @value="' . $button_label . '"]');
86 $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)));