public function ServicesResourceNodetests::testNodeRelationshipFiles in Services 6.3
Test files relationship.
File
- tests/
functional/ ServicesResourceNodeTests.test, line 343
Class
- ServicesResourceNodetests
- Run test cases for the endpoint with no authentication turned on.
Code
public function testNodeRelationshipFiles() {
$this->privileged_user = $this
->drupalCreateUser(array(
'get own binary files',
'save file information',
'administer services',
'administer site configuration',
'upload files',
));
$this
->drupalLogin($this->privileged_user);
$testfiles = $this
->drupalGetTestFiles('text');
$testfile1 = $this
->uploadTestFile($testfiles);
$testfile2 = $this
->uploadTestFile($testfiles);
$testfile3 = $this
->uploadTestFile($testfiles);
// Needed for upload module to create new records in {upload} table.
// @see upload_save()
$testfile1['new'] = TRUE;
$testfile2['new'] = TRUE;
$testfile3['new'] = TRUE;
// First two files are listed. Third is not listed.
$testfile1['list'] = 1;
$testfile2['list'] = 1;
$testfile3['list'] = 0;
// Create node with three files.
$settings = array(
'files' => array(
$testfile1['fid'] => (object) $testfile1,
$testfile2['fid'] => (object) $testfile2,
$testfile3['fid'] => (object) $testfile3,
),
);
$node = $this
->drupalCreateNode($settings);
$result = $this
->servicesGet($this->endpoint->path . '/node/' . $node->nid . '/files');
$this
->assertTrue(isset($result['body'][$testfile1['fid']]) && isset($result['body'][$testfile2['fid']]) && !isset($result['body'][$testfile3['fid']]), t('Attached files listed.'), 'FileResource: nodeFiles');
}