forked from laravel/framework
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRemoteSecLibTest.php
More file actions
56 lines (42 loc) · 1.8 KB
/
RemoteSecLibTest.php
File metadata and controls
56 lines (42 loc) · 1.8 KB
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
<?php
use Mockery as m;
class RemoteSecLibGatewayTest extends PHPUnit_Framework_TestCase {
public function tearDown()
{
m::close();
}
public function testHostAndPortSetCorrectly()
{
$gateway = $this->getGateway();
$this->assertEquals('127.0.0.1', $gateway->getHost());
$this->assertEquals(22, $gateway->getPort());
}
public function testConnectProperlyCallsLoginWithAuth()
{
$gateway = $this->getGateway();
$gateway->shouldReceive('getNewKey')->andReturn($key = m::mock('StdClass'));
$key->shouldReceive('setPassword')->once()->with('keyphrase');
$key->shouldReceive('loadKey')->once()->with('keystuff');
$gateway->getConnection()->shouldReceive('login')->with('taylor', $key);
$gateway->connect('taylor');
}
public function testKeyTextCanBeSetManually()
{
$files = m::mock('Illuminate\Filesystem\Filesystem');
$gateway = m::mock('Illuminate\Remote\SecLibGateway', array('127.0.0.1:22', array('username' => 'taylor', 'keytext' => 'keystuff'), $files))->makePartial();
$gateway->shouldReceive('getConnection')->andReturn(m::mock('StdClass'));
$gateway->shouldReceive('getNewKey')->andReturn($key = m::mock('StdClass'));
$key->shouldReceive('setPassword')->once()->with(null);
$key->shouldReceive('loadKey')->once()->with('keystuff');
$gateway->getConnection()->shouldReceive('login')->with('taylor', $key);
$gateway->connect('taylor');
}
public function getGateway()
{
$files = m::mock('Illuminate\Filesystem\Filesystem');
$files->shouldReceive('get')->with('keypath')->andReturn('keystuff');
$gateway = m::mock('Illuminate\Remote\SecLibGateway', array('127.0.0.1:22', array('username' => 'taylor', 'key' => 'keypath', 'keyphrase' => 'keyphrase'), $files))->makePartial();
$gateway->shouldReceive('getConnection')->andReturn(m::mock('StdClass'));
return $gateway;
}
}