smb/tests/server.php
2013-11-26 16:58:23 +01:00

56 lines
1.3 KiB
PHP

<?php
namespace SMB\Test;
class Server extends \PHPUnit_Framework_TestCase {
/**
* @var \SMB\Server $server
*/
private $server;
private $config;
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);
}
public function testListShares() {
$shares = $this->server->listShares();
foreach ($shares as $share) {
if ($share->getName() === $this->config->share) {
return;
}
}
$this->fail('Share "' . $this->config->share . '" not found');
}
/**
* @expectedException \SMB\AuthenticationException
*/
public function testWrongUserName() {
$server = new \SMB\Server($this->config->host, uniqid(), $this->config->password);
$server->listShares();
}
/**
* @expectedException \SMB\AuthenticationException
*/
public function testWrongPassword() {
$server = new \SMB\Server($this->config->host, $this->config->user, uniqid());
$server->listShares();
}
/**
* @expectedException \SMB\InvalidHostException
*/
public function testWrongHost() {
$server = new \SMB\Server(uniqid(), $this->config->user, $this->config->password);
$server->listShares();
}
public function testGetTimeZone() {
$timeZone = $this->server->getTimeZone();
$this->assertEquals('+0100', $timeZone);
}
}