Completed
Pull Request — master (#467)
by
unknown
15:24
created

JsonTestCaseScriptRunnerTest::runTestCaseFile()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
1
<?php
2
3
namespace SMW\Tests\Integration\JSONScript;
4
5
use SMW\ApplicationFactory;
6
use SMW\DataValueFactory;
7
use SMW\EventHandler;
8
use SMW\PropertySpecificationLookup;
9
use SMW\SPARQLStore\TurtleTriplesBuilder;
10
use SMW\Tests\JsonTestCaseFileHandler;
11
use SMW\Tests\JsonTestCaseScriptRunner;
12
13
/**
14
 * @see https://github.com/SemanticMediaWiki/SemanticMediaWiki/tree/master/tests#write-integration-tests-using-json-script
15
 *
16
 * `JsonTestCaseScriptRunner` provisioned by SMW is a base class allowing to use a JSON
17
 * format to create test definitions with the objective to compose "real" content
18
 * and test integration with MediaWiki, Semantic MediaWiki, and Scribunto.
19
 *
20
 * @group SRF
21
 * @group SMWExtension
22
 *
23
 * @license GNU GPL v2+
24
 * @since 2.5
25
 *
26
 * @author Stephan Gambke
27
 */
28
class JsonTestCaseScriptRunnerTest extends JsonTestCaseScriptRunner {
29
30
	/**
31
	 * @see \SMW\Tests\JsonTestCaseScriptRunner::getTestCaseLocation
32
	 * @return string
33
	 */
34
	protected function getTestCaseLocation() {
35
		return __DIR__ . '/TestCases';
36
	}
37
38
	/**
39
	 * @see JsonTestCaseScriptRunner::getDependencyDefinitions
40
	 */
41
	protected function getDependencyDefinitions() {
42
		return [
43
			'Mermaid' => [ $this, 'checkMermaidDependency' ]
44
		];
45
	}
46
47
	public function checkMermaidDependency( $val, &$reason ) {
48
49
		if ( !defined( 'MERMAID_VERSION' ) ) {
50
			$reason = "Dependency: Mermaid as requirement is not available!";
51
			return false;
52
		}
53
54
		list( $compare, $requiredVersion ) = explode( ' ', $val );
55
		$version = MERMAID_VERSION;
56
57
		if ( !version_compare( $version, $requiredVersion, $compare ) ) {
58
			$reason = "Dependency: Required version of Mermaid ($requiredVersion $compare $version) is not available!";
59
			return false;
60
		}
61
62
		return true;
63
	}
64
65
	/**
66
	 * @see JsonTestCaseScriptRunner::runTestCaseFile
67
	 *
68
	 * @param JsonTestCaseFileHandler $jsonTestCaseFileHandler
69
	 */
70
	protected function runTestCaseFile( JsonTestCaseFileHandler $jsonTestCaseFileHandler ) { }
71
72
}
73