blob: 9dae22aed4df37aea8a9c1ca88e193b850a4f1ca (
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
64
65
66
67
68
69
70
71
72
|
<?php
namespace SMW\Tests\Query;
use SMW\DIWikiPage;
use SMW\Query\Excerpts;
/**
* @covers \SMW\Query\Excerpts
* @group semantic-mediawiki
*
* @license GNU GPL v2+
* @since 3.0
*
* @author mwjames
*/
class ExcerptsTest extends \PHPUnit_Framework_TestCase {
public function testCanConstruct() {
$this->assertInstanceOf(
Excerpts::class,
new Excerpts()
);
}
public function testAddExcerpt() {
$instance = new Excerpts();
$instance->addExcerpt( 'Foo', 0.1 );
$this->assertEquals(
0.1,
$instance->getExcerpt( 'Foo' )
);
$this->assertFalse(
$instance->getExcerpt( 'Bar' )
);
}
public function testAddExcerpt_DIWikiPage() {
$dataItem = DIWikiPage::newFromText( 'Bar' );
$instance = new Excerpts();
$instance->addExcerpt( $dataItem, 10 );
$this->assertEquals(
10,
$instance->getExcerpt( $dataItem )
);
}
public function testGetExcerpts() {
$instance = new Excerpts();
$instance->addExcerpt( 'Foo', '...' );
$instance->addExcerpt( 'Bar', 1001 );
$this->assertEquals(
[
[ 'Foo', '...' ],
[ 'Bar', 1001 ]
],
$instance->getExcerpts()
);
}
}
|