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 ); |
|
|
|
|
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
|
|
|
|
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: