1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace SMW\Tests\Exporter\ResourceBuilders; |
4
|
|
|
|
5
|
|
|
use SMW\Exporter\ResourceBuilders\UniquenessConstraintPropertyValueResourceBuilder; |
6
|
|
|
use SMW\DataItemFactory; |
7
|
|
|
use SMW\DataValueFactory; |
8
|
|
|
use SMW\Tests\TestEnvironment; |
9
|
|
|
use SMWExpData as ExpData; |
10
|
|
|
use SMW\Exporter\Element\ExpNsResource; |
11
|
|
|
|
12
|
|
|
/** |
13
|
|
|
* @covers \SMW\Exporter\ResourceBuilders\UniquenessConstraintPropertyValueResourceBuilder |
14
|
|
|
* @group semantic-mediawiki |
15
|
|
|
* |
16
|
|
|
* @license GNU GPL v2+ |
17
|
|
|
* @since 2.5 |
18
|
|
|
* |
19
|
|
|
* @author mwjames |
20
|
|
|
*/ |
21
|
|
|
class UniquenessConstraintPropertyValueResourceBuilderTest extends \PHPUnit_Framework_TestCase { |
22
|
|
|
|
23
|
|
|
private $dataItemFactory; |
24
|
|
|
private $dataValueFactory; |
25
|
|
|
private $testEnvironment; |
26
|
|
|
|
27
|
|
|
protected function setUp() { |
28
|
|
|
parent::setUp(); |
29
|
|
|
$this->dataItemFactory = new DataItemFactory(); |
30
|
|
|
$this->dataValueFactory = DataValueFactory::getInstance(); |
31
|
|
|
|
32
|
|
|
$this->testEnvironment = new TestEnvironment(); |
33
|
|
|
$this->testEnvironment->resetPoolCacheFor( \SMWExporter::POOLCACHE_ID ); |
34
|
|
|
} |
35
|
|
|
|
36
|
|
|
protected function tearDown() { |
37
|
|
|
$this->testEnvironment->tearDown(); |
38
|
|
|
parent::tearDown(); |
39
|
|
|
} |
40
|
|
|
|
41
|
|
|
public function testCanConstruct() { |
42
|
|
|
|
43
|
|
|
$this->assertInstanceof( |
44
|
|
|
UniquenessConstraintPropertyValueResourceBuilder::class, |
45
|
|
|
new UniquenessConstraintPropertyValueResourceBuilder() |
46
|
|
|
); |
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
public function testIsNotResourceBuilderForNonUniquenessConstraintProperty() { |
50
|
|
|
|
51
|
|
|
$property = $this->dataItemFactory->newDIProperty( 'Foo' ); |
52
|
|
|
|
53
|
|
|
$instance = new UniquenessConstraintPropertyValueResourceBuilder(); |
54
|
|
|
|
55
|
|
|
$this->assertFalse( |
56
|
|
|
$instance->isResourceBuilderFor( $property ) |
57
|
|
|
); |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
public function testAddResourceValueForValidProperty() { |
61
|
|
|
|
62
|
|
|
$property = $this->dataItemFactory->newDIProperty( '_PVUC' ); |
63
|
|
|
|
64
|
|
|
$expData = new ExpData( |
65
|
|
|
new ExpNsResource( 'Foobar', 'Bar', 'Mo', null ) |
|
|
|
|
66
|
|
|
); |
67
|
|
|
|
68
|
|
|
$instance = new UniquenessConstraintPropertyValueResourceBuilder(); |
69
|
|
|
|
70
|
|
|
$instance->addResourceValue( |
71
|
|
|
$expData, |
72
|
|
|
$property, |
73
|
|
|
$this->dataItemFactory->newDIBoolean( true ) |
74
|
|
|
); |
75
|
|
|
|
76
|
|
|
$this->assertTrue( |
77
|
|
|
$instance->isResourceBuilderFor( $property ) |
78
|
|
|
); |
79
|
|
|
} |
80
|
|
|
|
81
|
|
|
} |
82
|
|
|
|
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: