summaryrefslogtreecommitdiff
path: root/www/wiki/extensions/SemanticMediaWiki/tests/phpunit/Unit/Query/Result/StringResultTest.php
blob: 092b90b8da560d23f494c5f2343fcc9eb7edc9df (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
<?php

namespace SMW\Tests\Query\Result;

use SMW\Query\Result\StringResult;

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

	private $query;

	protected function setUp() {

		$this->query = $this->getMockBuilder( '\SMWQuery' )
			->disableOriginalConstructor()
			->getMock();
	}

	public function testCanConstruct() {

		$this->assertInstanceOf(
			StringResult::class,
			new StringResult( '', $this->query )
		);
	}

	public function testGetResult() {

		$instance = new StringResult( 'Foobar', $this->query );

		$this->assertEquals(
			'Foobar',
			$instance->getResults()
		);
	}

	public function testGetResult_PreOutputCallback() {

		$instance = new StringResult( 'Foobar', $this->query );

		$instance->setPreOutputCallback( function( $result, $options ) {
			return $result . ' Foo bar';
		} );

		$this->assertEquals(
			'Foobar Foo bar',
			$instance->getResults()
		);
	}

}