SerializerFactoryTest   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 4
dl 0
loc 21
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 0 3 1
A testEntitySerializerConstruction() 0 8 1
1
<?php
2
3
namespace Tests\Integration\Wikibase\InternalSerialization;
4
5
use Serializers\Serializer;
6
use Wikibase\DataModel\Entity\Item;
7
use Wikibase\InternalSerialization\SerializerFactory;
8
9
/**
10
 * @covers Wikibase\InternalSerialization\SerializerFactory
11
 *
12
 * @license GPL-2.0-or-later
13
 * @author Jeroen De Dauw < [email protected] >
14
 */
15
class SerializerFactoryTest extends \PHPUnit\Framework\TestCase {
16
17
	/**
18
	 * @var SerializerFactory
19
	 */
20
	private $factory;
21
22
	protected function setUp() : void {
23
		$this->factory = new SerializerFactory( $this->createMock( Serializer::class ) );
0 ignored issues
show
Documentation introduced by
$this->createMock(\Serializers\Serializer::class) is of type object<PHPUnit\Framework\MockObject\MockObject>, but the function expects a object<Serializers\Serializer>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
24
	}
25
26
	public function testEntitySerializerConstruction() {
27
		$this->factory->newEntitySerializer()->serialize( new Item() );
28
29
		$this->assertTrue(
30
			true,
31
			'The serializer returned by newEntitySerializer can serialize an Item'
32
		);
33
	}
34
35
}
36