Passed
Push — emptyTypes ( 729d32...4c20e7 )
by no
06:55 queued 03:55
created

DataTypeTest::instanceProvider()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 9
rs 9.6666
cc 2
eloc 5
nc 2
nop 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A DataTypeTest::testGetId() 0 4 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', '' ),
39
			array( 'propertyType', null ),
40
			array( 'propertyType', false ),
41
			array( 'propertyType', 1 ),
42
			array( '', 'valueType' ),
43
			array( null, 'valueType' ),
44
			array( false, 'valueType' ),
45
			array( 0, 'valueType' ),
46
		);
47
	}
48
49
	public function testGetId() {
50
		$type = new DataType( 'propertyType', 'valueType' );
51
		$this->assertSame( 'propertyType', $type->getId() );
52
	}
53
54
	public function testGetDataValueType() {
55
		$type = new DataType( 'propertyType', 'valueType' );
56
		$this->assertSame( 'valueType', $type->getDataValueType() );
57
	}
58
59
	public function testGetLabel() {
60
		$type = new DataType( 'propertyType', 'valueType' );
61
		$this->assertSame( 'datatypes-type-propertyType|en', $type->getLabel( 'en' ) );
62
	}
63
64
	public function testToArray() {
65
		$type = new DataType( 'propertyType', 'valueType' );
66
		$this->assertSame( array( 'dataValueType' => 'valueType' ), $type->toArray() );
67
	}
68
69
}
70