blob: 13e071f6f65700feda9216a60ebf0068a7d97e8d (
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
|
<?php
namespace SMW\Tests\DataValues\ValueValidators;
use SMW\DataItemFactory;
use SMW\DataValueFactory;
use SMW\DataValues\ValueValidators\PropertySpecificationConstraintValueValidator;
/**
* @covers \SMW\DataValues\ValueValidators\PropertySpecificationConstraintValueValidator
* @group semantic-mediawiki
*
* @license GNU GPL v2+
* @since 2.5
*
* @author mwjames
*/
class PropertySpecificationConstraintValueValidatorTest extends \PHPUnit_Framework_TestCase {
private $dataItemFactory;
private $dataValueFactory;
protected function setUp() {
parent::setUp();
$this->dataItemFactory = new DataItemFactory();
$this->dataValueFactory = DataValueFactory::getInstance();
}
public function testCanConstruct() {
$this->assertInstanceOf(
'\SMW\DataValues\ValueValidators\PropertySpecificationConstraintValueValidator',
new PropertySpecificationConstraintValueValidator()
);
}
public function testHasNoConstraintViolationOnNonRelatedValue() {
$instance = new PropertySpecificationConstraintValueValidator();
$instance->validate( 'Foo' );
$this->assertFalse(
$instance->hasConstraintViolation()
);
}
public function testHasNoConstraintViolationOnDisabledPreferredLabelPropertyButWithError() {
$dataValue = $this->dataValueFactory->newDataValueByProperty(
$this->dataItemFactory->newDIProperty( '_PPLB' )
);
$dataValue->setContextPage(
$this->dataItemFactory->newDIWikiPage( 'Foo', SMW_NS_PROPERTY )
);
$dataValue->setOption( 'smwgDVFeatures', ~SMW_DV_PPLB );
$instance = new PropertySpecificationConstraintValueValidator();
$instance->validate( $dataValue );
$this->assertFalse(
$instance->hasConstraintViolation()
);
$this->assertNotEmpty(
$dataValue->getErrors()
);
}
}
|