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

BibTexFileExportPrinterTest::filenameProvider()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 17

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 17
rs 9.7
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
namespace SRF\Tests\BibTex;
4
5
use SRF\BibTex\BibTexFileExportPrinter;
6
use SRF\Tests\ResultPrinterReflector;
7
8
/**
9
 * @covers \SRF\BibTex\BibTexFileExportPrinter
10
 * @group semantic-result-formats
11
 *
12
 * @license GNU GPL v2+
13
 * @since 3.1
14
 *
15
 * @author mwjames
16
 */
17
class BibTexFileExportPrinterTest 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
			BibTexFileExportPrinter::class,
36
			new BibTexFileExportPrinter( 'bibtex' )
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 BibTexFileExportPrinter(
50
			'bibtex'
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 BibTexFileExportPrinter(
64
			'bibtex'
65
		);
66
67
		$this->assertEquals(
68
			'text/bibtex',
69
			$instance->getMimeType( $this->queryResult )
70
		);
71
	}
72
73
	public function filenameProvider() {
74
75
		yield[
76
			'',
77
			'BibTeX.bib'
78
		];
79
80
		yield[
81
			'foo',
82
			'foo.bib'
83
		];
84
85
		yield[
86
			'foo.bib',
87
			'foo.bib'
88
		];
89
	}
90
91
}
92