Addshore has uploaded a new change for review. ( https://gerrit.wikimedia.org/r/359915 )
Change subject: DNM DEBUGGING test failure ...................................................................... DNM DEBUGGING test failure Change-Id: Idc000a02e055f8613f664ee40d073bb58390d533 --- M tests/phpunit/SpecialImportFileIntegrationTest.php A tests/phpunit/TestTest.php 2 files changed, 135 insertions(+), 77 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/FileImporter refs/changes/15/359915/1 diff --git a/tests/phpunit/SpecialImportFileIntegrationTest.php b/tests/phpunit/SpecialImportFileIntegrationTest.php index 8c118af..0edb8a2 100644 --- a/tests/phpunit/SpecialImportFileIntegrationTest.php +++ b/tests/phpunit/SpecialImportFileIntegrationTest.php @@ -29,7 +29,6 @@ $hashSiteStore = new HashSiteStore( [ $commonsSite ] ); $siteTableSiteLookup = new SiteTableSiteLookup( $hashSiteStore ); $this->setService( 'FileImporterMediaWikiSiteTableSiteLookup', $siteTableSiteLookup ); - $this->tablesUsed[] = 'user_groups'; } private function getMockSite( $globalId, $domain ) { @@ -57,16 +56,18 @@ public function provideTestData() { return [ - 'Anon user, Expect Groups required' => [ - new FauxRequest(), - new User(), - [ - 'name' => PermissionsError::class, - 'message' => 'The action you have requested is limited to users in one of the groups', - ], - function(){ - } - ], + +// 'Anon user, Expect Groups required' => [ +// new FauxRequest(), +// new User(), +// [ +// 'name' => PermissionsError::class, +// 'message' => 'The action you have requested is limited to users in one of the groups', +// ], +// function(){ +// } +// ], + 'Uploader, Expect input form' => [ new FauxRequest(), true, @@ -75,72 +76,73 @@ $this->assertInitialInputFormPreset( $html ); } ], - 'Bad domain (not in allowed sites)' => [ - new FauxRequest( [ - 'clientUrl' => 'https://test.wikimedia.org/wiki/File:AnyFile.JPG' - ] ), - true, - null, - function( $html ) { - $this->assertInitialInputFormPreset( $html ); - $this->assertWarningBox( $html, 'Can\'t import the given URL' ); - } - ], - 'Bad domain (malformed?)' => [ - new FauxRequest( [ - 'clientUrl' => 't243ju89gujwe9fjka09jg' - ] ), - true, - null, - function( $html ) { - $this->assertInitialInputFormPreset( $html ); - $this->assertWarningBox( $html, 'Can\'t import the given URL' ); - } - ], - 'Bad file' => [ - new FauxRequest( [ - 'clientUrl' => 'https://commons.wikimedia.org/wiki/ThisIsNotAFileFooBarBarBar' - ] ), - true, - null, - function( $html ) { - $this->assertInitialInputFormPreset( $html ); - $this->assertWarningBox( - $html, - 'File not found: https://commons.wikimedia.org/wiki/ThisIsNotAFileFooBarBarBar' - ); - } - ], - 'Good file' => [ - new FauxRequest( [ - 'clientUrl' => 'https://commons.wikimedia.org/wiki/File:Chicken_In_Snow.JPG', - ] ), - true, - null, - function( $html ) { - $this->assertPreviewPage( - $html, - 'https://commons.wikimedia.org/wiki/File:Chicken_In_Snow.JPG', - 'Chicken In Snow.JPG' - ); - } - ], - 'Good file & Good target title' => [ - new FauxRequest( [ - 'clientUrl' => 'https://commons.wikimedia.org/wiki/File:Chicken_In_Snow.JPG', - 'intendedFileName' => 'Chicken In Snow CHANGED', - 'importDetailsHash' => 'SomeHash',// XXX: This is currently not checked? - ] ), - true, - null, - function( $html ) { - $this->assertPreviewPage( - $html, - 'https://commons.wikimedia.org/wiki/File:Chicken_In_Snow.JPG', - 'Chicken In Snow CHANGED.JPG' - ); - } - ], + +// 'Bad domain (not in allowed sites)' => [ +// new FauxRequest( [ +// 'clientUrl' => 'https://test.wikimedia.org/wiki/File:AnyFile.JPG' +// ] ), +// true, +// null, +// function( $html ) { +// $this->assertInitialInputFormPreset( $html ); +// $this->assertWarningBox( $html, 'Can\'t import the given URL' ); +// } +// ], +// 'Bad domain (malformed?)' => [ +// new FauxRequest( [ +// 'clientUrl' => 't243ju89gujwe9fjka09jg' +// ] ), +// true, +// null, +// function( $html ) { +// $this->assertInitialInputFormPreset( $html ); +// $this->assertWarningBox( $html, 'Can\'t import the given URL' ); +// } +// ], +// 'Bad file' => [ +// new FauxRequest( [ +// 'clientUrl' => 'https://commons.wikimedia.org/wiki/ThisIsNotAFileFooBarBarBar' +// ] ), +// true, +// null, +// function( $html ) { +// $this->assertInitialInputFormPreset( $html ); +// $this->assertWarningBox( +// $html, +// 'File not found: https://commons.wikimedia.org/wiki/ThisIsNotAFileFooBarBarBar' +// ); +// } +// ], +// 'Good file' => [ +// new FauxRequest( [ +// 'clientUrl' => 'https://commons.wikimedia.org/wiki/File:Chicken_In_Snow.JPG', +// ] ), +// true, +// null, +// function( $html ) { +// $this->assertPreviewPage( +// $html, +// 'https://commons.wikimedia.org/wiki/File:Chicken_In_Snow.JPG', +// 'Chicken In Snow.JPG' +// ); +// } +// ], +// 'Good file & Good target title' => [ +// new FauxRequest( [ +// 'clientUrl' => 'https://commons.wikimedia.org/wiki/File:Chicken_In_Snow.JPG', +// 'intendedFileName' => 'Chicken In Snow CHANGED', +// 'importDetailsHash' => 'SomeHash',// XXX: This is currently not checked? +// ] ), +// true, +// null, +// function( $html ) { +// $this->assertPreviewPage( +// $html, +// 'https://commons.wikimedia.org/wiki/File:Chicken_In_Snow.JPG', +// 'Chicken In Snow CHANGED.JPG' +// ); +// } +// ], ]; } diff --git a/tests/phpunit/TestTest.php b/tests/phpunit/TestTest.php new file mode 100644 index 0000000..d602519 --- /dev/null +++ b/tests/phpunit/TestTest.php @@ -0,0 +1,56 @@ +<?php + +namespace FileImporter\Test; + +use User; +use UserGroupMembership; + +/** + * @group Database + * + * TestSuite::run + * MediaWikiTestCase::setUpBeforeClass + * MediaWikiTestCase::run + * MediaWikiTestCase::setupAllTestDBs + * parent::run (phpunit testcase) + * TestCase::setUp + * (overrideMwServices called as a result of using setService) + * TestCase::test + * (overrideMwServices caused a new services instance, & thus new db connections?) + * + * SOLUTIONS: + * - Move the set service stuff to setupBeforeClass! + * - Requires things to be statically accessible for reseting services. + * - This would actually be needed every time overrideMwServices is called though? <<<<< + * Other things to do: + * - Move db setup to setupBeforeClass too?! + * */ +class TestTest extends \MediaWikiTestCase { + + public function setUp() { + parent::setUp(); + + // As a result of setService + $this->overrideMwServices(); + + // testCase->run + // testCase->setupBeforeClass + // testCase->setupAllTestDBs + // testCase::setupTestDB + // testCase::setupDatabaseWithTestPrefix + // parent::run + // TestCase::run + // TestCase::runTest + + // setUp -> testCase->setService + // testCase->overrideMwServices + // MediaWikiServices::forceGlobalInstance( $newInstance ); + } + + public function testTest() { + $user = User::newFromName( 'Admin' ); + UserGroupMembership::getMembershipsForUser( $user ); + $this->assertTrue( true ); + } + +} -- To view, visit https://gerrit.wikimedia.org/r/359915 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Idc000a02e055f8613f664ee40d073bb58390d533 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/FileImporter Gerrit-Branch: master Gerrit-Owner: Addshore <addshorew...@gmail.com> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits