invalidConstructorArgumentsProvider()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 12
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 3
Bugs 0 Features 0
Metric Value
c 3
b 0
f 0
dl 0
loc 12
rs 9.4285
cc 1
eloc 10
nc 1
nop 0
1
<?php
2
3
namespace DataTypes\Tests\Phpunit;
4
5
use DataTypes\DataType;
6
use InvalidArgumentException;
7
use PHPUnit_Framework_TestCase;
8
9
/**
10
 * @covers DataTypes\DataType
11
 *
12
 * @group DataTypes
13
 *
14
 * @license GPL-2.0+
15
 * @author Jeroen De Dauw < [email protected] >
16
 * @author Thiemo Mättig
17
 */
18
class DataTypeTest extends PHPUnit_Framework_TestCase {
19
20
	/**
21
	 * @dataProvider invalidConstructorArgumentsProvider
22
	 */
23
	public function testConstructorThrowsException( $propertyType, $valueType ) {
24
		$this->setExpectedException( InvalidArgumentException::class );
25
		new DataType( $propertyType, $valueType );
26
	}
27
28
	public function invalidConstructorArgumentsProvider() {
29
		return [
30
			[ 'propertyType', '' ],
31
			[ 'propertyType', null ],
32
			[ 'propertyType', false ],
33
			[ 'propertyType', 1 ],
34
			[ '', 'valueType' ],
35
			[ null, 'valueType' ],
36
			[ false, 'valueType' ],
37
			[ 0, 'valueType' ],
38
		];
39
	}
40
41
	public function testGetId() {
42
		$type = new DataType( 'propertyType', 'valueType' );
43
		$this->assertSame( 'propertyType', $type->getId() );
44
	}
45
46
	public function testGetDataValueType() {
47
		$type = new DataType( 'propertyType', 'valueType' );
48
		$this->assertSame( 'valueType', $type->getDataValueType() );
49
	}
50
51
	public function testGetMessageKey() {
52
		$type = new DataType( 'propertyType', 'valueType' );
53
		$this->assertSame( 'datatypes-type-propertyType', $type->getMessageKey() );
54
	}
55
56
	public function testToArray() {
57
		$type = new DataType( 'propertyType', 'valueType' );
58
		$this->assertSame( [ 'dataValueType' => 'valueType' ], $type->toArray() );
59
	}
60
61
}
62