1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace SCI\Tests\DataValues; |
4
|
|
|
|
5
|
|
|
use SCI\DataValues\CitationReferenceValue; |
6
|
|
|
use SMW\DataTypeRegistry; |
7
|
|
|
|
8
|
|
|
/** |
9
|
|
|
* @covers \SCI\DataValues\CitationReferenceValue |
10
|
|
|
* @group semantic-cite |
11
|
|
|
* |
12
|
|
|
* @license GNU GPL v2+ |
13
|
|
|
* @since 1.0 |
14
|
|
|
* |
15
|
|
|
* @author mwjames |
16
|
|
|
*/ |
17
|
|
|
class CitationReferenceValueTest extends \PHPUnit_Framework_TestCase { |
18
|
|
|
|
19
|
|
|
private $dataValueServiceFactory; |
20
|
|
|
|
21
|
|
|
protected function setUp() { |
22
|
|
|
parent::setUp(); |
23
|
|
|
|
24
|
|
|
$constraintValueValidator = $this->getMockBuilder( '\SMW\DataValues\ValueValidators\ConstraintValueValidator' ) |
25
|
|
|
->disableOriginalConstructor() |
26
|
|
|
->getMock(); |
27
|
|
|
|
28
|
|
|
$this->dataValueServiceFactory = $this->getMockBuilder( '\SMW\Services\DataValueServiceFactory' ) |
29
|
|
|
->disableOriginalConstructor() |
30
|
|
|
->getMock(); |
31
|
|
|
|
32
|
|
|
$this->dataValueServiceFactory->expects( $this->any() ) |
33
|
|
|
->method( 'getConstraintValueValidator' ) |
34
|
|
|
->will( $this->returnValue( $constraintValueValidator ) ); |
35
|
|
|
} |
36
|
|
|
|
37
|
|
|
public function testCanConstruct() { |
38
|
|
|
|
39
|
|
|
$this->assertInstanceOf( |
40
|
|
|
'\SCI\DataValues\CitationReferenceValue', |
41
|
|
|
new CitationReferenceValue() |
42
|
|
|
); |
43
|
|
|
} |
44
|
|
|
|
45
|
|
|
public function testNoValueCreatesError() { |
46
|
|
|
|
47
|
|
|
$citationReferencePositionJournal = $this->getMockBuilder( '\SCI\CitationReferencePositionJournal' ) |
48
|
|
|
->disableOriginalConstructor() |
49
|
|
|
->getMock(); |
50
|
|
|
|
51
|
|
|
$this->dataValueServiceFactory->importExtraneousFunctions( |
52
|
|
|
array( |
53
|
|
|
'\SCI\CitationReferencePositionJournal' => function() use ( $citationReferencePositionJournal ) { |
54
|
|
|
return $citationReferencePositionJournal; |
55
|
|
|
} |
56
|
|
|
) |
57
|
|
|
); |
58
|
|
|
|
59
|
|
|
$instance = new CitationReferenceValue(); |
60
|
|
|
|
61
|
|
|
$instance->setDataValueServiceFactory( |
62
|
|
|
$this->dataValueServiceFactory |
63
|
|
|
); |
64
|
|
|
|
65
|
|
|
$instance->setUserValue( '' ); |
66
|
|
|
|
67
|
|
|
$this->assertNotEmpty( |
68
|
|
|
$instance->getErrors() |
69
|
|
|
); |
70
|
|
|
} |
71
|
|
|
|
72
|
|
|
} |
73
|
|
|
|