diff --git a/tests/phpunit/ByJsonTestCaseProvider.php b/tests/phpunit/ByJsonTestCaseProvider.php index 68d007da29..de0cd09533 100644 --- a/tests/phpunit/ByJsonTestCaseProvider.php +++ b/tests/phpunit/ByJsonTestCaseProvider.php @@ -60,6 +60,11 @@ abstract class ByJsonTestCaseProvider extends MwDBaseUnitTestCase { */ protected $deleteAfterState = true; + /** + * @var string + */ + protected $connectorId = ''; + protected function setUp() { parent::setUp(); @@ -70,6 +75,12 @@ protected function setUp() { $this->fileReader = $utilityFactory->newJsonFileReader( null ); $this->pageCreator = $utilityFactory->newPageCreator(); $this->pageDeleter = $utilityFactory->newPageDeleter(); + + if ( $this->getStore() instanceof \SMWSparqlStore ) { + $this->connectorId = strtolower( $GLOBALS['smwgSparqlDatabaseConnector'] ); + } else { + $this->connectorId = strtolower( $this->getDBConnection()->getType() ); + } } protected function tearDown() { @@ -122,6 +133,12 @@ protected function createPagesFor( array $pages, $defaultNamespace ) { foreach ( $pages as $page ) { + $skipOn = isset( $page['skip-on'] ) ? $page['skip-on'] : array(); + + if ( in_array( $this->connectorId, array_keys( $skipOn ) ) ) { + continue; + } + if ( !isset( $page['name'] ) || !isset( $page['contents'] ) ) { continue; } diff --git a/tests/phpunit/Integration/ByJsonScript/ByJsonScriptFixtureTestCaseRunnerTest.php b/tests/phpunit/Integration/ByJsonScript/ByJsonScriptFixtureTestCaseRunnerTest.php index 401ee4e0ff..ea040131aa 100644 --- a/tests/phpunit/Integration/ByJsonScript/ByJsonScriptFixtureTestCaseRunnerTest.php +++ b/tests/phpunit/Integration/ByJsonScript/ByJsonScriptFixtureTestCaseRunnerTest.php @@ -173,6 +173,11 @@ private function tryToProcessParserTestCase( $jsonTestCaseFileHandler ) { ); foreach ( $jsonTestCaseFileHandler->findTestCasesFor( 'parser-testcases' ) as $case ) { + + if ( $jsonTestCaseFileHandler->requiredToSkipFor( $case, $this->connectorId ) ) { + continue; + } + $this->parserTestCaseProcessor->process( $case ); } } diff --git a/tests/phpunit/Integration/ByJsonScript/Fixtures/p-0413.json b/tests/phpunit/Integration/ByJsonScript/Fixtures/p-0413.json new file mode 100644 index 0000000000..37a3ec50bb --- /dev/null +++ b/tests/phpunit/Integration/ByJsonScript/Fixtures/p-0413.json @@ -0,0 +1,610 @@ +{ + "description": "Test in-text annotation for different `_dat` input/output (en)", + "properties": [ + { + "name": "Has date", + "contents": "[[Has type::Date]]" + } + ], + "subjects": [ + { + "name": "Example/P0413/1", + "contents": "[[Has date::Feb 11 2000 10:00:01]]" + }, + { + "name": "Example/P0413/1a", + "contents": "{{#ask: [[Example/P0413/1]] |?Has date |?Has date#- |?Has date#ISO=ISO Date |?Has date#MEDIAWIKI=MW Date }}" + }, + { + "name": "Example/P0413/2", + "contents": "[[Has date::Feb 11 2000]]" + }, + { + "name": "Example/P0413/2a", + "contents": "{{#ask: [[Example/P0413/2]] |?Has date |?Has date#- |?Has date#ISO=ISO Date |?Has date#MEDIAWIKI=MW Date }}" + }, + { + "name": "Example/P0413/3", + "contents": "[[Has date::2000]]" + }, + { + "name": "Example/P0413/3a", + "contents": "{{#ask: [[Example/P0413/3]] |?Has date |?Has date#- |?Has date#ISO=ISO Date |?Has date#MEDIAWIKI=MW Date }}" + }, + { + "name": "Example/P0413/4", + "contents": "[[Has date::Feb 11 2000 10:00:01 PM]]" + }, + { + "name": "Example/P0413/4a", + "contents": "{{#ask: [[Example/P0413/4]] |?Has date |?Has date#- |?Has date#ISO=ISO Date |?Has date#MEDIAWIKI=MW Date }}" + }, + { + "name": "Example/P0413/5", + "contents": "[[Has date::Feb 11 2000 22:00:01]]" + }, + { + "name": "Example/P0413/5a", + "contents": "{{#ask: [[Example/P0413/5]] |?Has date |?Has date#- |?Has date#ISO=ISO Date |?Has date#MEDIAWIKI=MW Date }}" + }, + { + "name": "Example/P0413/6", + "contents": "[[Has date::2000-02-11T22:00:01]]" + }, + { + "name": "Example/P0413/6a", + "contents": "{{#ask: [[Example/P0413/6]] |?Has date |?Has date#- |?Has date#ISO=ISO Date |?Has date#MEDIAWIKI=MW Date }}" + }, + { + "name": "Example/P0413/7", + "contents": "[[Has date::2000-02-11T22:00:01+02:00]]" + }, + { + "name": "Example/P0413/7a", + "contents": "{{#ask: [[Example/P0413/7]] |?Has date |?Has date#- |?Has date#ISO=ISO Date |?Has date#MEDIAWIKI=MW Date }}" + }, + { + "name": "Example/P0413/8", + "contents": "[[Has date::2000 February 2]]" + }, + { + "name": "Example/P0413/8a", + "contents": "{{#ask: [[Example/P0413/8]] |?Has date |?Has date#- |?Has date#ISO=ISO Date |?Has date#MEDIAWIKI=MW Date }}" + }, + { + "name": "Example/P0413/9", + "contents": "[[Has date::2-3-2000]]" + }, + { + "name": "Example/P0413/9a", + "contents": "{{#ask: [[Example/P0413/9]] |?Has date |?Has date#- |?Has date#ISO=ISO Date |?Has date#MEDIAWIKI=MW Date }}" + }, + { + "name": "Example/P0413/10", + "contents": "[[Has date::2/3/2000]]" + }, + { + "name": "Example/P0413/10a", + "contents": "{{#ask: [[Example/P0413/10]] |?Has date |?Has date#- |?Has date#ISO=ISO Date |?Has date#MEDIAWIKI=MW Date }}" + }, + { + "name": "Example/P0413/11", + "contents": "[[Has date::Jan 1 300 BC]]", + "skip-on": { + "virtuoso": "Virtuoso 6.1 does not support BC/BCE dates" + } + }, + { + "name": "Example/P0413/11a", + "contents": "{{#ask: [[Example/P0413/11]] |?Has date |?Has date#- |?Has date#ISO=ISO Date |?Has date#MEDIAWIKI=MW Date }}", + "skip-on": { + "virtuoso": "Virtuoso 6.1 does not support BC/BCE dates" + } + }, + { + "name": "Example/P0413/12", + "contents": "[[Has date::14000000000 BC]] (WIN-OS only allows 2147483647)", + "skip-on": { + "virtuoso": "Virtuoso 6.1 does not support BC/BCE dates" + } + }, + { + "name": "Example/P0413/12a", + "contents": "{{#ask: [[Example/P0413/12]] |?Has date |?Has date#- |?Has date#ISO=ISO Date |?Has date#MEDIAWIKI=MW Date }}", + "skip-on": { + "virtuoso": "Virtuoso 6.1 does not support BC/BCE dates" + } + }, + { + "name": "Example/P0413/13", + "contents": "[[Has date::Feb 11 2000 Jl]]" + }, + { + "name": "Example/P0413/13a", + "contents": "{{#ask: [[Example/P0413/13]] |?Has date |?Has date#- |?Has date#ISO=ISO Date |?Has date#MEDIAWIKI=MW Date |?Has date#JL=JL Date |?Has date#GR=GR Date }}" + }, + { + "name": "Example/P0413/14", + "contents": "[[Has date::Feb 11 1492 Gr]]" + }, + { + "name": "Example/P0413/14a", + "contents": "{{#ask: [[Example/P0413/14]] |?Has date |?Has date#- |?Has date#ISO=ISO Date |?Has date#MEDIAWIKI=MW Date |?Has date#JL=JL Date |?Has date#GR=GR Date }}" + }, + { + "name": "Example/P0413/15", + "contents": "[[Has date::Feb 11 2000 10:00 GMT]]" + }, + { + "name": "Example/P0413/15a", + "contents": "{{#ask: [[Example/P0413/15]] |?Has date |?Has date#- |?Has date#ISO=ISO Date |?Has date#MEDIAWIKI=MW Date |?Has date#JL=JL Date |?Has date#GR=GR Date }}" + }, + { + "name": "Example/P0413/16", + "contents": "[[Has date::2000-02-22]]" + }, + { + "name": "Example/P0413/16a", + "contents": "{{#ask: [[Example/P0413/16]] |?Has date |?Has date#- |?Has date#ISO=ISO Date |?Has date#MEDIAWIKI=MW Date }}" + } + ], + "parser-testcases": [ + { + "about": "#0 Complete date with time", + "subject": "Example/P0413/1", + "store": { + "semantic-data": { + "strict-mode-valuematch": false, + "propertyCount": 3, + "propertyKeys": [ "Has_date", "_SKEY", "_MDAT" ], + "propertyValues": [ "2000-02-11T10:00:01" ] + } + }, + "expected-output": { + "to-contain": [ + "Feb 11 2000 10:00:01" + ] + } + }, + { + "about": "#1", + "subject": "Example/P0413/1a", + "expected-output": { + "to-contain": [ + "11 February 2000 10:00:01", + "2000-02-11T10:00:01", + "2000-02-11T10:00:01", + "10:00, 11 February 2000" + ] + } + }, + { + "about": "#2 Just a date", + "subject": "Example/P0413/2", + "store": { + "semantic-data": { + "strict-mode-valuematch": false, + "propertyCount": 3, + "propertyKeys": [ "Has_date", "_SKEY", "_MDAT" ], + "propertyValues": [ "2000-02-11" ] + } + }, + "expected-output": { + "to-contain": [ + "Feb 11 2000" + ] + } + }, + { + "about": "#3", + "subject": "Example/P0413/2a", + "expected-output": { + "to-contain": [ + "11 February 2000", + "2000-02-11", + "2000-02-11", + "11 February 2000" + ] + } + }, + { + "about": "#4 Yearby itself", + "subject": "Example/P0413/3", + "store": { + "semantic-data": { + "strict-mode-valuematch": false, + "propertyCount": 3, + "propertyKeys": [ "Has_date", "_SKEY", "_MDAT" ], + "propertyValues": [ "2000-01-01" ] + } + }, + "expected-output": { + "to-contain": [ + "2000" + ] + } + }, + { + "about": "#5", + "subject": "Example/P0413/3a", + "expected-output": { + "to-contain": [ + "2000", + "2000-01-01", + "2000-01-01", + "2000" + ] + } + }, + { + "about": "#6 Complete date with time, PM", + "subject": "Example/P0413/4", + "store": { + "semantic-data": { + "strict-mode-valuematch": false, + "propertyCount": 3, + "propertyKeys": [ "Has_date", "_SKEY", "_MDAT" ], + "propertyValues": [ "2000-02-11T22:00:01" ] + } + }, + "expected-output": { + "to-contain": [ + "Feb 11 2000 10:00:01 PM" + ] + } + }, + { + "about": "#7", + "subject": "Example/P0413/4a", + "expected-output": { + "to-contain": [ + "11 February 2000 22:00:01", + "2000-02-11T22:00:01", + "2000-02-11T22:00:01", + "22:00, 11 February 2000" + ] + } + }, + { + "about": "#8 Complete date with 24h time", + "subject": "Example/P0413/5", + "store": { + "semantic-data": { + "strict-mode-valuematch": false, + "propertyCount": 3, + "propertyKeys": [ "Has_date", "_SKEY", "_MDAT" ], + "propertyValues": [ "2000-02-11T22:00:01" ] + } + }, + "expected-output": { + "to-contain": [ + "Feb 11 2000 22:00:01" + ] + } + }, + { + "about": "#9", + "subject": "Example/P0413/5a", + "expected-output": { + "to-contain": [ + "11 February 2000 22:00:01", + "2000-02-11T22:00:01", + "2000-02-11T22:00:01", + "22:00, 11 February 2000" + ] + } + }, + { + "about": "#10 ISO-style date", + "subject": "Example/P0413/6", + "store": { + "semantic-data": { + "strict-mode-valuematch": false, + "propertyCount": 3, + "propertyKeys": [ "Has_date", "_SKEY", "_MDAT" ], + "propertyValues": [ "2000-02-11T22:00:01" ] + } + }, + "expected-output": { + "to-contain": [ + "2000-02-11T22:00:01" + ] + } + }, + { + "about": "#11", + "subject": "Example/P0413/6a", + "expected-output": { + "to-contain": [ + "11 February 2000 22:00:01", + "2000-02-11T22:00:01", + "2000-02-11T22:00:01", + "22:00, 11 February 2000" + ] + } + }, + { + "about": "#12 ISO-style date with offset", + "subject": "Example/P0413/7", + "store": { + "semantic-data": { + "strict-mode-valuematch": false, + "propertyCount": 3, + "propertyKeys": [ "Has_date", "_SKEY", "_MDAT" ], + "propertyValues": [ "2000-02-11T20:00:01" ] + } + }, + "expected-output": { + "to-contain": [ + "2000-02-11T22:00:01+02:00" + ] + } + }, + { + "about": "#13", + "subject": "Example/P0413/7a", + "expected-output": { + "to-contain": [ + "11 February 2000 20:00:01", + "2000-02-11T20:00:01", + "2000-02-11T20:00:01", + "20:00, 11 February 2000" + ] + } + }, + { + "about": "#14 varying order of inputs", + "subject": "Example/P0413/8", + "store": { + "semantic-data": { + "strict-mode-valuematch": false, + "propertyCount": 3, + "propertyKeys": [ "Has_date", "_SKEY", "_MDAT" ], + "propertyValues": [ "2000-02-02" ] + } + }, + "expected-output": { + "to-contain": [ + "2000 February 2" + ] + } + }, + { + "about": "#15", + "subject": "Example/P0413/8a", + "expected-output": { + "to-contain": [ + "2 February 2000", + "2000-02-02", + "2000-02-02", + "2 February 2000" + ] + } + }, + { + "about": "#16 preferred interpretation, month or day, sometimes depends on language settings", + "subject": "Example/P0413/9", + "store": { + "semantic-data": { + "strict-mode-valuematch": false, + "propertyCount": 3, + "propertyKeys": [ "Has_date", "_SKEY", "_MDAT" ], + "propertyValues": [ "2000-02-03" ] + } + }, + "expected-output": { + "to-contain": [ + "2-3-2000" + ] + } + }, + { + "about": "#17", + "subject": "Example/P0413/9a", + "expected-output": { + "to-contain": [ + "3 February 2000", + "2000-02-03", + "2000-02-03", + "3 February 2000" + ] + } + }, + { + "about": "#18 various kinds of separators (/) are recognized in all languages", + "subject": "Example/P0413/10", + "store": { + "semantic-data": { + "strict-mode-valuematch": false, + "propertyCount": 3, + "propertyKeys": [ "Has_date", "_SKEY", "_MDAT" ], + "propertyValues": [ "2000-02-03" ] + } + }, + "expected-output": { + "to-contain": [ + "2/3/2000" + ] + } + }, + { + "about": "#19", + "subject": "Example/P0413/10a", + "expected-output": { + "to-contain": [ + "3 February 2000", + "2000-02-03", + "2000-02-03", + "3 February 2000" + ] + } + }, + { + "about": "#20 Dates BC/Before common era", + "skip-on": { + "virtuoso": "Virtuoso 6.1 does not support BC/BCE dates" + }, + "subject": "Example/P0413/11", + "store": { + "semantic-data": { + "strict-mode-valuematch": false, + "propertyCount": 3, + "propertyKeys": [ "Has_date", "_SKEY", "_MDAT" ], + "propertyValues": [ "--301-12-28" ] + } + }, + "expected-output": { + "to-contain": [ + "Jan 1 300 BC" + ] + } + }, + { + "about": "#21", + "skip-on": { + "virtuoso": "Virtuoso 6.1 does not support BC/BCE dates" + }, + "subject": "Example/P0413/11a", + "expected-output": { + "to-contain": [ + "1 January 300 BC", + "--301-12-28", + "--301-12-28", + "28 December 0000" + ] + } + }, + { + "about": "#24 Julian Calendar annotated date", + "subject": "Example/P0413/13", + "store": { + "semantic-data": { + "strict-mode-valuematch": false, + "propertyCount": 3, + "propertyKeys": [ "Has_date", "_SKEY", "_MDAT" ], + "propertyValues": [ "2000-02-24" ] + } + }, + "expected-output": { + "to-contain": [ + "Feb 11 2000 Jl" + ] + } + }, + { + "about": "#25", + "subject": "Example/P0413/13a", + "expected-output": { + "to-contain": [ + "24 February 2000", + "2000-02-24", + "2000-02-24", + "24 February 2000", + "11 February 2000", + "24 February 2000" + ] + } + }, + { + "about": "#26 Gregorian Calendar annotated date", + "subject": "Example/P0413/14", + "store": { + "semantic-data": { + "strict-mode-valuematch": false, + "propertyCount": 3, + "propertyKeys": [ "Has_date", "_SKEY", "_MDAT" ], + "propertyValues": [ "1492-02-11" ] + } + }, + "expected-output": { + "to-contain": [ + "Feb 11 1492 Gr" + ] + } + }, + { + "about": "#27", + "subject": "Example/P0413/14a", + "expected-output": { + "to-contain": [ + "2 February 1492", + "1492-02-11", + "1492-02-11", + "11 February 1492", + "2 February 1492", + "11 February 1492" + ] + } + }, + { + "about": "#28 Date with time zone shortcut", + "subject": "Example/P0413/15", + "store": { + "semantic-data": { + "strict-mode-valuematch": false, + "propertyCount": 3, + "propertyKeys": [ "Has_date", "_SKEY", "_MDAT" ], + "propertyValues": [ "2000-02-11T10:00:00" ] + } + }, + "expected-output": { + "to-contain": [ + "Feb 11 2000 10:00 GMT" + ] + } + }, + { + "about": "#29", + "subject": "Example/P0413/15a", + "expected-output": { + "to-contain": [ + "11 February 2000 10:00:00", + "2000-02-11T10:00:00", + "2000-02-11T10:00:00", + "10:00, 11 February 2000", + "29 January 2000 10:00:00", + "11 February 2000 10:00:00" + ] + } + }, + { + "about": "#30 MySQL date format", + "subject": "Example/P0413/16", + "store": { + "semantic-data": { + "strict-mode-valuematch": false, + "propertyCount": 3, + "propertyKeys": [ "Has_date", "_SKEY", "_MDAT" ], + "propertyValues": [ "2000-02-22" ] + } + }, + "expected-output": { + "to-contain": [ + "2000-02-22" + ] + } + }, + { + "about": "#31", + "subject": "Example/P0413/16a", + "expected-output": { + "to-contain": [ + "22 February 2000", + "2000-02-22", + "2000-02-22", + "22 February 2000" + ] + } + } + ], + "settings": { + "wgContLang": "en", + "wgLang": "en" + }, + "meta": { + + "version": "0.1", + "is-incomplete": false, + "debug": false + } +} \ No newline at end of file diff --git a/tests/phpunit/Integration/ByJsonScript/README.md b/tests/phpunit/Integration/ByJsonScript/README.md index 3017644c70..089f5a1f71 100644 --- a/tests/phpunit/Integration/ByJsonScript/README.md +++ b/tests/phpunit/Integration/ByJsonScript/README.md @@ -1,5 +1,5 @@ ## Fixtures -Contains 92 files: +Contains 93 files: ### F * [f-0001.json](https://github.com/SemanticMediaWiki/SemanticMediaWiki/tree/master/tests/phpunit/Integration/ByJsonScript/Fixtures/f-0001.json) Test format=debug output @@ -42,6 +42,7 @@ Contains 92 files: * [p-0410.json](https://github.com/SemanticMediaWiki/SemanticMediaWiki/tree/master/tests/phpunit/Integration/ByJsonScript/Fixtures/p-0410.json) Test in-text annotation on `_num`/`_tem`/`_qty` type with denoted precision (`_PREC`) and/or `-p` printout precision marker (#1335, en) * [p-0411.json](https://github.com/SemanticMediaWiki/SemanticMediaWiki/tree/master/tests/phpunit/Integration/ByJsonScript/Fixtures/p-0411.json) Test in-text annotation (and #subobject) using a monolingual property (#1344, en) * [p-0412.json](https://github.com/SemanticMediaWiki/SemanticMediaWiki/tree/master/tests/phpunit/Integration/ByJsonScript/Fixtures/p-0412.json) Test in-text annotation for `_boo` datatype (ja) +* [p-0413.json](https://github.com/SemanticMediaWiki/SemanticMediaWiki/tree/master/tests/phpunit/Integration/ByJsonScript/Fixtures/p-0413.json) Test in-text annotation for different `_dat` input/output (en) * [p-0701.json](https://github.com/SemanticMediaWiki/SemanticMediaWiki/tree/master/tests/phpunit/Integration/ByJsonScript/Fixtures/p-0701.json) Test to create inverted annotation using a #ask/template combination (#711, `import-annotation=true`) * [p-0702.json](https://github.com/SemanticMediaWiki/SemanticMediaWiki/tree/master/tests/phpunit/Integration/ByJsonScript/Fixtures/p-0702.json) Test #ask with `format=table` on inverse property/printrquest (#1270, en) * [p-0901.json](https://github.com/SemanticMediaWiki/SemanticMediaWiki/tree/master/tests/phpunit/Integration/ByJsonScript/Fixtures/p-0901.json) Test #ask on moved redirected subject (#1086) diff --git a/tests/phpunit/JsonTestCaseFileHandler.php b/tests/phpunit/JsonTestCaseFileHandler.php index bee2634e77..6e0290fe27 100644 --- a/tests/phpunit/JsonTestCaseFileHandler.php +++ b/tests/phpunit/JsonTestCaseFileHandler.php @@ -62,6 +62,26 @@ public function getDebugMode() { return isset( $meta['debug'] ) ? (bool)$meta['debug'] : false; } + /** + * @since 2.4 + * + * @param array $case + * @param string $identifier + * + * @return boolean + */ + public function requiredToSkipFor( array $case, $identifier ) { + + $skipOn = isset( $case['skip-on'] ) ? $case['skip-on'] : array(); + $identifier = strtolower( $identifier ); + + if ( in_array( $identifier, array_keys( $skipOn ) ) ) { + return true; + } + + return false; + } + /** * @since 2.2 *