LegacyDeserializerFactoryTest   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 8

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 8
dl 0
loc 29
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 0 3 1
A testEntityDeserializer() 0 9 1
A testSnakDeserializer() 0 6 1
1
<?php
2
3
namespace Tests\Integration\Wikibase\InternalSerialization;
4
5
use Wikibase\DataModel\Entity\Property;
6
use Wikibase\DataModel\Entity\PropertyId;
7
use Wikibase\DataModel\Snak\PropertyNoValueSnak;
8
use Wikibase\InternalSerialization\LegacyDeserializerFactory;
9
10
/**
11
 * @covers Wikibase\InternalSerialization\LegacyDeserializerFactory
12
 *
13
 * @license GPL-2.0-or-later
14
 * @author Jeroen De Dauw < [email protected] >
15
 */
16
class LegacyDeserializerFactoryTest extends \PHPUnit\Framework\TestCase {
17
18
	/**
19
	 * @var LegacyDeserializerFactory
20
	 */
21
	private $factory;
22
23
	protected function setUp() : void {
24
		$this->factory = TestFactoryBuilder::newLegacyDeserializerFactory( $this );
25
	}
26
27
	public function testEntityDeserializer() {
28
		$this->assertEquals(
29
			new Property( new PropertyId( 'P1' ), null, 'foo' ),
30
			$this->factory->newEntityDeserializer()->deserialize( array(
31
				'entity' => array( 'property', 1 ),
32
				'datatype' => 'foo',
33
			) )
34
		);
35
	}
36
37
	public function testSnakDeserializer() {
38
		$this->assertEquals(
39
			new PropertyNoValueSnak( 1 ),
40
			$this->factory->newSnakDeserializer()->deserialize( array( 'novalue', 1 ) )
41
		);
42
	}
43
44
}
45