PagesImporterTest   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 5

Importance

Changes 0
Metric Value
wmc 1
lcom 1
cbo 5
dl 0
loc 24
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A testCallsImportForEachPage() 0 20 1
1
<?php
2
3
namespace Tests\Queryr\Replicator\Importer;
4
5
use PHPUnit\Framework\TestCase;
6
use Queryr\Replicator\Importer\PageImporter;
7
use Queryr\Replicator\Importer\PageImportReporter;
8
use Queryr\Replicator\Importer\PagesImporter;
9
use Queryr\Replicator\Importer\StatsReporter;
10
use Queryr\Replicator\Model\EntityPage;
11
12
/**
13
 * @licence GNU GPL v2+
14
 * @author Jeroen De Dauw < [email protected] >
15
 */
16
class PagesImporterTest extends TestCase {
17
18
	public function testCallsImportForEachPage() {
19
		$pageImporter = $this->createMock( PageImporter::class );
20
21
		$pageImporter->expects( $this->exactly( 3 ) )
22
			->method( 'import' );
23
24
		$pageImporter->expects( $this->any() )
25
			->method( 'getReporter' )
26
			->will( $this->returnValue( $this->createMock( PageImportReporter::class ) ) );
27
28
		$statsReporter = $this->createMock( StatsReporter::class );
29
30
		$importer = new PagesImporter( $pageImporter, $statsReporter );
0 ignored issues
show
Documentation introduced by
$pageImporter is of type object<PHPUnit\Framework\MockObject\MockObject>, but the function expects a object<Queryr\Replicator\Importer\PageImporter>.

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...
Documentation introduced by
$statsReporter is of type object<PHPUnit\Framework\MockObject\MockObject>, but the function expects a object<Queryr\Replicator\Importer\StatsReporter>.

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...
31
32
		$importer->importPages( new \ArrayIterator( [
33
			new EntityPage( 'first', 'first', 1, 100, 'foo' ),
34
			new EntityPage( 'second', 'second', 2, 200, 'foo' ),
35
			new EntityPage( 'third', 'third', 3, 300, 'foo' )
36
		] ) );
37
	}
38
39
}
40
41