Completed
Pull Request — master (#46)
by no
08:45 queued 02:10
created

DataTypeTest::getInstances()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 3
Bugs 0 Features 0
Metric Value
c 3
b 0
f 0
dl 0
loc 7
rs 9.4286
cc 1
eloc 4
nc 1
nop 0
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
 * @licence GNU GPL v2+
13
 * @author Jeroen De Dauw < [email protected] >
14
 * @author Thiemo Mättig
15
 */
16
class DataTypeTest extends PHPUnit_Framework_TestCase {
17
18
	protected function setUp() {
19
		parent::setUp();
20
21
		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...
22
			return implode( '|', func_get_args() );
23
		} );
24
	}
25
26
	/**
27
	 * @dataProvider invalidConstructorArgumentsProvider
28
	 */
29
	public function testConstructorThrowsException( $propertyType, $valueType ) {
30
		$this->setExpectedException( 'InvalidArgumentException' );
31
		new DataType( $propertyType, $valueType );
32
	}
33
34
	public function invalidConstructorArgumentsProvider() {
35
		return array(
36
			array( 'propertyType', null ),
37
			array( 'propertyType', false ),
38
			array( 'propertyType', '' ),
39
			array( null, 'valueType' ),
40
			array( false, 'valueType' ),
41
			array( '', '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