|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace SCI\Tests\Specials; |
|
4
|
|
|
|
|
5
|
|
|
use SCI\Specials\SpecialFindCitableMetadata; |
|
6
|
|
|
|
|
7
|
|
|
/** |
|
8
|
|
|
* @covers \SCI\Specials\SpecialFindCitableMetadata |
|
9
|
|
|
* @group semantic-cite |
|
10
|
|
|
* |
|
11
|
|
|
* @license GNU GPL v2+ |
|
12
|
|
|
* @since 1.0 |
|
13
|
|
|
* |
|
14
|
|
|
* @author mwjames |
|
15
|
|
|
*/ |
|
16
|
|
|
class SpecialFindCitableMetadataTest extends \PHPUnit_Framework_TestCase { |
|
17
|
|
|
|
|
18
|
|
|
private $request; |
|
19
|
|
|
private $config; |
|
20
|
|
|
private $message; |
|
21
|
|
|
private $user; |
|
22
|
|
|
private $outputPage; |
|
23
|
|
|
private $context; |
|
24
|
|
|
|
|
25
|
|
|
protected function setUp() : void { |
|
26
|
|
|
|
|
27
|
|
|
$this->request = $this->getMockBuilder( '\WebRequest' ) |
|
28
|
|
|
->disableOriginalConstructor() |
|
29
|
|
|
->getMock(); |
|
30
|
|
|
|
|
31
|
|
|
$this->config = $this->getMockBuilder( '\Config' ) |
|
32
|
|
|
->disableOriginalConstructor() |
|
33
|
|
|
->getMock(); |
|
34
|
|
|
|
|
35
|
|
|
$this->message = $this->getMockBuilder( '\Message' ) |
|
36
|
|
|
->disableOriginalConstructor() |
|
37
|
|
|
->getMock(); |
|
38
|
|
|
|
|
39
|
|
|
$this->user = $this->getMockBuilder( '\User' ) |
|
40
|
|
|
->disableOriginalConstructor() |
|
41
|
|
|
->getMock(); |
|
42
|
|
|
|
|
43
|
|
|
$this->outputPage = $this->getMockBuilder( '\OutputPage' ) |
|
44
|
|
|
->disableOriginalConstructor() |
|
45
|
|
|
->getMock(); |
|
46
|
|
|
|
|
47
|
|
|
$this->context = $this->getMockBuilder( '\IContextSource' ) |
|
48
|
|
|
->disableOriginalConstructor() |
|
49
|
|
|
->getMock(); |
|
50
|
|
|
} |
|
51
|
|
|
|
|
52
|
|
|
/** |
|
53
|
|
|
* @dataProvider variableProvider |
|
54
|
|
|
*/ |
|
55
|
|
|
public function testCanExecute( $requestValues, $queryString ) { |
|
56
|
|
|
|
|
57
|
|
|
$this->request->expects( $this->once() ) |
|
58
|
|
|
->method( 'getValues' ) |
|
59
|
|
|
->will( $this->returnValue( $requestValues ) ); |
|
60
|
|
|
|
|
61
|
|
|
$this->context->expects( $this->any() ) |
|
62
|
|
|
->method( 'getTitle' ) |
|
63
|
|
|
->will( $this->returnValue( \Title::newFromText( __METHOD__ ) ) ); |
|
64
|
|
|
|
|
65
|
|
|
$SpecialFindCitableMetadata = $this->getMockBuilder( '\SCI\Specials\SpecialFindCitableMetadata' ) |
|
66
|
|
|
->disableOriginalConstructor() |
|
67
|
|
|
->setMethods( [ |
|
68
|
|
|
'getContext', |
|
69
|
|
|
'getOutput', |
|
70
|
|
|
'msg', |
|
71
|
|
|
'getConfig', |
|
72
|
|
|
'getRequest', |
|
73
|
|
|
'getUser', |
|
74
|
|
|
'userCanExecute' ] |
|
75
|
|
|
) |
|
76
|
|
|
->getMock(); |
|
77
|
|
|
|
|
78
|
|
|
$SpecialFindCitableMetadata->expects( $this->any() ) |
|
79
|
|
|
->method( 'getContext' ) |
|
80
|
|
|
->will( $this->returnValue( $this->context ) ); |
|
81
|
|
|
|
|
82
|
|
|
$SpecialFindCitableMetadata->expects( $this->any() ) |
|
83
|
|
|
->method( 'getOutput' ) |
|
84
|
|
|
->will( $this->returnValue( $this->outputPage ) ); |
|
85
|
|
|
|
|
86
|
|
|
$SpecialFindCitableMetadata->expects( $this->any() ) |
|
87
|
|
|
->method( 'getUser' ) |
|
88
|
|
|
->will( $this->returnValue( $this->user ) ); |
|
89
|
|
|
|
|
90
|
|
|
$SpecialFindCitableMetadata->expects( $this->any() ) |
|
91
|
|
|
->method( 'msg' ) |
|
92
|
|
|
->will( $this->returnValue( $this->message ) ); |
|
93
|
|
|
|
|
94
|
|
|
$SpecialFindCitableMetadata->expects( $this->any() ) |
|
95
|
|
|
->method( 'getConfig' ) |
|
96
|
|
|
->will( $this->returnValue( $this->config ) ); |
|
97
|
|
|
|
|
98
|
|
|
$SpecialFindCitableMetadata->expects( $this->any() ) |
|
99
|
|
|
->method( 'getRequest' ) |
|
100
|
|
|
->will( $this->returnValue( $this->request ) ); |
|
101
|
|
|
|
|
102
|
|
|
$SpecialFindCitableMetadata->expects( $this->once() ) |
|
103
|
|
|
->method( 'userCanExecute' ) |
|
104
|
|
|
->will( $this->returnValue( true ) ); |
|
105
|
|
|
|
|
106
|
|
|
$SpecialFindCitableMetadata->execute( $queryString ); |
|
107
|
|
|
} |
|
108
|
|
|
|
|
109
|
|
|
public function variableProvider() { |
|
110
|
|
|
|
|
111
|
|
|
$provider[] = [ |
|
112
|
|
|
[], |
|
113
|
|
|
'' |
|
114
|
|
|
]; |
|
115
|
|
|
|
|
116
|
|
|
$provider[] = [ |
|
117
|
|
|
[], |
|
118
|
|
|
'DOI/10.123' |
|
119
|
|
|
]; |
|
120
|
|
|
|
|
121
|
|
|
return $provider; |
|
122
|
|
|
} |
|
123
|
|
|
|
|
124
|
|
|
} |
|
125
|
|
|
|