1
|
|
|
<?php |
2
|
|
|
/* vim: set expandtab sw=4 ts=4 sts=4: */ |
3
|
|
|
|
4
|
|
|
/** |
5
|
|
|
* Tests for Sync Github Issue States Shell. |
6
|
|
|
* |
7
|
|
|
* phpMyAdmin Error reporting server |
8
|
|
|
* Copyright (c) phpMyAdmin project (https://www.phpmyadmin.net/) |
9
|
|
|
* |
10
|
|
|
* Licensed under The MIT License |
11
|
|
|
* For full copyright and license information, please see the LICENSE.txt |
12
|
|
|
* Redistributions of files must retain the above copyright notice. |
13
|
|
|
* |
14
|
|
|
* @copyright Copyright (c) phpMyAdmin project (https://www.phpmyadmin.net/) |
15
|
|
|
* @license https://opensource.org/licenses/mit-license.php MIT License |
16
|
|
|
* |
17
|
|
|
* @see https://www.phpmyadmin.net/ |
18
|
|
|
*/ |
19
|
|
|
|
20
|
|
|
namespace App\Test\TestCase\Shell; |
21
|
|
|
|
22
|
|
|
use App\Shell\SyncGithubIssueStatesShell; |
23
|
|
|
use Cake\TestSuite\TestCase; |
24
|
|
|
use Cake\ORM\TableRegistry; |
25
|
|
|
|
26
|
|
|
/** |
27
|
|
|
* App\Shell\SyncGithubIssueStatesShell Test Case |
28
|
|
|
*/ |
29
|
|
|
class SyncGithubIssueStatesShellTest extends TestCase |
30
|
|
|
{ |
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* ConsoleIo mock |
34
|
|
|
* |
35
|
|
|
* @var \Cake\Console\ConsoleIo|\PHPUnit_Framework_MockObject_MockObject |
36
|
|
|
*/ |
37
|
|
|
public $io; |
38
|
|
|
|
39
|
|
|
/** |
40
|
|
|
* Test subject |
41
|
|
|
* |
42
|
|
|
* @var \App\Shell\SyncGithubIssueStatesShell |
43
|
|
|
*/ |
44
|
|
|
public $SyncGithubIssueStates; |
45
|
|
|
|
46
|
|
|
public $fixtures = array( |
47
|
|
|
'app.reports' |
48
|
|
|
); |
49
|
|
|
|
50
|
|
|
/** |
51
|
|
|
* setUp method |
52
|
|
|
* |
53
|
|
|
* @return void |
54
|
|
|
*/ |
55
|
|
|
public function setUp() |
56
|
|
|
{ |
57
|
|
|
parent::setUp(); |
58
|
|
|
$this->io = $this->getMockBuilder('Cake\Console\ConsoleIo')->getMock(); |
59
|
|
|
$this->SyncGithubIssueStates = new SyncGithubIssueStatesShell($this->io); |
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
/** |
63
|
|
|
* tearDown method |
64
|
|
|
* |
65
|
|
|
* @return void |
66
|
|
|
*/ |
67
|
|
|
public function tearDown() |
68
|
|
|
{ |
69
|
|
|
unset($this->SyncGithubIssueStates); |
70
|
|
|
|
71
|
|
|
parent::tearDown(); |
72
|
|
|
} |
73
|
|
|
|
74
|
|
|
/** |
75
|
|
|
* Test main method |
76
|
|
|
* |
77
|
|
|
* @return void |
78
|
|
|
*/ |
79
|
|
|
public function testMain() |
80
|
|
|
{ |
81
|
|
|
// Call intialize method to load the models |
82
|
|
|
$this->SyncGithubIssueStates->initialize(); |
83
|
|
|
|
84
|
|
|
$conditions = array( |
85
|
|
|
'status' => 'resolved' |
86
|
|
|
); |
87
|
|
|
$reportsTable = TableRegistry::get('Reports'); |
88
|
|
|
$currentCount = $reportsTable->find('all')->where($conditions)->count(); |
89
|
|
|
$this->assertEquals(0, $currentCount); |
90
|
|
|
|
91
|
|
|
// Run the shell command |
92
|
|
|
$this->SyncGithubIssueStates->main(); |
93
|
|
|
|
94
|
|
|
$newCount = $reportsTable->find('all')->where($conditions)->count(); |
95
|
|
|
$this->assertEquals(1, $newCount); |
96
|
|
|
} |
97
|
|
|
} |
98
|
|
|
|