Completed
Push — master ( 0a532a...959a2b )
by mw
122:08 queued 105:20
created

FormatProfileAnnotatorTest::setUp()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 3
nc 1
nop 0
dl 0
loc 5
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
namespace SMW\Tests\Query\ProfileAnnotators;
4
5
use SMW\DIWikiPage;
6
use SMW\Query\ProfileAnnotators\FormatProfileAnnotator;
7
use SMW\Query\ProfileAnnotators\NullProfileAnnotator;
8
use SMW\Tests\Utils\UtilityFactory;
9
use SMWContainerSemanticData as ContainerSemanticData;
10
use SMWDIContainer as DIContainer;
11
12
/**
13
 * @covers \SMW\Query\ProfileAnnotators\FormatProfileAnnotator
14
 * @group semantic-mediawiki
15
 *
16
 * @license GNU GPL v2+
17
 * @since 1.9
18
 *
19
 * @author mwjames
20
 */
21
class FormatProfileAnnotatorTest extends \PHPUnit_Framework_TestCase {
22
23
	private $semanticDataValidator;
24
25
	protected function setUp() {
26
		parent::setUp();
27
28
		$this->semanticDataValidator = UtilityFactory::getInstance()->newValidatorFactory()->newSemanticDataValidator();
29
	}
30
31
	public function testCanConstruct() {
32
33
		$profileAnnotator = $this->getMockBuilder( '\SMW\Query\ProfileAnnotator' )
34
			->disableOriginalConstructor()
35
			->getMock();
36
37
		$this->assertInstanceOf(
38
			'\SMW\Query\ProfileAnnotators\FormatProfileAnnotator',
39
			new FormatProfileAnnotator( $profileAnnotator, 'table' )
40
		);
41
	}
42
43
	public function testCreateProfile() {
44
45
		$subject =new DIWikiPage( __METHOD__, NS_MAIN, '', 'foo' );
46
47
		$container = new DIContainer(
48
			new ContainerSemanticData( $subject	)
49
		);
50
51
		$instance = new FormatProfileAnnotator(
52
			new NullProfileAnnotator( $container ),
53
			'table'
54
		);
55
56
		$instance->addAnnotation();
57
58
		$expected = array(
59
			'propertyCount'  => 1,
60
			'propertyKeys'   => array( '_ASKFO' ),
61
			'propertyValues' => array( 'table' )
62
		);
63
64
		$this->semanticDataValidator->assertThatPropertiesAreSet(
65
			$expected,
66
			$instance->getContainer()->getSemanticData()
67
		);
68
	}
69
70
}
71