|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace DataTypes\Tests\Phpunit; |
|
4
|
|
|
|
|
5
|
|
|
use DataTypes\DataType; |
|
6
|
|
|
use PHPUnit_Framework_TestCase; |
|
7
|
|
|
use ReflectionClass; |
|
8
|
|
|
|
|
9
|
|
|
/** |
|
10
|
|
|
* @covers DataTypes\DataType |
|
11
|
|
|
* |
|
12
|
|
|
* @group DataTypes |
|
13
|
|
|
* |
|
14
|
|
|
* @license GPL-2.0+ |
|
15
|
|
|
* @author Jeroen De Dauw < [email protected] > |
|
16
|
|
|
* @author Thiemo Mättig |
|
17
|
|
|
*/ |
|
18
|
|
|
class DataTypeTest extends PHPUnit_Framework_TestCase { |
|
19
|
|
|
|
|
20
|
|
|
/** |
|
21
|
|
|
* @dataProvider invalidConstructorArgumentsProvider |
|
22
|
|
|
*/ |
|
23
|
|
|
public function testConstructorThrowsException( $propertyType, $valueType ) { |
|
24
|
|
|
$this->setExpectedException( 'InvalidArgumentException' ); |
|
25
|
|
|
new DataType( $propertyType, $valueType ); |
|
26
|
|
|
} |
|
27
|
|
|
|
|
28
|
|
|
public function invalidConstructorArgumentsProvider() { |
|
29
|
|
|
return array( |
|
30
|
|
|
array( 'propertyType', '' ), |
|
31
|
|
|
array( 'propertyType', null ), |
|
32
|
|
|
array( 'propertyType', false ), |
|
33
|
|
|
array( 'propertyType', 1 ), |
|
34
|
|
|
array( '', 'valueType' ), |
|
35
|
|
|
array( null, 'valueType' ), |
|
36
|
|
|
array( false, 'valueType' ), |
|
37
|
|
|
array( 0, 'valueType' ), |
|
38
|
|
|
); |
|
39
|
|
|
} |
|
40
|
|
|
|
|
41
|
|
|
public function testGetId() { |
|
42
|
|
|
$type = new DataType( 'propertyType', 'valueType' ); |
|
43
|
|
|
$this->assertSame( 'propertyType', $type->getId() ); |
|
44
|
|
|
} |
|
45
|
|
|
|
|
46
|
|
|
public function testGetDataValueType() { |
|
47
|
|
|
$type = new DataType( 'propertyType', 'valueType' ); |
|
48
|
|
|
$this->assertSame( 'valueType', $type->getDataValueType() ); |
|
49
|
|
|
} |
|
50
|
|
|
|
|
51
|
|
|
public function testGetMessageKey() { |
|
52
|
|
|
$type = new DataType( 'propertyType', 'valueType' ); |
|
53
|
|
|
$this->assertSame( 'datatypes-type-propertyType', $type->getMessageKey() ); |
|
54
|
|
|
} |
|
55
|
|
|
|
|
56
|
|
|
public function testToArray() { |
|
57
|
|
|
$type = new DataType( 'propertyType', 'valueType' ); |
|
58
|
|
|
$this->assertSame( array( 'dataValueType' => 'valueType' ), $type->toArray() ); |
|
59
|
|
|
} |
|
60
|
|
|
|
|
61
|
|
|
} |
|
62
|
|
|
|