Created
January 5, 2011 20:36
-
-
Save ygerasimov/766964 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// $Id$ | |
/** | |
* @file | |
* Call the endpoint tests when no authentication is being used. | |
* | |
*/ | |
require_once('ServicesWebTestCase.php') ; | |
/** | |
* Run test cases for the endpoint with no authentication turned on. | |
* | |
*/ | |
class ServicesResourceFileTests extends ServicesWebtestCase { | |
// Class variables | |
protected $privileged_user = NULL ; | |
// Endpoint details. | |
protected $endpoint = NULL; | |
/** | |
* Implementation of setUp(). | |
*/ | |
public function setUp() { | |
parent::setUp( | |
'autoload', | |
'ctools', | |
'services', | |
'rest_server', | |
'services_sessauth', | |
'inputstream', | |
'upload' | |
); | |
// Set up endpoint. | |
$this->endpoint = $this->saveNewEndpoint(); | |
// Set up privileged user and login. | |
$this->privileged_user = $this->drupalCreateUser(array('administer files', 'get any binary files')); | |
$this->drupalLogin($this->privileged_user); | |
} | |
/** | |
* Implementation of getInfo(). | |
*/ | |
public static function getInfo() { | |
return array( | |
'name' => t('Resource File tests, no auth'), | |
'description' => t('Test the resource File methods and actions.'), | |
'group' => t('Services'), | |
); | |
} | |
// File resource. | |
// Upload file. Upload file withthout file data. | |
function testFileCreate() { | |
$text_file = current($this->drupalGetTestFiles('text')); | |
$file = new stdClass(); | |
$realpath = realpath($text_file->filename); | |
$file->filesize = filesize($realpath); | |
$file->filepath = 'sites/default/files/' . $text_file->basename; | |
$fh = fopen($realpath, 'r'); | |
$file_data = fread($fh, $file->filesize); | |
fclose($fh); | |
$file->file = base64_encode($file_data); | |
$response = $this->servicesPost($this->endpoint->path . '/file', array('file' => $file)); | |
} | |
// Update file. | |
// Retrieve | |
// Delete | |
// nodeFiles | |
// | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment