You are here

public function ServicesResourceFileTests::testResourceFileRetrieve in Services 7.3

Same name and namespace in other branches
  1. 6.3 tests/functional/ServicesResourceFileTests.test \ServicesResourceFileTests::testResourceFileRetrieve()

Test retrieve method.

File

tests/functional/ServicesResourceFileTests.test, line 158
Test for file resource.

Class

ServicesResourceFileTests
Test class.

Code

public function testResourceFileRetrieve() {
  $testfile = $this->testfile;
  $testfile->fid = NULL;
  $testfile->uid = $this->privileged_user->uid;
  file_save($testfile);

  // Retrieve file.
  $result = $this
    ->servicesGet($this->endpoint->path . '/file/' . $testfile->fid);
  $file = $result['body'];

  // Assert that fid, filesize and uri are the same.
  $this
    ->assertTrue($file->fid == $testfile->fid && $file->filesize == $testfile->filesize && $file->uri == $testfile->uri, 'File retrieved.', 'FileResource: Retrieve');
}