Gergő Tisza has uploaded a new change for review.
https://gerrit.wikimedia.org/r/194958
Change subject: Move tests to CommonsMetadata namespace to avoid conflicts
......................................................................
Move tests to CommonsMetadata namespace to avoid conflicts
Change-Id: I6b6e65cc1a179c3d03897138bfef50380ec55e87
---
M tests/phpunit/DataCollectorTest.php
M tests/phpunit/DomNavigatorTest.php
M tests/phpunit/HookHandlerTest.php
M tests/phpunit/LicenseParserTest.php
M tests/phpunit/ParserTestHelper.php
M tests/phpunit/TemplateParserTest.php
6 files changed, 31 insertions(+), 30 deletions(-)
git pull
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/CommonsMetadata
refs/changes/58/194958/1
diff --git a/tests/phpunit/DataCollectorTest.php
b/tests/phpunit/DataCollectorTest.php
index e7cc411..763ecb0 100644
--- a/tests/phpunit/DataCollectorTest.php
+++ b/tests/phpunit/DataCollectorTest.php
@@ -1,23 +1,22 @@
<?php
-use CommonsMetadata\DataCollector;
-use CommonsMetadata\TemplateParser;
+namespace CommonsMetadata;
/**
* @covers CommonsMetadata\DataCollector
* @group Extensions/CommonsMetadata
*/
-class DataCollectorTest extends MediaWikiTestCase {
- /** @var PHPUnit_Framework_MockObject_MockObject */
+class DataCollectorTest extends \MediaWikiTestCase {
+ /** @var \PHPUnit_Framework_MockObject_MockObject */
protected $templateParser;
- /** @var PHPUnit_Framework_MockObject_MockObject */
+ /** @var \PHPUnit_Framework_MockObject_MockObject */
protected $licenseParser;
/** @var DataCollector */
protected $dataCollector;
- /** @var PHPUnit_Framework_MockObject_MockObject */
+ /** @var \PHPUnit_Framework_MockObject_MockObject */
protected $file;
public function setUp() {
@@ -129,7 +128,7 @@
/*------------------------------- Logic tests
--------------------------*/
public function testGetCategoryMetadata() {
- $getCategoryMetadataMethod = new ReflectionMethod(
$this->dataCollector, 'getCategoryMetadata' );
+ $getCategoryMetadataMethod = new \ReflectionMethod(
$this->dataCollector, 'getCategoryMetadata' );
$getCategoryMetadataMethod->setAccessible( true );
$categories = array( 'Foo', 'Bar', 'Pictures of the year
(2012)', 'Pictures of the day (2012)', 'CC-BY-SA-2.0' );
@@ -153,7 +152,7 @@
}
public function testGetTemplateMetadata() {
- $getTemplateMetadataMethod = new ReflectionMethod(
$this->dataCollector, 'getTemplateMetadata' );
+ $getTemplateMetadataMethod = new \ReflectionMethod(
$this->dataCollector, 'getTemplateMetadata' );
$getTemplateMetadataMethod->setAccessible( true );
$this->licenseParser->expects( $this->any() )
@@ -180,7 +179,7 @@
}
public function testGetTemplateMetadataForMultipleInfoTemplates() {
- $getTemplateMetadataMethod = new ReflectionMethod(
$this->dataCollector, 'getTemplateMetadata' );
+ $getTemplateMetadataMethod = new \ReflectionMethod(
$this->dataCollector, 'getTemplateMetadata' );
$getTemplateMetadataMethod->setAccessible( true );
$template1 = array( 'Artist' => 'a1', 'Foo' => 'x' );
diff --git a/tests/phpunit/DomNavigatorTest.php
b/tests/phpunit/DomNavigatorTest.php
index 97c20fe..805b743 100644
--- a/tests/phpunit/DomNavigatorTest.php
+++ b/tests/phpunit/DomNavigatorTest.php
@@ -1,12 +1,12 @@
<?php
-use CommonsMetadata\DomNavigator;
+namespace CommonsMetadata;
/**
* @covers CommonsMetadata\DomNavigator
* @group Extensions/CommonsMetadata
*/
-class DomNavigatorTest extends MediaWikiTestCase {
+class DomNavigatorTest extends \MediaWikiTestCase {
public function testHasClass() {
$navigator = new DomNavigator( '<span class="foo"></span>' );
$node = $navigator->getByXpath( '//body/*' );
@@ -188,10 +188,10 @@
/**
* Asserts the text of nodes in a result set agains strings in an array.
* @param array $expected
- * @param DOMElement[]|DomNodeList $nodes
+ * @param \DomNodeList $nodes
* @param string $message
*/
- protected function assertNodeListTextEquals( array $expected,
DOMNodeList $nodes, $message = '' ) {
+ protected function assertNodeListTextEquals( array $expected,
\DOMNodeList $nodes, $message = '' ) {
$this->assertEquals( count( $expected ) , $nodes->length );
foreach ( $expected as $i => $text ) {
$this->assertEquals( $text, $nodes->item( $i
)->textContent, $message ?: "Failed to assert that text of node $i equals
'$text'" );
@@ -202,10 +202,10 @@
* Asserts a given attribute of nodes in a result set agains strings in
an array.
* @param string $attributeName
* @param array $expected
- * @param DOMElement[]|DomNodeList $nodes
+ * @param \DomNodeList $nodes
* @param string $message
*/
- protected function assertNodeListAttributeEquals( $attributeName, array
$expected, DOMNodeList $nodes, $message = '' ) {
+ protected function assertNodeListAttributeEquals( $attributeName, array
$expected, \DOMNodeList $nodes, $message = '' ) {
$this->assertEquals( count( $expected ) , $nodes->length );
foreach ( $expected as $i => $attr ) {
$node = $nodes->item( $i );
diff --git a/tests/phpunit/HookHandlerTest.php
b/tests/phpunit/HookHandlerTest.php
index c5ddd99..3ec0e9b 100644
--- a/tests/phpunit/HookHandlerTest.php
+++ b/tests/phpunit/HookHandlerTest.php
@@ -1,6 +1,6 @@
<?php
-use CommonsMetadata\HookHandler;
+namespace CommonsMetadata;
require_once __DIR__ . "/ParserTestHelper.php";
@@ -8,7 +8,7 @@
* @covers CommonsMetadata\HookHandler
* @group Extensions/CommonsMetadata
*/
-class HookHandlerTest extends PHPUnit_Framework_TestCase {
+class HookHandlerTest extends \PHPUnit_Framework_TestCase {
/** @var ParserTestHelper */
protected $parserTestHelper;
diff --git a/tests/phpunit/LicenseParserTest.php
b/tests/phpunit/LicenseParserTest.php
index d81a60c..0dc4f00 100644
--- a/tests/phpunit/LicenseParserTest.php
+++ b/tests/phpunit/LicenseParserTest.php
@@ -1,12 +1,12 @@
<?php
-use CommonsMetadata\LicenseParser;
+namespace CommonsMetadata;
/**
* @covers CommonsMetadata\LicenseParser
* @group Extensions/CommonsMetadata
*/
-class LicenseParserTest extends MediaWikiTestCase {
+class LicenseParserTest extends \MediaWikiTestCase {
/** @var LicenseParser */
protected $licenseParser;
@@ -266,7 +266,7 @@
}
protected function assertLicenseHasGreaterPriority(
$greaterLicenseData, $smallerLicenseData ) {
- $getLicensePriorityMethod = new ReflectionMethod(
$this->licenseParser, 'getLicensePriority' );
+ $getLicensePriorityMethod = new \ReflectionMethod(
$this->licenseParser, 'getLicensePriority' );
$getLicensePriorityMethod->setAccessible( true );
$greaterLicensePriority =
$getLicensePriorityMethod->invokeArgs( $this->licenseParser, array(
$greaterLicenseData ) );
$smallerLicensePriority =
$getLicensePriorityMethod->invokeArgs( $this->licenseParser, array(
$smallerLicenseData ) );
diff --git a/tests/phpunit/ParserTestHelper.php
b/tests/phpunit/ParserTestHelper.php
index 5265220..8527b2f 100644
--- a/tests/phpunit/ParserTestHelper.php
+++ b/tests/phpunit/ParserTestHelper.php
@@ -1,5 +1,7 @@
<?php
+namespace CommonsMetadata;
+
class ParserTestHelper {
/**
* Maps test names to filenames in the test subdirectory.
@@ -49,12 +51,12 @@
);
/**
- * @var PHPUnit_Framework_TestCase
+ * @var \PHPUnit_Framework_TestCase
*/
protected $testCase;
/**
- * @param PHPUnit_Framework_TestCase $testCase
+ * @param \PHPUnit_Framework_TestCase $testCase
*/
public function setTestCase( $testCase ) {
$this->testCase = $testCase;
@@ -82,7 +84,7 @@
/**
* Loads an expected metadata test result.
* @param $name
- * @throws InvalidArgumentException
+ * @throws \InvalidArgumentException
* @return array
*/
public function getMetadata( $name ) {
@@ -101,7 +103,7 @@
/**
* @param string $description file page text
* @param string[] $categories list of category names, without namespace
- * @return LocalFile
+ * @return \LocalFile
*/
public function getLocalFile( $description, $categories ) {
$file = $this->testCase->getMockBuilder( 'LocalFile' )
@@ -123,7 +125,7 @@
/**
* @param string $description file page text
- * @return ForeignAPIFile
+ * @return \ForeignAPIFile
*/
public function getForeignApiFile( $description ) {
$file = $this->testCase->getMockBuilder( 'ForeignAPIFile' )
@@ -144,7 +146,7 @@
/**
* @param string $description file page text
* @param string[] $categories list of category names, without namespace
- * @return ForeignDBFile
+ * @return \ForeignDBFile
*/
public function getForeignDbFile( $description, $categories ) {
$file = $this->testCase->getMockBuilder( 'ForeignDbFile' )
@@ -166,10 +168,10 @@
/**
* @param string $languageCode
- * @return IContextSource
+ * @return \IContextSource
*/
public function getContext( $languageCode ) {
- $language = Language::factory( $languageCode );
+ $language = \Language::factory( $languageCode );
$context = $this->testCase->getMockBuilder( 'IContextSource' )
->disableOriginalConstructor()
->getMock();
diff --git a/tests/phpunit/TemplateParserTest.php
b/tests/phpunit/TemplateParserTest.php
index e6f5325..75ae9aa 100644
--- a/tests/phpunit/TemplateParserTest.php
+++ b/tests/phpunit/TemplateParserTest.php
@@ -1,6 +1,6 @@
<?php
-use CommonsMetadata\TemplateParser;
+namespace CommonsMetadata;
require_once __DIR__ . "/ParserTestHelper.php";
@@ -8,7 +8,7 @@
* @covers CommonsMetadata\TemplateParser
* @group Extensions/CommonsMetadata
*/
-class TemplateParserTest extends MediaWikiTestCase {
+class TemplateParserTest extends \MediaWikiTestCase {
/**
* Make sure there are no errors when common HTML structures are
missing.
*/
--
To view, visit https://gerrit.wikimedia.org/r/194958
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I6b6e65cc1a179c3d03897138bfef50380ec55e87
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/CommonsMetadata
Gerrit-Branch: master
Gerrit-Owner: Gergő Tisza <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits