summaryrefslogtreecommitdiff
path: root/www/wiki/extensions/SemanticMediaWiki/tests/phpunit/Unit/Query/Result/ResolverJournalTest.php
blob: 53b64398c2c8c1099a03775ef3c598dacb60f6fa (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
<?php

namespace SMW\Tests\Query\Result;

use SMW\DIProperty;
use SMW\DIWikiPage;
use SMW\Query\Result\ResolverJournal;

/**
 * @covers \SMW\Query\Result\ResolverJournal
 * @group semantic-mediawiki
 *
 * @license GNU GPL v2+
 * @since 2.4
 *
 * @author mwjames
 */
class ResolverJournalTest extends \PHPUnit_Framework_TestCase {

	public function testCanConstruct() {

		$this->assertInstanceOf(
			ResolverJournal::class,
			new ResolverJournal()
		);
	}

	public function testRecordItem() {

		$dataItem = DIWikiPage::newFromText( 'Foo' );
		$instance = new ResolverJournal();

		$instance->prune();
		$instance->recordItem( $dataItem );

		$this->assertEquals(
			[ 'Foo#0##' => $dataItem ],
			$instance->getEntityList( 'FOO:123' )
		);

		$instance->prune();

		$this->assertEmpty(
			$instance->getEntityList()
		);
	}

	public function testRecordProperty() {

		$property = new DIProperty( 'Bar' );
		$instance = new ResolverJournal();

		$instance->recordProperty( $property );

		$this->assertEquals(
			[
				'Bar' => $property
			],
			$instance->getPropertyList()
		);
	}

}