diff options
author | Yaco <franco@reevo.org> | 2020-06-04 11:01:00 -0300 |
---|---|---|
committer | Yaco <franco@reevo.org> | 2020-06-04 11:01:00 -0300 |
commit | fc7369835258467bf97eb64f184b93691f9a9fd5 (patch) | |
tree | daabd60089d2dd76d9f5fb416b005fbe159c799d /www/wiki/extensions/SemanticFormsSelect/tests |
first commit
Diffstat (limited to 'www/wiki/extensions/SemanticFormsSelect/tests')
10 files changed, 802 insertions, 0 deletions
diff --git a/www/wiki/extensions/SemanticFormsSelect/tests/bootstrap.php b/www/wiki/extensions/SemanticFormsSelect/tests/bootstrap.php new file mode 100644 index 00000000..83339993 --- /dev/null +++ b/www/wiki/extensions/SemanticFormsSelect/tests/bootstrap.php @@ -0,0 +1,29 @@ +<?php + +if ( PHP_SAPI !== 'cli' ) { + die( 'Not an entry point' ); +} + +error_reporting( E_ALL | E_STRICT ); +date_default_timezone_set( 'UTC' ); +ini_set( 'display_errors', 1 ); + +global $IP; + +//if ( !is_readable( $autoloaderClassPath = __DIR__ . '/../../SemanticMediaWiki/tests/autoloader.php' ) ) { +if ( !is_readable( $autoloaderClassPath = $IP . '/extensions/SemanticMediaWiki/tests/autoloader.php' ) ) { + die( "\nThe Semantic MediaWiki test autoloader is not available\n" ); +} + +// if ( !class_exists( 'SemanticFormsSelect' ) || ( $version = SemanticFormsSelect::getVersion() ) === null ) { +if ( ExtensionRegistry::getInstance()->isLoaded( 'SemanticFormsSelect' ) ) { + die( "\nSemantic Forms Select is not available, please check your Composer or LocalSettings.\n" ); +} + +//print sprintf( "\n%-20s%s\n", "Semantic Forms Select: ", ExtensionRegistry::getInstance()->isLoaded( 'SemanticFormsSelect' ) ); +//print sprintf( "%-20s%s\n", "Page Forms: ", SemanticFormsSelect::getVersion( 'PageForms' ) ); + +$autoloader = require $autoloaderClassPath; +//$autoloader->addPsr4( 'SFS\\Tests\\', __DIR__ . '/phpunit/Unit' ); +//$autoloader->addPsr4( 'SFS\\Tests\\Integration\\', __DIR__ . '/phpunit/Integration' ); +unset( $autoloader ); diff --git a/www/wiki/extensions/SemanticFormsSelect/tests/phpunit/Unit/ApiSemanticFormsSelectRequestProcessorTest.php b/www/wiki/extensions/SemanticFormsSelect/tests/phpunit/Unit/ApiSemanticFormsSelectRequestProcessorTest.php new file mode 100644 index 00000000..7c2b292b --- /dev/null +++ b/www/wiki/extensions/SemanticFormsSelect/tests/phpunit/Unit/ApiSemanticFormsSelectRequestProcessorTest.php @@ -0,0 +1,134 @@ +<?php + +namespace SFS\Tests; + +use SFS\ApiSemanticFormsSelectRequestProcessor; +use ApiMain; +use RequestContext; +use WebRequest; +use FauxRequest; + +/** + * @covers \SFS\ApiSemanticFormsSelectRequestProcessor + * @group semantic-forms-select + * + * @license GNU GPL v2+ + * @since 3.0.0 + * + * @author FelixAba + */ +class ApiSemanticFormsSelectRequestProcessorTest + extends \PHPUnit_Framework_TestCase { + + private $ApiSFSRP; + + protected function setUp() { + parent::setUp(); + $parser = $this->getMockBuilder( '\Parser' ) + ->disableOriginalConstructor()->getMock(); + $this->ApiSFSRP = new ApiSemanticFormsSelectRequestProcessor( $parser ); + } + + protected function tearDown() { + unset( $this->ApiSFSRP ); + parent::tearDown(); + } + + public function testCanConstruct() { + $this->assertInstanceOf( + '\SFS\ApiSemanticFormsSelectRequestProcessor', $this->ApiSFSRP + ); + } + + public function testMissingParametersThrowsException() { + + $parameters = []; + + $this->setExpectedException( 'InvalidArgumentException' ); + $this->ApiSFSRP->getJsonDecodedResultValuesForRequestParameters( + $parameters + ); + } + + public function testJsonResultValuesFromRequestParameters() { + + $parameters = [ 'query' => 'foo', 'sep' => ',' ]; + + $this->assertInternalType( + 'object', + $this->ApiSFSRP->getJsonDecodedResultValuesForRequestParameters( + $parameters + ) + ); + } + + public function testJsonResultValuesFromRequestParameters_doProcessQueryFor( + ) { + + $parameters = [ 'approach' => 'smw', 'query' => 'foo, baa, gaah', + 'sep' => ',' ]; + + $this->assertInternalType( + 'object', + $this->ApiSFSRP->getJsonDecodedResultValuesForRequestParameters( + $parameters + ) + ); + } + + public function testSetDebugFlag() { + $this->ApiSFSRP->setDebugFlag( true ); + $parameters = [ 'query' => 'foo , function', 'sep' => ',' ]; + + $this->assertInternalType( + 'object', + $this->ApiSFSRP->getJsonDecodedResultValuesForRequestParameters( + $parameters + ) + ); + } + + public function testSetDebugFlag_doProcessQueryFor() { + $this->ApiSFSRP->setDebugFlag( true ); + $parameters = [ 'approach' => 'smw', 'query' => 'my Query,query2', + 'sep' => ',' ]; + + $this->assertInternalType( + 'object', + $this->ApiSFSRP->getJsonDecodedResultValuesForRequestParameters( + $parameters + ) + ); + } + + public function testGetFormattedValuesFrom() { + $sep = ","; + $values = "my Query,query2"; + $result = [ "", "my Query", "query2" ]; + $formattedValues = $this->invokeMethod( + $this->ApiSFSRP, 'getFormattedValuesFrom', [ $sep, $values ] + ); + $this->assertEquals( $result, $formattedValues ); + } + + /** + * Call protected/private method of a class. + * + * @param object &$object Instantiated object that we will run method on. + * @param string $methodName Method name to call + * @param array $parameters Array of parameters to pass into method. + * + * @return mixed Method return. + */ + public function invokeMethod( &$object, $methodName, + array $parameters = [] + ) { + $reflection = new \ReflectionClass( get_class( $object ) ); + $method = $reflection->getMethod( $methodName ); + $method->setAccessible( true ); + + return $method->invokeArgs( $object, $parameters ); + } + + +} diff --git a/www/wiki/extensions/SemanticFormsSelect/tests/phpunit/Unit/ApiSemanticFormsSelectTest.php b/www/wiki/extensions/SemanticFormsSelect/tests/phpunit/Unit/ApiSemanticFormsSelectTest.php new file mode 100644 index 00000000..30ad86de --- /dev/null +++ b/www/wiki/extensions/SemanticFormsSelect/tests/phpunit/Unit/ApiSemanticFormsSelectTest.php @@ -0,0 +1,95 @@ +<?php + +namespace SFS\Tests; + +use SFS\ApiSemanticFormsSelect; +use ApiMain; +use RequestContext; +use WebRequest; +use FauxRequest; + +/** + * @covers \SFS\ApiSemanticFormsSelect + * @group semantic-forms-select + * + * @license GNU GPL v2+ + * @since 1.3 + * + * @author mwjames + */ +class ApiSemanticFormsSelectTest extends \PHPUnit_Framework_TestCase { + + private $ApiSFS; + private $ApiMain; + + protected function setUp() { + parent::setUp(); + $parameters = [ 'action' => 'sformsselect', 'approach' => 'smw', + 'query' => 'abc', 'sep' => ',' ]; + + $this->ApiMain = new ApiMain( + $this->newRequestContext( $parameters ), true + ); + $this->ApiSFS = new ApiSemanticFormsSelect( + $this->ApiMain, 'sformsselect' + ); + } + + protected function tearDown() { + unset( $this->ApiSFS ); + unset( $this->ApiMain ); + parent::tearDown(); + } + + + public function testCanConstruct() { + + $apiMain = new ApiMain( $this->newRequestContext( [] ), true ); + + $instance = new ApiSemanticFormsSelect( + $apiMain, 'sformsselect' + ); + + $this->assertInstanceOf( + '\SFS\ApiSemanticFormsSelect', $this->ApiSFS + ); + } + + public function testExecute() { + + $this->assertTrue( + $this->ApiSFS->execute() + ); + } + + public function testGetDescription() { + $tdata = [ 'API for providing SemanticFormsSelect values' ]; + $this->assertEquals( $this->ApiSFS->getDescription(), $tdata ); + } + + public function testGetParamDescription() { + $tdata = [ 'approach' => 'The actual approach: function or smw', + 'query' => 'The query of the former' ]; + $this->assertEquals( $this->ApiSFS->getParamDescription(), $tdata ); + } + + public function testGetVersion() { + $tdata = 'SFS\ApiSemanticFormsSelect: 1.1'; + $this->assertEquals( $this->ApiSFS->getVersion(), $tdata ); + } + + + private function newRequestContext( $request = [] ) { + + $context = new RequestContext(); + + if ( $request instanceof WebRequest ) { + $context->setRequest( $request ); + } else { + $context->setRequest( new FauxRequest( $request, true ) ); + } + + return $context; + } + +} diff --git a/www/wiki/extensions/SemanticFormsSelect/tests/phpunit/Unit/OutputTest.php b/www/wiki/extensions/SemanticFormsSelect/tests/phpunit/Unit/OutputTest.php new file mode 100644 index 00000000..7f124267 --- /dev/null +++ b/www/wiki/extensions/SemanticFormsSelect/tests/phpunit/Unit/OutputTest.php @@ -0,0 +1,50 @@ +<?php + +namespace SFS\Tests; + +use SFS\Output; + +/** + * @covers \SFS\Output + * @group semantic-forms-select + * + * @license GNU GPL v2+ + * @since 1.3 + * + * @author mwjames + */ +class OutputTest extends \PHPUnit_Framework_TestCase { + private $data; + + protected function setUp() { + parent::setUp(); + $this->data = []; + $this->data['Foo'] = 'Bar'; + $this->data['Spam'] = 'Eggs'; + } + + protected function tearDown() { + unset( $this->data ); + parent::tearDown(); + } + + public function testCanConstruct() { + $this->assertInstanceOf( '\SFS\Output', new Output() ); + } + + public function testAddToHeadItem() { + $ret = Output::addToHeadItem( $this->data ); + + $this->assertArrayHasKey( 'Foo', $ret ); + $this->assertArrayHasKey( 'Spam', $ret ); + } + + public function testCommitToParserOutput() { + global $wgOut; + $expected_result = '[' . json_encode( $this->data ) . ']'; + Output::commitToParserOutput(); + $this->assertEquals( + $expected_result, $wgOut->getJsConfigVars()['sf_select'] + ); + } +} diff --git a/www/wiki/extensions/SemanticFormsSelect/tests/phpunit/Unit/SelectFieldTest.php b/www/wiki/extensions/SemanticFormsSelect/tests/phpunit/Unit/SelectFieldTest.php new file mode 100644 index 00000000..e69faca3 --- /dev/null +++ b/www/wiki/extensions/SemanticFormsSelect/tests/phpunit/Unit/SelectFieldTest.php @@ -0,0 +1,270 @@ +<?php + +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ + +namespace SFS\Tests; + +use SFS\SelectField; + +use Parser; +use ParserOptions; +use ParserOutput; +use Title; + +/** + * @covers \SFS\SelectField + * @group semantic-forms-select + * @author FelixAba + */ +class SelectFieldTest extends \PHPUnit_Framework_TestCase { + private $SelectField; + private $parser; + // Defined variables + private $other_args_query_parametrized = [ 'query' => '((Category:Building Complex))((Part Of Site::@@@@));?Display Title;format~list;sort~Display Title;sep~,;link~none;headers~hide;limit~500' ]; + private $expected_result_parametrized_setQuery = "[[Category:Building Complex]][[Part Of Site::@@@@]];?Display Title;format=list;sort=Display Title;sep=,;link=none;headers=hide;limit=500"; + private $other_args_query_unparametrized = [ 'query' => '((Category:Building Complex));?Display Title;format~list;sort~Display Title;sep~,;link~none;headers~hide;limit~500' ]; + private $other_args_function_parametrized = [ 'function' => '((Category:Building Complex))((Part Of Site::@@@@));?Display Title;format~list;sort~Display Title;sep~,;link~none;headers~hide;limit~500' ]; + private $expected_result_parametrized_seFunction = '{{#[[Category:Building Complex]][[Part Of Site::@@@@]];?Display Title;format=list;sort=Display Title;sep=,;link=none;headers=hide;limit=500}}'; + private $other_args_function_unparametrized = [ 'function' => 'ask:((Category:Building Complex));?Display Title;format~list;sort~Display Title;sep~@@;link~none;headers~hide;limit~500' ]; + private $expected_result_unparametrized_seFunction = "Building Complex:86543eab-4112-4616-be50-17dcdc24c346 (OFD.AEXH)@@Building Complex:5b9e26f8-6c57-48ff-a6b8-42a4e50fe472 (OFD.AEXH)@@Building Complex:93b076aa-cbe9-4371-8b61-c17c26f1872f (OFD.AMEXH)@@Building Complex:59577450-1582-4d6e-9621-3ac0531a728e (OFD.EEXH)@@Building Complex:1a9bed0b-67de-4e71-8528-f2b6a8907814 (RContiAve.Sport Complex)@@Building Complex:6a2242ea-7536-4a6d-85d2-f2ba4398ef44 (TB.BC)@@Building Complex:2db51fb1-10b6-4d4c-a152-f512914781ff (TB.BD)"; + + public function testCanConstruct() { + + $this->assertInstanceOf( '\SFS\SelectField', $this->SelectField ); + } + + public function testProcessParameters_Query() { + + $this->SelectField->processParameters( + "", $this->other_args_query_parametrized + ); + $this->assertTrue( + array_key_exists( "query", $this->other_args_query_parametrized ) + ); + } + + public function testProcessParameters_Function() { + + $this->SelectField->processParameters( + "", $this->other_args_function_parametrized + ); + $this->assertArrayHasKey( + "function", $this->other_args_function_parametrized + ); + } + + public function testParametrized_setQuery() { + + $this->SelectField->setQuery( $this->other_args_query_parametrized ); + + $this->assertEquals( + $this->expected_result_parametrized_setQuery, + $this->SelectField->getData()['selectquery'] + ); + /* + * Optional Test. + */ + preg_match_all( + "/[~(\(\()(\)\))]+/", $this->SelectField->getData()['selectquery'], + $was_remove + ); + + preg_match_all( + "/[=(\[\[)(\]\])]+/", $this->SelectField->getData()['selectquery'], + $was_replaced + ); + + $this->assertTrue( count( $was_remove[0] ) == 0 ); + $this->assertTrue( count( $was_replaced[0] ) > 0 ); + } + + public function testUnparametrized_setQuery() { + + $this->SelectField->setQuery( $this->other_args_query_unparametrized ); + + $this->assertTrue( $this->SelectField->getValues() !== null ); + $this->assertTrue( $this->SelectField->hasStaticValues() ); + } + + public function testParametrized_setFunction() { + + $this->SelectField->setFunction( + $this->other_args_function_parametrized + ); + $this->assertTrue( + strcmp( + $this->expected_result_parametrized_seFunction, + $this->SelectField->getData()['selectfunction'] + ) == 0 + ); + } + + public function testUnparametrized_setFunction() { + + $this->SelectField->setFunction( + $this->other_args_function_unparametrized + ); + + $this->assertTrue( $this->SelectField->hasStaticValues() ); + } + + public function testSetSelectIsMultiple_keyExistTrue() { + $other_args = [ "part_of_multiple" => "bla bla bla" ]; + $this->SelectField->setSelectIsMultiple( $other_args ); + $this->assertTrue( $this->SelectField->getData()["selectismultiple"] ); + } + + public function testSetSelectIsMultiple_keyExistFalse() { + + $other_args = [ "Not_part_of_multiple" => "blas blas blas" ]; + $this->SelectField->setSelectIsMultiple( $other_args ); + $this->assertFalse( $this->SelectField->getData()["selectismultiple"] ); + } + + public function testSetSelectTemplate_correctData() { + $input_name = "{{#[[Category:Building Complex]][[Part Of Site::@@@@]]"; + $result = "{{#"; + $this->SelectField->setSelectTemplate( $input_name ); + + $this->assertEquals( + $this->SelectField->getData()['selecttemplate'], $result + ); + } + + public function testSetSelectTemplate_wrongData() { + $input_name = "Category:Building Complex"; + $result = ""; + $this->SelectField->setSelectTemplate( $input_name ); + + $this->assertEquals( + $this->SelectField->getData()['selecttemplate'], $result + ); + } + + public function testSetSelectField_correctData() { + $input_name = "{{#[[Category:Building Complex]][[Part Of Site::@@@@]]"; + $result = "Part Of Site::@@@@]"; + + $this->SelectField->setSelectField( $input_name ); + + $this->assertEquals( + $this->SelectField->getData()['selectfield'], $result + ); + } + + public function testSetSelectField_wrongData() { + $input_name = "Category:Building Complex"; + $result = ""; + $this->SelectField->setSelectField( $input_name ); + + $this->assertNotEquals( + $this->SelectField->getData()['selectfield'], $result + ); + } + + public function testSetValueTemplate_containsMselectTemplate() { + $input_name = "{{#[[Category:Building Complex]][[Part Of Site::@@@@]]"; + $other_args = [ "sametemplate" => "test values" ]; + $result = "{{#"; + $this->SelectField->setSelectTemplate( $input_name ); + $this->SelectField->setValueTemplate( $other_args ); + + $this->assertEquals( + $this->SelectField->getData()["valuetemplate"], $result + ); + } + + public function testSetValueTemplate_containsOtherArgsTemplate() { + + $other_args = [ "template" => "test values" ]; + + $this->SelectField->setValueTemplate( $other_args ); + + $this->assertEquals( + $this->SelectField->getData()["valuetemplate"], + $other_args["template"] + ); + } + + public function testSetValueField() { + $other_args = [ "field" => "test values Field" ]; + + $this->SelectField->setValueField( $other_args ); + + $this->assertEquals( + $this->SelectField->getData()["valuefield"], $other_args["field"] + ); + } + + public function testSetSelectRemove_keyExistTrue() { + $other_args = [ 'rmdiv' => "Test data" ]; + $this->SelectField->setSelectRemove( $other_args ); + $this->assertTrue( $this->SelectField->getData()["selectrm"] ); + } + + public function testSetSelectRemove_keyExistFalse() { + + $other_args = [ "no_rmdiv" => "test data" ]; + $this->SelectField->setSelectRemove( $other_args ); + $this->assertFalse( $this->SelectField->getData()["selectrm"] ); + } + + public function testSetLabel_keyExistTrue() { + $other_args = [ 'label' => "Test data" ]; + $this->SelectField->setLabel( $other_args ); + $this->assertTrue( $this->SelectField->getData()["label"] ); + } + + public function testSetLabel_keyExistFalse() { + + $other_args = [ "no_label" => "test data" ]; + $this->SelectField->setLabel( $other_args ); + $this->assertArrayHasKey( "label", $this->SelectField->getData() ); + $this->assertFalse( $this->SelectField->getData()["label"] ); + } + + public function testSetDelimiter_keyExistTrue() { + $other_args = [ "delimiter" => ":" ]; + $this->SelectField->setDelimiter( $other_args ); + $this->assertEquals( + $this->SelectField->getDelimiter(), $other_args["delimiter"] + ); + $this->assertEquals( + $this->SelectField->getData()["sep"], $other_args["delimiter"] + ); + } + + public function testSetWgPageFormsListSeparator_keyExistTrue() { + + $g_args = [ "Global_delimiter" => ";" ]; + $this->SelectField->setDelimiter( $g_args ); + $this->assertEquals( + $this->SelectField->getDelimiter(), $g_args["Global_delimiter"] + ); + $this->assertEquals( + $this->SelectField->getData()["sep"], $g_args["Global_delimiter"] + ); + } + + protected function setUp() { + parent::setUp(); + $this->parser = $GLOBALS['wgParser']; + $this->parser->setTitle( Title::newFromText( 'NO TITLE' ) ); + $this->parser->mOptions = new ParserOptions(); + $this->parser->mOutput = new ParserOutput( + ); // Stored result thats passed back to Parser Object + $this->parser->clearState(); + $this->SelectField = new SelectField( $this->parser ); + } + + protected function tearDown() { + unset( $this->SelectField ); + parent::tearDown(); + } + + +} diff --git a/www/wiki/extensions/SemanticFormsSelect/tests/phpunit/Unit/SemanticFormsSelectInputTest.php b/www/wiki/extensions/SemanticFormsSelect/tests/phpunit/Unit/SemanticFormsSelectInputTest.php new file mode 100644 index 00000000..dac06300 --- /dev/null +++ b/www/wiki/extensions/SemanticFormsSelect/tests/phpunit/Unit/SemanticFormsSelectInputTest.php @@ -0,0 +1,84 @@ +<?php + +namespace SFS\Tests; + +use SFS\SemanticFormsSelectInput; + +/** + * @covers \SFS\SemanticFormsSelectInput + * @group semantic-forms-select + * + * @license GNU GPL v2+ + * @since 3.0.0 + * + * @author FelixAba + */ +class SemanticFormsSelectInputTest extends \PHPUnit_Framework_TestCase { + + private $SFSInput; + + + protected function setUp() { + parent::setUp(); + $value = ''; + $inputName = ''; + $isMandatory = false; + $isDisabled = false; + + $otherArgs = [ 'template' => 'Foo', 'field' => '', + 'function' => 'Bar', 'is_list' => true ]; + + $parserOutput = $this->getMockBuilder( '\ParserOutput' ) + ->disableOriginalConstructor()->getMock(); + + $parser = $this->getMockBuilder( '\Parser' ) + ->disableOriginalConstructor()->getMock(); + + $parser->expects( $this->any() )->method( 'getOutput' )->will( + $this->returnValue( $parserOutput ) + ); + $this->SFSInput = new SemanticFormsSelectInput( + $value, $inputName, $isMandatory, $isDisabled, $otherArgs + ); + } + + protected function tearDown() { + unset( $this->SelectField ); + parent::tearDown(); + } + + public function testCanConstruct() { + + $this->assertInstanceOf( + '\SFS\SemanticFormsSelectInput', $this->SFSInput + ); + } + + public function testGetHTMLText() { + + $this->assertInternalType( + 'string', $this->SFSInput->getHtmlText() + ); + } + + public function testGetName() { + + $this->assertEquals( + 'SF_Select', $this->SFSInput->getName() + ); + } + + public function testGetParameters() { + + $this->assertInternalType( 'array', $this->SFSInput->getParameters() ); + } + + + public function testGetResourceModuleNames() { + $rsmn = [ 'ext.sf_select.scriptselect' ]; + + $this->assertEquals( $rsmn, $this->SFSInput->getResourceModuleNames() ); + } + +} + diff --git a/www/wiki/extensions/SemanticFormsSelect/tests/travis/install-mediawiki.sh b/www/wiki/extensions/SemanticFormsSelect/tests/travis/install-mediawiki.sh new file mode 100644 index 00000000..0fe25fb1 --- /dev/null +++ b/www/wiki/extensions/SemanticFormsSelect/tests/travis/install-mediawiki.sh @@ -0,0 +1,43 @@ +#!/bin/bash +set -ex + +cd .. + +## Use sha (master@5cc1f1d) to download a particular commit to avoid breakages +## introduced by MediaWiki core +if [[ "$MW" == *@* ]] +then + arrMw=(${MW//@/ }) + MW=${arrMw[0]} + SOURCE=${arrMw[1]} +else + MW=$MW + SOURCE=$MW +fi + +wget https://github.com/wikimedia/mediawiki/archive/$SOURCE.tar.gz -O $MW.tar.gz + +tar -zxf $MW.tar.gz +mv mediawiki-* mw + +cd mw + +## MW 1.25+ requires Psr\Logger +if [ -f composer.json ] +then + composer self-update + composer install --prefer-source +fi + +if [ "$DB" == "postgres" ] +then + # See #458 + sudo /etc/init.d/postgresql stop + sudo /etc/init.d/postgresql start + + psql -c 'create database its_a_mw;' -U postgres + php maintenance/install.php --dbtype $DB --dbuser postgres --dbname its_a_mw --pass nyan TravisWiki admin --scriptpath /TravisWiki +else + mysql -e 'create database its_a_mw;' + php maintenance/install.php --dbtype $DB --dbuser root --dbname its_a_mw --dbpath $(pwd) --pass nyan TravisWiki admin --scriptpath /TravisWiki +fi diff --git a/www/wiki/extensions/SemanticFormsSelect/tests/travis/install-semantic-forms-select.sh b/www/wiki/extensions/SemanticFormsSelect/tests/travis/install-semantic-forms-select.sh new file mode 100644 index 00000000..8ebd83b3 --- /dev/null +++ b/www/wiki/extensions/SemanticFormsSelect/tests/travis/install-semantic-forms-select.sh @@ -0,0 +1,73 @@ +#!/bin/bash +set -ex + +BASE_PATH=$(pwd) +MW_INSTALL_PATH=$BASE_PATH/../mw + +# Run Composer installation from the MW root directory +function installToMediaWikiRoot { + echo -e "Running MW root composer install build on $TRAVIS_BRANCH \n" + + cd $MW_INSTALL_PATH + + if [ "$PHPUNIT" != "" ] + then + composer require 'phpunit/phpunit='$PHPUNIT --prefer-source --update-with-dependencies + else + composer require 'phpunit/phpunit=3.7.*' --prefer-source --update-with-dependencies + fi + + if [ "$SFS" != "" ] + then + composer require 'mediawiki/semantic-forms-select='$SMT --prefer-source --update-with-dependencies + else + composer init --stability dev + composer require "mediawiki/semantic-forms-select:dev-master" --prefer-source --dev --update-with-dependencies + + cd extensions + cd SemanticFormsSelect + + # Pull request number, "false" if it's not a pull request + # After the install via composer an additional get fetch is carried out to + # update th repository to make sure that the latests code changes are + # deployed for testing + if [ "$TRAVIS_PULL_REQUEST" != "false" ] + then + git fetch origin +refs/pull/"$TRAVIS_PULL_REQUEST"/merge: + git checkout -qf FETCH_HEAD + else + git fetch origin "$TRAVIS_BRANCH" + git checkout -qf FETCH_HEAD + fi + + cd ../.. + fi + + # Rebuild the class map for added classes during git fetch + composer dump-autoload +} + +function updateConfiguration { + + cd $MW_INSTALL_PATH + + # Site language + if [ "$SITELANG" != "" ] + then + echo '$wgLanguageCode = "'$SITELANG'";' >> LocalSettings.php + fi + + echo 'wfLoadExtension( "PageForms" );' >> LocalSettings.php + echo 'wfLoadExtension( "SemanticFormsSelect" );' >> LocalSettings.php + + echo 'error_reporting(E_ALL| E_STRICT);' >> LocalSettings.php + echo 'ini_set("display_errors", 1);' >> LocalSettings.php + echo '$wgShowExceptionDetails = true;' >> LocalSettings.php + echo '$wgDevelopmentWarnings = true;' >> LocalSettings.php + echo "putenv( 'MW_INSTALL_PATH=$(pwd)' );" >> LocalSettings.php + + php maintenance/update.php --quick +} + +installToMediaWikiRoot +updateConfiguration diff --git a/www/wiki/extensions/SemanticFormsSelect/tests/travis/run-tests.sh b/www/wiki/extensions/SemanticFormsSelect/tests/travis/run-tests.sh new file mode 100644 index 00000000..66104ddd --- /dev/null +++ b/www/wiki/extensions/SemanticFormsSelect/tests/travis/run-tests.sh @@ -0,0 +1,14 @@ +#! /bin/bash +set -ex + +BASE_PATH=$(pwd) +MW_INSTALL_PATH=$BASE_PATH/../mw + +cd $MW_INSTALL_PATH/extensions/SemanticFormsSelect + +if [ "$TYPE" == "coverage" ] +then + composer phpunit -- --coverage-clover $BASE_PATH/build/coverage.clover +else + composer phpunit +fi diff --git a/www/wiki/extensions/SemanticFormsSelect/tests/travis/upload-coverage-report.sh b/www/wiki/extensions/SemanticFormsSelect/tests/travis/upload-coverage-report.sh new file mode 100644 index 00000000..aff95cf7 --- /dev/null +++ b/www/wiki/extensions/SemanticFormsSelect/tests/travis/upload-coverage-report.sh @@ -0,0 +1,10 @@ +#! /bin/bash +set -ex + +BASE_PATH=$(pwd) + +if [ "$TYPE" == "coverage" ] +then + wget https://scrutinizer-ci.com/ocular.phar + php ocular.phar code-coverage:upload --format=php-clover $BASE_PATH/build/coverage.clover +fi
\ No newline at end of file |