RuleFinderTest::testCanConstruct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 15

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 15
rs 9.7666
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
namespace SMW\ImageCaption\Tests;
4
5
use SMW\ImageCaption\RuleFinder;
6
7
/**
8
 * @covers \SMW\ImageCaption\RuleFinder
9
 * @group semantic-image-caption
10
 *
11
 * @license GNU GPL v2+
12
 * @since 1.0
13
 *
14
 * @author mwjames
15
 */
16
class RuleFinderTest extends \PHPUnit_Framework_TestCase {
17
18
	public function testCanConstruct() {
19
20
		$schemaFinder = $this->getMockBuilder( '\SMW\Schema\SchemaFinder' )
21
			->disableOriginalConstructor()
22
			->getMock();
23
24
		$schemaFilterFactory = $this->getMockBuilder( '\SMW\Schema\SchemaFilterFactory' )
25
			->disableOriginalConstructor()
26
			->getMock();
27
28
		$this->assertInstanceof(
29
			RuleFinder::class,
30
			new RuleFinder( $schemaFinder, $schemaFilterFactory )
31
		);
32
	}
33
34
	public function testFindRule_CategoryFilter() {
35
36
		$rule = $this->getMockBuilder( '\SMW\Schema\Rule' )
37
			->disableOriginalConstructor()
38
			->getMock();
39
40
		$categoryFilter = $this->getMockBuilder( '\SMW\Schema\Filters\CategoryFilter' )
41
			->disableOriginalConstructor()
42
			->getMock();
43
44
		$categoryFilter->expects( $this->any() )
45
			->method( 'getMatches' )
46
			->will( $this->returnValue( [ $rule ] ) );
47
48
		$schemaFilterFactory = $this->getMockBuilder( '\SMW\Schema\SchemaFilterFactory' )
49
			->disableOriginalConstructor()
50
			->getMock();
51
52
		$schemaFilterFactory->expects( $this->any() )
53
			->method( 'newCategoryFilter' )
54
			->will( $this->returnValue( $categoryFilter ) );
55
56
		$schemaList = $this->getMockBuilder( '\SMW\Schema\SchemaList' )
57
			->disableOriginalConstructor()
58
			->getMock();
59
60
		$schemaFinder = $this->getMockBuilder( '\SMW\Schema\SchemaFinder' )
61
			->disableOriginalConstructor()
62
			->getMock();
63
64
		$schemaFinder->expects( $this->any() )
65
			->method( 'getSchemaListByType' )
66
			->will( $this->returnValue( $schemaList ) );
67
68
		$instance = new RuleFinder(
69
			$schemaFinder,
70
			$schemaFilterFactory
71
		);
72
73
		$this->assertInstanceof(
74
			'\SMW\Schema\Compartment',
75
			$instance->findRule( [] )
76
		);
77
	}
78
79
}
80