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

getPermittedSettings()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

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