Completed
Push — master ( a8abd3...b31965 )
by Jeroen De
22s
created

DataTypeTest   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 44
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 6
Bugs 0 Features 0
Metric Value
wmc 6
lcom 0
cbo 1
dl 0
loc 44
rs 10
c 6
b 0
f 0

6 Methods

Rating   Name   Duplication   Size   Complexity  
A testConstructorThrowsException() 0 4 1
A invalidConstructorArgumentsProvider() 0 12 1
A testGetId() 0 4 1
A testGetDataValueType() 0 4 1
A testGetMessageKey() 0 4 1
A testToArray() 0 4 1
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