Completed
Push — master ( e61639...4a2756 )
by
unknown
09:47 queued 06:18
created

DataTypeTest   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 48
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 6
Bugs 0 Features 0
Metric Value
wmc 7
c 6
b 0
f 0
lcom 0
cbo 2
dl 0
loc 48
rs 10

7 Methods

Rating   Name   Duplication   Size   Complexity  
A testGetId() 0 4 1
A testGetDataValueType() 0 4 1
A testGetLabel() 0 4 1
A testToArray() 0 4 1
A setUp() 0 7 1
A testConstructorThrowsException() 0 4 1
A invalidConstructorArgumentsProvider() 0 8 1
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 ) {
0 ignored issues
show
Unused Code introduced by
The parameter $key is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $languageCode is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
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