ApiImportCommandTest::testEntityIdInOutput()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 8
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\ApiImportCommand;
7
use Symfony\Component\Console\Tester\CommandTester;
8
use Tests\Queryr\Replicator\Fixtures\FakeHttp;
9
use Tests\Queryr\Replicator\Integration\TestEnvironment;
10
11
/**
12
 * @covers \Queryr\Replicator\Cli\Command\ApiImportCommand
13
 *
14
 * @licence GNU GPL v2+
15
 * @author Jeroen De Dauw < [email protected] >
16
 */
17
class ApiImportCommandTest extends TestCase {
18
19
	public function testEntityIdInOutput() {
20
		$output = $this->getOutputForArgs( [
21
			'entities' => [ 'Q1' ]
22
		] );
23
24
		$this->assertContains( 'Q1', $output );
25
		$this->assertContains( 'Entity imported', $output );
26
	}
27
28
	private function getOutputForArgs( array $args ) {
29
		$commandTester = $this->newCommandTester();
30
31
		$commandTester->execute( $args );
32
33
		return $commandTester->getDisplay();
34
	}
35
36
	private function newCommandTester() {
37
		$command = new ApiImportCommand();
38
		$command->setServiceFactory( TestEnvironment::newInstance()->getFactory() );
39
		$command->setHttp( new FakeHttp() );
40
41
		return new CommandTester( $command );
42
	}
43
44
}
45
46