public function UuidFileServicesTest::testFileUpdate in Universally Unique IDentifier 7
Tests file creation.
File
- uuid_services/
uuid_services.file_services.test, line 117 - Test the UUID File Services integration.
Class
- UuidFileServicesTest
- Test the UUID File Services integration.
Code
public function testFileUpdate() {
$this->privilegedUser = $this
->drupalCreateUser(array(
'create files',
));
$this
->drupalLogin($this->privilegedUser);
// Get a test file.
$testfiles = $this
->drupalGetTestFiles('php');
$testfile = current($testfiles);
// Setup file to be created.
$filepath = file_default_scheme() . '://' . rand() . '/' . rand() . '/' . $testfile->filename;
$file_data = array(
'uid' => '0',
'filesize' => filesize($testfile->uri),
'filename' => $testfile->filename,
'filepath' => $filepath,
'file' => base64_encode(file_get_contents($testfile->uri)),
'uuid' => 'ee26fe5d-f781-4a38-bfe0-8bb350b90073',
'type' => 'image',
'filemime' => 'text/plain',
'uri' => $testfile->uri,
);
$response = $this
->servicesPut($this->endpoint->path . '/file/create', $file_data);
// Get the saved file's extension.
$file = file_load($response['body']->fid);
$name = explode('.', $file->filename);
$last = array_pop($name);
$extension = strtolower($last);
$this
->assertNotEqual('php', $extension, 'File was not created with a "php" extension.', 'UUID: File Create');
}