1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace DataTypes\Tests\Phpunit; |
4
|
|
|
|
5
|
|
|
use DataTypes\DataType; |
6
|
|
|
use DataTypes\Message; |
7
|
|
|
use PHPUnit_Framework_TestCase; |
8
|
|
|
|
9
|
|
|
/** |
10
|
|
|
* @covers DataTypes\DataType |
11
|
|
|
* |
12
|
|
|
* @group DataTypes |
13
|
|
|
* |
14
|
|
|
* @licence GNU GPL v2+ |
15
|
|
|
* @author Jeroen De Dauw < [email protected] > |
16
|
|
|
* @author Thiemo Mättig |
17
|
|
|
*/ |
18
|
|
|
class DataTypeTest extends PHPUnit_Framework_TestCase { |
19
|
|
|
|
20
|
|
|
protected function setUp() { |
21
|
|
|
parent::setUp(); |
22
|
|
|
|
23
|
|
|
Message::registerTextFunction( function( $key, $languageCode ) { |
|
|
|
|
24
|
|
|
return implode( '|', func_get_args() ); |
25
|
|
|
} ); |
26
|
|
|
} |
27
|
|
|
|
28
|
|
|
/** |
29
|
|
|
* @dataProvider invalidConstructorArgumentsProvider |
30
|
|
|
*/ |
31
|
|
|
public function testConstructorThrowsException( $propertyType, $valueType ) { |
32
|
|
|
$this->setExpectedException( 'InvalidArgumentException' ); |
33
|
|
|
new DataType( $propertyType, $valueType ); |
34
|
|
|
} |
35
|
|
|
|
36
|
|
|
public function invalidConstructorArgumentsProvider() { |
37
|
|
|
return array( |
38
|
|
|
array( 'propertyType', null ), |
39
|
|
|
array( 'propertyType', false ), |
40
|
|
|
array( null, 'valueType' ), |
41
|
|
|
array( false, 'valueType' ), |
42
|
|
|
); |
43
|
|
|
} |
44
|
|
|
|
45
|
|
|
public function testGetId() { |
46
|
|
|
$type = new DataType( 'propertyType', 'valueType' ); |
47
|
|
|
$this->assertSame( 'propertyType', $type->getId() ); |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
public function testGetDataValueType() { |
51
|
|
|
$type = new DataType( 'propertyType', 'valueType' ); |
52
|
|
|
$this->assertSame( 'valueType', $type->getDataValueType() ); |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
public function testGetLabel() { |
56
|
|
|
$type = new DataType( 'propertyType', 'valueType' ); |
57
|
|
|
$this->assertSame( 'datatypes-type-propertyType|en', $type->getLabel( 'en' ) ); |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
public function testToArray() { |
61
|
|
|
$type = new DataType( 'propertyType', 'valueType' ); |
62
|
|
|
$this->assertSame( array( 'dataValueType' => 'valueType' ), $type->toArray() ); |
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
} |
66
|
|
|
|
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.