-
Notifications
You must be signed in to change notification settings - Fork 190
/
MachineTokensListCommandTest.php
71 lines (62 loc) · 2.07 KB
/
MachineTokensListCommandTest.php
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
<?php
namespace Pantheon\Terminus\UnitTests\Commands\Auth;
use Pantheon\Terminus\Commands\MachineToken\ListCommand;
use Pantheon\Terminus\Config;
use Terminus\Collections\MachineTokens;
use Terminus\Models\MachineToken;
/**
* Testing class for Pantheon\Terminus\Commands\Auth\LoginCommand
*/
class MachineTokensListCommandTest extends MachineTokenCommandTest
{
/**
* Sets up the fixture, for example, open a network connection.
* This method is called before a test is executed.
*/
protected function setUp()
{
parent::setUp();
$this->command = new ListCommand(new Config());
$this->command->setSession($this->session);
$this->command->setLogger($this->logger);
}
/**
* Tests the machine-token:list command when there are no tokens.
*
* @return void
*/
public function testMachineTokenListEmpty()
{
$this->machine_tokens->method('all')
->willReturn([]);
$this->logger->expects($this->once())
->method('log')
->with($this->equalTo('warning'), $this->equalTo('You have no machine tokens.'));
$out = $this->command->listTokens();
$this->assertInstanceOf('Consolidation\OutputFormatters\StructuredData\RowsOfFields', $out);
$this->assertEquals([], $out->getArrayCopy());
}
/**
* Tests the machine-token:list command when there are tokens.
*
* @return void
*/
public function testMachineTokenListNotEmpty()
{
$tokens = [
['id' => '1', 'device_name' => 'Foo'],
['id' => '2', 'device_name' => 'Bar']
];
$collection = new MachineTokens(['user' => $this->user]);
$this->machine_tokens->method('all')
->willReturn([
new MachineToken((object)$tokens[0], ['collection' => $collection]),
new MachineToken((object)$tokens[1], ['collection' => $collection])
]);
$this->logger->expects($this->never())
->method($this->anything());
$out = $this->command->listTokens();
$this->assertInstanceOf('Consolidation\OutputFormatters\StructuredData\RowsOfFields', $out);
$this->assertEquals($tokens, $out->getArrayCopy());
}
}