summaryrefslogtreecommitdiffstats
path: root/apps/files_external/3rdparty/icewind/smb/tests/Server.php
blob: 9f62886654f45239df7c1e5635c75ac7609e2309 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
<?php
/**
 * Copyright (c) 2014 Robin Appelman <icewind@owncloud.com>
 * This file is licensed under the Licensed under the MIT license:
 * http://opensource.org/licenses/MIT
 */

namespace Icewind\SMB\Test;

class Server extends \PHPUnit_Framework_TestCase {
	/**
	 * @var \Icewind\SMB\Server $server
	 */
	private $server;

	private $config;

	public function setUp() {
		$this->config = json_decode(file_get_contents(__DIR__ . '/config.json'));
		$this->server = new \Icewind\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 \Icewind\SMB\Exception\AuthenticationException
	 */
	public function testWrongUserName() {
		$this->markTestSkipped('This fails for no reason on travis');
		$server = new \Icewind\SMB\Server($this->config->host, uniqid(), uniqid());
		$server->listShares();
	}

	/**
	 * @expectedException \Icewind\SMB\Exception\AuthenticationException
	 */
	public function testWrongPassword() {
		$server = new \Icewind\SMB\Server($this->config->host, $this->config->user, uniqid());
		$server->listShares();
	}

	/**
	 * @expectedException \Icewind\SMB\Exception\InvalidHostException
	 */
	public function testWrongHost() {
		$server = new \Icewind\SMB\Server(uniqid(), $this->config->user, $this->config->password);
		$server->listShares();
	}
}