Completed
Pull Request — master (#168)
by Deven
02:30
created

SyncGithubIssueStatesShellTest::testMain()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 18
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 18
rs 9.4285
cc 1
eloc 10
nc 1
nop 0
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