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

DataTypeTest::testConstructorThrowsException()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 3
nc 1
nop 2
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 Thiemo Mättig
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 Thiemo Mättig
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