Completed
Push — master ( 813ff2...07dd29 )
by mw
377:22 queued 342:34
created

ImportContentsTest::testContentType()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 11
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 11
c 0
b 0
f 0
cc 1
eloc 6
nc 1
nop 0
rs 9.4285
1
<?php
2
3
namespace SMW\TestsImporter;
4
5
use SMW\Importer\ImportContents;
6
7
/**
8
 * @covers \SMW\Importer\ImportContents
9
 * @group semantic-mediawiki
10
 *
11
 * @license GNU GPL v2+
12
 * @since 2.5
13
 *
14
 * @author mwjames
15
 */
16
class ImportContentsTest extends \PHPUnit_Framework_TestCase {
17
18
	public function testCanConstruct() {
19
20
		$this->assertInstanceOf(
21
			'\SMW\Importer\ImportContents',
22
			new ImportContents()
23
		);
24
	}
25
26
	public function testDescription() {
27
28
		$instance = new ImportContents();
29
30
		$instance->setDescription( 'Foo' );
31
32
		$this->assertSame(
33
			'Foo',
34
			$instance->getDescription()
35
		);
36
	}
37
38
	public function testVersion() {
39
40
		$instance = new ImportContents();
41
42
		$instance->setVersion( '1' );
43
44
		$this->assertSame(
45
			1,
46
			$instance->getVersion()
47
		);
48
	}
49
50
	public function testName() {
51
52
		$instance = new ImportContents();
53
54
		$instance->setName( 'Foo' );
55
56
		$this->assertSame(
57
			'Foo',
58
			$instance->getName()
59
		);
60
	}
61
62
	public function testNamespace() {
63
64
		$instance = new ImportContents();
65
66
		$instance->setNamespace( 'Foo' );
67
68
		$this->assertSame(
69
			'Foo',
70
			$instance->getNamespace()
71
		);
72
	}
73
74
	public function testContents() {
75
76
		$instance = new ImportContents();
77
78
		$instance->setContents( 'Foo' );
79
80
		$this->assertSame(
81
			'Foo',
82
			$instance->getContents()
83
		);
84
	}
85
86
	public function testContentType() {
87
88
		$instance = new ImportContents();
89
90
		$instance->setContentType( 'Foo' );
91
92
		$this->assertSame(
93
			'Foo',
94
			$instance->getContentType()
95
		);
96
	}
97
98
	public function testError() {
99
100
		$instance = new ImportContents();
101
102
		$instance->addError( 'Foo' );
103
104
		$this->assertSame(
105
			array( 'Foo' ),
106
			$instance->getErrors()
107
		);
108
	}
109
110
	public function testOptions() {
111
112
		$instance = new ImportContents();
113
114
		$instance->setOptions( 'Foo' );
0 ignored issues
show
Documentation introduced by
'Foo' is of type string, but the function expects a array.

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:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
115
116
		$this->assertSame(
117
			array( 'Foo' ),
118
			$instance->getOptions()
119
		);
120
121
		$this->assertFalse(
122
			$instance->getOption( 'Foo' )
123
		);
124
	}
125
126
}
127