XmlDumpImportCommandTest::newCommandTester()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 6
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
namespace Tests\Queryr\Replicator\Importer\Console;
4
5
use PHPUnit\Framework\TestCase;
6
use Queryr\Replicator\Cli\Command\XmlDumpImportCommand;
7
use Symfony\Component\Console\Tester\CommandTester;
8
use Tests\Queryr\Replicator\Integration\TestEnvironment;
9
10
/**
11
 * @covers \Queryr\Replicator\Cli\Command\XmlDumpImportCommand
12
 *
13
 * @licence GNU GPL v2+
14
 * @author Jeroen De Dauw < [email protected] >
15
 */
16
class XmlDumpImportCommandTest extends TestCase {
17
18
	public function testEntityIdInOutput() {
19
		$output = $this->getOutputForArgs( [
20
			'file' => 'tests/data/simple/one-item.xml'
21
		] );
22
23
		$this->assertContains( 'Q15831780', $output );
24
		$this->assertContains( 'Entity imported', $output );
25
	}
26
27
	private function getOutputForArgs( array $args ) {
28
		$commandTester = $this->newCommandTester();
29
30
		$commandTester->execute( $args );
31
32
		return $commandTester->getDisplay();
33
	}
34
35
	private function newCommandTester() {
36
		$command = new XmlDumpImportCommand();
37
		$command->setServiceFactory( TestEnvironment::newInstance()->getFactory() );
38
39
		return new CommandTester( $command );
40
	}
41
42
	public function testResume() {
43
		$output = $this->getOutputForArgs( [
44
			'file' => 'tests/data/simple/five-items.xml',
45
			'--continue' => 'Q15826086'
46
		] );
47
48
		$this->assertNotContains( 'Q15831779', $output );
49
		$this->assertNotContains( 'Q15831780', $output );
50
		$this->assertContains( 'Q15826087', $output );
51
		$this->assertContains( 'Q15826088', $output );
52
		$this->assertContains( 'Entities: 2', $output );
53
	}
54
55
}