function ResourceStreamTestCase::setUp in D7 Media 6
Generates a random database prefix, runs the install scripts on the prefixed database and enable the specified modules. After installation many caches are flushed and the internal browser is setup so that the page requests will run on the new prefix. A temporary files directory is created with the same name as the database prefix.
Parameters
...: List of modules to enable for the duration of the test. This can be either a single array or a variable number of string arguments.
Overrides DrupalWebTestCase::setUp
File
- resource/
tests/ ResourceStream.test, line 33 - This provides SimpleTests for the core stream wrapper functionality.
Class
- ResourceStreamTestCase
- Base class for file tests that adds some additional file specific assertions and helper functions.
Code
function setUp() {
// create a known file and directory for testing.
resource_debug($this->scheme);
$this->realpath = realpath(variable_get($this->pathkey, $this->pathdefault));
$this->dirname = 'ResourceStreamTestCaseDir' . uniqid();
$this->filename = 'ResourceStreamTestCaseFile' . uniqid() . '.txt';
$this->path = '/' . $this->dirname . '/' . $this->filename;
$this->url = $this->scheme . $this->path;
resource_debug("realpath: {$this->realpath}");
$data = '1234567890abcdef';
mkdir($this->realpath . '/' . $this->dirname);
file_put_contents($this->realpath . $this->path, $data, LOCK_EX);
$this
->assertTrue(file_exists($this->realpath . $this->path), 'Source file created.');
}