gplx/mediawiki/extensions/SemanticMediaWiki/tests/phpunit/Integration/Elastic/DefaultConfigTest.php

65 lines
1.2 KiB
PHP

<?php
namespace SMW\Tests\Integration\Elastic;
use SMW\Exception\JSONParseException;
/**
* @license GPL-2.0-or-later
* @since 3.2
*
* @author mwjames
*/
class DefaultConfigTest extends \PHPUnit\Framework\TestCase {
private $contents;
protected function setUp(): void {
parent::setUp();
$this->contents = file_get_contents(
$GLOBALS['smwgIP'] . 'data/elastic/default-profile.json'
);
}
public function testJSONFileValidity() {
$jsonParseException = new JSONParseException(
$this->contents
);
$this->assertEmpty(
'',
$jsonParseException->getMessage()
);
}
/**
* @depends testJSONFileValidity
*
* @dataProvider defaultSettingsProvider
*/
public function testComparePHP_JSONConfigKeys( $key, $k, $expected ) {
$contents = json_decode( $this->contents, true );
$this->assertEquals(
$expected,
$contents[$key][$k]
);
}
public function defaultSettingsProvider() {
$defaultSettings = \SemanticMediaWiki::getDefaultSettings();
foreach ( $defaultSettings['smwgElasticsearchConfig'] as $key => $configs ) {
if ( $key === 'index_def' ) {
continue;
}
foreach ( $configs as $k => $v ) {
yield "$key-$k" => [ $key, $k, $v ];
}
}
}
}