Example #1
0
 protected function setUp()
 {
     parent::setUp();
     $account = $this->drupalCreateUser(array('access site reports'));
     $this->drupalLogin($account);
     $image_files = $this->drupalGetTestFiles('image');
     $this->image = entity_create('file', (array) current($image_files));
     list(, $this->imageExtension) = explode('.', $this->image->getFilename());
     $this->assertTrue(is_file($this->image->getFileUri()), "The image file we're going to upload exists.");
     $this->phpfile = current($this->drupalGetTestFiles('php'));
     $this->assertTrue(is_file($this->phpfile->uri), 'The PHP file we are going to upload exists.');
     $this->maxFidBefore = db_query('SELECT MAX(fid) AS fid FROM {file_managed}')->fetchField();
     // Upload with replace to guarantee there's something there.
     $edit = array('file_test_replace' => FILE_EXISTS_REPLACE, 'files[file_test_upload]' => drupal_realpath($this->image->getFileUri()));
     $this->drupalPostForm('file-test/upload', $edit, t('Submit'));
     $this->assertResponse(200, 'Received a 200 response for posted test file.');
     $this->assertRaw(t('You WIN!'), 'Found the success message.');
     // Check that the correct hooks were called then clean out the hook
     // counters.
     $this->assertFileHooksCalled(array('validate', 'insert'));
     file_test_reset();
 }
 protected function setUp()
 {
     parent::setUp();
     // Clear out any hook calls.
     file_test_reset();
 }