public function ProtectedNodePrivateFile::setUp in Protected Node 1.0.x
Same name and namespace in other branches
- 7 tests/protected_node.private_file.test \ProtectedNodePrivateFile::setUp()
Prepare users for protected node's tests.
Overrides ProtectedNodeBaseTestCase::setUp
File
- tests/
protected_node.private_file.test, line 27 - Test protected node behavior with private files.
Class
- ProtectedNodePrivateFile
- Configure protected_node to use per node password and use private file field.
Code
public function setUp() {
parent::setUp('image');
// Log in an Admin.
$this
->drupalLogin($this->adminUser);
// Submit the configuration form.
$protected_node_settings = array(
'protected_node_use_global_password' => PROTECTED_NODE_PER_NODE_PASSWORD,
);
$this
->drupalPost('admin/config/content/protected_node', $protected_node_settings, t('Save configuration'));
// Private file system already set by simpletest.
// Set private file field for basic page.
$filefieldtestcase = new FileFieldTestCase();
$filefieldtestcase
->createFileField('private_file', 'page', array(
'uri_scheme' => 'private',
));
// Set private image field for basic page.
$this
->createImageField('private_image', 'page', array(
'uri_scheme' => 'private',
));
// Get files to upload.
$this->text_file = current($this
->drupalGetTestFiles('text'));
$this->image_file = current($this
->drupalGetTestFiles('image'));
// Add a new page node with the files so we can have the file ids.
$node_title = $this
->randomName(8);
$node_data = array(
'title' => $node_title,
'files[private_file_und_0]' => drupal_realpath($this->text_file->uri),
'files[private_image_und_0]' => drupal_realpath($this->image_file->uri),
);
$this
->drupalPost('node/add/page', $node_data, t('Save'));
$file_node = $this
->drupalGetNodeByTitle($node_title);
$this->text_file = (object) $file_node->private_file[LANGUAGE_NONE][0];
$this->image_file = (object) $file_node->private_image[LANGUAGE_NONE][0];
}