Make test configurable

This commit is contained in:
Robin Appelman 2013-03-14 17:49:40 +01:00
commit fc12434d28
2 changed files with 16 additions and 5 deletions

6
tests/config.json Normal file
View file

@ -0,0 +1,6 @@
{
"host": "localhost",
"user": "test",
"password": "test",
"share": "test"
}

View file

@ -16,25 +16,30 @@ class Test extends PHPUnit_Framework_TestCase {
*/
private $root;
private $config;
public function setUp() {
$this->server = new SMB\Server('localhost', 'test', 'test');
$this->share = $this->server->getShare('test');
$this->config = json_decode(file_get_contents(__DIR__ . '/config.json'));
$this->server = new SMB\Server($this->config->host, $this->config->user, $this->config->password);
$this->share = $this->server->getShare($this->config->share);
$this->root = '/' . uniqid();
$this->share->mkdir($this->root);
}
public function tearDown() {
if ($this->share) {
$this->share->rmdir($this->root);
}
}
public function testListShares() {
$shares = $this->server->listShares();
foreach ($shares as $share) {
if ($share->getName() === 'test') {
if ($share->getName() === $this->config->share) {
return;
}
}
$this->fail('Share "test" not found');
$this->fail('Share "' . $this->config->share . '" not found');
}
public function testDirectory() {