1 | <?php |
||
17 | class CitationReferenceValueTest extends \PHPUnit_Framework_TestCase { |
||
18 | |||
19 | private $dataValueServiceFactory; |
||
20 | |||
21 | protected function setUp() : void { |
||
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 | $callback = function() use ( $citationReferencePositionJournal ) { |
||
52 | return $citationReferencePositionJournal; |
||
53 | }; |
||
54 | |||
55 | $instance = new CitationReferenceValue(); |
||
56 | $instance->addCallable( 'sci.citationreferencepositionjournal', $callback ); |
||
57 | |||
58 | $instance->setDataValueServiceFactory( |
||
59 | $this->dataValueServiceFactory |
||
60 | ); |
||
61 | |||
62 | $instance->setUserValue( '' ); |
||
63 | |||
64 | $this->assertNotEmpty( |
||
65 | $instance->getErrors() |
||
66 | ); |
||
67 | } |
||
68 | |||
69 | } |
||
70 |