blob: a3d473b63663fe17b51d3b6f080427ae72969f3e (
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
|
<?php
/**
* Created by IntelliJ IDEA.
* User: bernhard
* Date: 11/26/15
* Time: 7:40 PM
*/
namespace OCA\News\Upgrade;
use OCP\IConfig;
use OCA\News\Service\ItemService;
class UpgradeTest extends \PHPUnit_Framework_TestCase {
/** @var Upgrade */
private $upgrade;
/** @var ItemService */
private $service;
/** @var IConfig */
private $config;
/** @var IDBConnection */
private $db;
public function setUp() {
$this->config = $this->getMockBuilder(
'\OCP\IConfig')
->disableOriginalConstructor()
->getMock();
$this->db = $this->getMockBuilder(
'\OCP\IDBConnection')
->disableOriginalConstructor()
->getMock();
$this->service = $this->getMockBuilder(
'\OCA\News\Service\ItemService')
->disableOriginalConstructor()
->getMock();
$this->upgrade = new Upgrade($this->config, $this->service,
$this->db, 'news');
}
public function testUpgrade() {
$this->config->expects($this->once())
->method('getAppValue')
->with($this->equalTo('news'), $this->equalTo('installed_version'))
->will($this->returnValue('8.9.0'));
$this->service->expects($this->once())
->method('generateSearchIndices');
$this->upgrade->upgrade();
}
public function testNoUpgrade() {
$this->config->expects($this->once())
->method('getAppValue')
->with($this->equalTo('news'), $this->equalTo('installed_version'))
->will($this->returnValue('8.9.1'));
$this->service->expects($this->never())
->method('generateSearchIndices');
$this->upgrade->upgrade();
}
}
|