Completed
Push — master ( 0bf478...d3e040 )
by mw
19:05
created

CitationReferenceValueTest::testCanConstruct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

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