Completed
Pull Request — master (#49)
by no
18:43 queued 13:55
created

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