Move some code arround

This commit is contained in:
Robin Appelman 2013-05-01 00:03:10 +02:00
commit 78916cfc08
15 changed files with 161 additions and 382 deletions

View file

@ -18,18 +18,20 @@ class Test extends PHPUnit_Framework_TestCase {
private $config;
private $needsCleanup = false;
public function setUp() {
$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) {
if ($this->share and $this->needsCleanup) {
$this->share->rmdir($this->root);
}
unset($this->share);
}
public function testListShares() {
@ -43,6 +45,8 @@ class Test extends PHPUnit_Framework_TestCase {
}
public function testDirectory() {
$this->share->mkdir($this->root);
$this->needsCleanup = true;
$this->assertEquals(array(), $this->share->dir($this->root));
$this->share->mkdir($this->root . '/foo');
@ -61,6 +65,8 @@ class Test extends PHPUnit_Framework_TestCase {
}
public function testFile() {
$this->share->mkdir($this->root);
$this->needsCleanup = true;
$text = 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua';
$size = strlen($text);
$tmpFile1 = tempnam('/tmp', 'smb_test_');
@ -91,6 +97,8 @@ class Test extends PHPUnit_Framework_TestCase {
}
public function testEscaping() {
$this->share->mkdir($this->root);
$this->needsCleanup = true;
// / ? < > \ : * | ” are illegal characters in path on windows, no use trying to get them working
$names = array('simple', 'with spaces', "single'quote'", '$as#d', '€', '££Ö€ßœĚęĘĞĜΣΥΦΩΫΫ');