Completed
Push — master ( 63546b...ea4d88 )
by mw
08:24
created

vCardFileExportPrinterTest::testCanConstruct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 7
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
namespace SRF\Tests\vCard;
4
5
use SRF\vCard\vCardFileExportPrinter;
6
use SRF\Tests\ResultPrinterReflector;
7
8
/**
9
 * @covers \SRF\vCard\vCardFileExportPrinter
10
 * @group semantic-result-formats
11
 *
12
 * @license GNU GPL v2+
13
 * @since 3.1
14
 *
15
 * @author mwjames
16
 */
17
class vCardFileExportPrinterTest extends \PHPUnit_Framework_TestCase {
18
19
	private $queryResult;
20
	private $resultPrinterReflector;
21
22
	protected function setUp() {
23
		parent::setUp();
24
25
		$this->resultPrinterReflector = new ResultPrinterReflector();
26
27
		$this->queryResult = $this->getMockBuilder( '\SMWQueryResult' )
28
			->disableOriginalConstructor()
29
			->getMock();
30
	}
31
32
	public function testCanConstruct() {
33
34
		$this->assertInstanceOf(
35
			vCardFileExportPrinter::class,
36
			new vCardFileExportPrinter( 'vcard' )
37
		);
38
	}
39
40
	/**
41
	 * @dataProvider filenameProvider
42
	 */
43
	public function testGetFileName( $filename, $expected ) {
44
45
		$parameters = [
46
			'filename' => $filename
47
		];
48
49
		$instance = new vCardFileExportPrinter(
50
			'vcard'
51
		);
52
53
		$this->resultPrinterReflector->addParameters( $instance, $parameters );
54
55
		$this->assertEquals(
56
			$expected,
57
			$instance->getFileName( $this->queryResult )
58
		);
59
	}
60
61
	public function testGetMimeType() {
62
63
		$instance = new vCardFileExportPrinter(
64
			'vcard'
65
		);
66
67
		$this->assertEquals(
68
			'text/x-vcard',
69
			$instance->getMimeType( $this->queryResult )
70
		);
71
	}
72
73
	public function filenameProvider() {
74
75
		yield[
76
			'',
77
			'vCard.vcf'
78
		];
79
80
		yield[
81
			'foo',
82
			'foo.vcf'
83
		];
84
85
		yield[
86
			'foo.vcf',
87
			'foo.vcf'
88
		];
89
	}
90
91
}
92