Further modules included.
[yaffs-website] / web / modules / contrib / filefield_sources / src / Tests / UploadSourceTest.php
1 <?php
2
3 /**
4  * @file
5  * Definition of Drupal\filefield_sources\Tests\UploadSourceTest.
6  */
7
8 namespace Drupal\filefield_sources\Tests;
9
10 /**
11  * Tests the upload source.
12  *
13  * @group filefield_sources
14  */
15 class UploadSourceTest extends FileFieldSourcesTestBase {
16
17   /**
18    * Tests upload source enabled.
19    */
20   public function testUploadSourceEnabled() {
21     $this->enableSources(array(
22       'upload' => TRUE,
23     ));
24
25     $this->assertUploadSourceWorkProperly();
26   }
27
28   /**
29    * Tests all sources enabled.
30    */
31   public function testAllSourcesEnabled() {
32     $this->enableSources(array(
33       'upload' => TRUE,
34       'remote' => TRUE,
35       'clipboard' => TRUE,
36       'reference' => TRUE,
37       'attach' => TRUE,
38     ));
39
40     $this->assertUploadSourceWorkProperly();
41   }
42
43   /**
44    * Tests upload source still working properly.
45    */
46   protected function assertUploadSourceWorkProperly() {
47     $file = $this->createTemporaryFileEntity();
48
49     // Upload a file by 'Upload' source.
50     $this->uploadFileByUploadSource($file->getFileUri(), $file->getFilename(), 0, FALSE);
51
52     // We can only upload one file on single value field.
53     $this->assertNoFieldByXPath('//input[@type="submit"]', t('Upload'), t('After uploading a file, "Upload" button is no longer displayed.'));
54
55     // Remove uploaded file.
56     $this->removeFile($file->getFilename(), 0);
57
58     // Can upload file again.
59     $this->assertFieldByXpath('//input[@type="submit"]', t('Upload'), 'After clicking the "Remove" button, the "Upload" button is displayed.');
60   }
61
62 }