<?php
class XmlTest extends MediaWikiTestCase {
- private static $oldLang;
- private static $oldNamespaces;
protected function setUp() {
parent::setUp();
) );
}
+ /**
+ * @covers Xml::expandAttributes
+ */
public function testExpandAttributes() {
$this->assertNull( Xml::expandAttributes( null ),
'Converting a null list of attributes'
);
}
+ /**
+ * @covers Xml::expandAttributes
+ */
public function testExpandAttributesException() {
$this->setExpectedException( 'MWException' );
Xml::expandAttributes( 'string' );
}
+ /**
+ * @covers Xml::element
+ */
function testElementOpen() {
$this->assertEquals(
'<element>',
);
}
+ /**
+ * @covers Xml::element
+ */
function testElementEmpty() {
$this->assertEquals(
'<element />',
);
}
+ /**
+ * @covers Xml::input
+ */
function testElementInputCanHaveAValueOfZero() {
$this->assertEquals(
'<input name="name" value="0" />',
);
}
+ /**
+ * @covers Xml::element
+ */
function testElementEscaping() {
$this->assertEquals(
'<element>hello <there> you & you</element>',
);
}
+ /**
+ * @covers Xml::escapeTagsOnly
+ */
public function testEscapeTagsOnly() {
$this->assertEquals( '"><', Xml::escapeTagsOnly( '"><' ),
'replace " > and < with their HTML entitites'
);
}
+ /**
+ * @covers Xml::element
+ */
function testElementAttributes() {
$this->assertEquals(
'<element key="value" <>="<>">',
);
}
+ /**
+ * @covers Xml::openElement
+ */
function testOpenElement() {
$this->assertEquals(
'<element k="v">',
);
}
+ /**
+ * @covers Xml::closeElement
+ */
function testCloseElement() {
$this->assertEquals( '</element>', Xml::closeElement( 'element' ), 'closeElement() shortcut' );
}
+ /**
+ * @covers Xml::dateMenu
+ */
public function testDateMenu() {
$curYear = intval( gmdate( 'Y' ) );
$prevYear = $curYear - 1;
);
}
- #
- # textarea
- #
+ /**
+ * @covers Xml::textarea
+ */
function testTextareaNoContent() {
$this->assertEquals(
'<textarea name="name" id="name" cols="40" rows="5"></textarea>',
);
}
+ /**
+ * @covers Xml::textarea
+ */
function testTextareaAttribs() {
$this->assertEquals(
'<textarea name="name" id="name" cols="20" rows="10"><txt></textarea>',
);
}
- #
- # input and label
- #
+ /**
+ * @covers Xml::label
+ */
function testLabelCreation() {
$this->assertEquals(
'<label for="id">name</label>',
);
}
+ /**
+ * @covers Xml::label
+ */
function testLabelAttributeCanOnlyBeClassOrTitle() {
$this->assertEquals(
'<label for="id">name</label>',
);
}
+ /**
+ * @covers Xml::languageSelector
+ */
function testLanguageSelector() {
$select = Xml::languageSelector( 'en', true, null,
array( 'id' => 'testlang' ), wfMessage( 'yourlanguage' ) );
);
}
- #
- # JS
- #
+ /**
+ * @covers Xml::escapeJsString
+ */
function testEscapeJsStringSpecialChars() {
$this->assertEquals(
'\\\\\r\n',
);
}
+ /**
+ * @covers Xml::encodeJsVar
+ */
function testEncodeJsVarBoolean() {
$this->assertEquals(
'true',
);
}
+ /**
+ * @covers Xml::encodeJsVar
+ */
function testEncodeJsVarNull() {
$this->assertEquals(
'null',
);
}
+ /**
+ * @covers Xml::encodeJsVar
+ */
function testEncodeJsVarArray() {
$this->assertEquals(
'["a",1]',
);
}
+ /**
+ * @covers Xml::encodeJsVar
+ */
function testEncodeJsVarObject() {
$this->assertEquals(
'{"a":"a","b":1}',
);
}
+ /**
+ * @covers Xml::encodeJsVar
+ */
function testEncodeJsVarInt() {
$this->assertEquals(
'123456',
);
}
+ /**
+ * @covers Xml::encodeJsVar
+ */
function testEncodeJsVarFloat() {
$this->assertEquals(
'1.23456',
);
}
+ /**
+ * @covers Xml::encodeJsVar
+ */
function testEncodeJsVarIntString() {
$this->assertEquals(
'"123456"',
);
}
+ /**
+ * @covers Xml::encodeJsVar
+ */
function testEncodeJsVarFloatString() {
$this->assertEquals(
'"1.23456"',
<?php
+/**
+ * @covers ZipDirectoryReader
+ * NOTE: this test is more like an integration test than a unit test
+ */
class ZipDirectoryReaderTest extends MediaWikiTestCase {
var $zipDir, $entries;
* @group medium
*/
class FileBackendTest extends MediaWikiTestCase {
- private $backend, $multiBackend;
+
+ /** @var FileBackend */
+ private $backend;
+ /** @var FileBackendMultiWrite */
+ private $multiBackend;
+ /** @var FSFileBackend */
+ public $singleBackend;
private $filesToPrune = array();
private static $backendToUse;
/**
* @dataProvider provider_testIsStoragePath
+ * @covers FileBackend::isStoragePath
*/
public function testIsStoragePath( $path, $isStorePath ) {
$this->assertEquals( $isStorePath, FileBackend::isStoragePath( $path ),
/**
* @dataProvider provider_testSplitStoragePath
+ * @covers FileBackend::splitStoragePath
*/
public function testSplitStoragePath( $path, $res ) {
$this->assertEquals( $res, FileBackend::splitStoragePath( $path ),
/**
* @dataProvider provider_normalizeStoragePath
+ * @covers FileBackend::normalizeStoragePath
*/
public function testNormalizeStoragePath( $path, $res ) {
$this->assertEquals( $res, FileBackend::normalizeStoragePath( $path ),
/**
* @dataProvider provider_testParentStoragePath
+ * @covers FileBackend::parentStoragePath
*/
public function testParentStoragePath( $path, $res ) {
$this->assertEquals( $res, FileBackend::parentStoragePath( $path ),
/**
* @dataProvider provider_testExtensionFromPath
+ * @covers FileBackend::extensionFromPath
*/
public function testExtensionFromPath( $path, $res ) {
$this->assertEquals( $res, FileBackend::extensionFromPath( $path ),
$this->tearDownFiles();
}
+ /**
+ * @covers FileBackend::doOperation
+ */
private function doTestStore( $op ) {
$backendName = $this->backendClass();
/**
* @dataProvider provider_testCopy
+ * @covers FileBackend::doOperation
*/
public function testCopy( $op ) {
$this->backend = $this->singleBackend;
/**
* @dataProvider provider_testMove
+ * @covers FileBackend::doOperation
*/
public function testMove( $op ) {
$this->backend = $this->singleBackend;
/**
* @dataProvider provider_testDelete
+ * @covers FileBackend::doOperation
*/
public function testDelete( $op, $withSource, $okStatus ) {
$this->backend = $this->singleBackend;
/**
* @dataProvider provider_testDescribe
+ * @covers FileBackend::doOperation
*/
public function testDescribe( $op, $withSource, $okStatus ) {
$this->backend = $this->singleBackend;
/**
* @dataProvider provider_testCreate
+ * @covers FileBackend::doOperation
*/
public function testCreate( $op, $alreadyExists, $okStatus, $newSize ) {
$this->backend = $this->singleBackend;
return $cases;
}
+ /**
+ * @covers FileBackend::doQuickOperations
+ */
public function testDoQuickOperations() {
$this->backend = $this->singleBackend;
$this->doTestDoQuickOperations();
/**
* @dataProvider provider_testGetFileStat
+ * @covers FileBackend::getFileStat
*/
public function testGetFileStat( $path, $content, $alreadyExists ) {
$this->backend = $this->singleBackend;
/**
* @dataProvider provider_testGetFileContents
+ * @covers FileBackend::getFileContents
+ * @covers FileBackend::getFileContentsMulti
*/
public function testGetFileContents( $source, $content ) {
$this->backend = $this->singleBackend;
/**
* @dataProvider provider_testGetLocalCopy
+ * @covers FileBackend::getLocalCopy
*/
public function testGetLocalCopy( $source, $content ) {
$this->backend = $this->singleBackend;
/**
* @dataProvider provider_testGetLocalReference
+ * @covers FileBackend::getLocalReference
*/
public function testGetLocalReference( $source, $content ) {
$this->backend = $this->singleBackend;
return $cases;
}
+ /**
+ * @covers FileBackend::getLocalCopy
+ * @covers FileBackend::getLocalReference
+ */
public function testGetLocalCopyAndReference404() {
$this->backend = $this->singleBackend;
$this->tearDownFiles();
/**
* @dataProvider provider_testGetFileHttpUrl
+ * @covers FileBackend::getFileHttpUrl
*/
public function testGetFileHttpUrl( $source, $content ) {
$this->backend = $this->singleBackend;
/**
* @dataProvider provider_testPrepareAndClean
+ * @covers FileBackend::prepare
+ * @covers FileBackend::clean
*/
public function testPrepareAndClean( $path, $isOK ) {
$this->backend = $this->singleBackend;
$this->tearDownFiles();
}
+ /**
+ * @covers FileBackend::clean
+ */
private function doTestRecursiveClean() {
$backendName = $this->backendClass();
// @todo testSecure
+ /**
+ * @covers FileBackend::doOperations
+ */
public function testDoOperations() {
$this->backend = $this->singleBackend;
$this->tearDownFiles();
"Correct file SHA-1 of $fileC" );
}
+ /**
+ * @covers FileBackend::doOperations
+ */
public function testDoOperationsPipeline() {
$this->backend = $this->singleBackend;
$this->tearDownFiles();
"Correct file SHA-1 of $fileC" );
}
+ /**
+ * @covers FileBackend::doOperations
+ */
public function testDoOperationsFailing() {
$this->backend = $this->singleBackend;
$this->tearDownFiles();
"Correct file SHA-1 of $fileA" );
}
+ /**
+ * @covers FileBackend::getFileList
+ */
public function testGetFileList() {
$this->backend = $this->singleBackend;
$this->tearDownFiles();
}
}
+ /**
+ * @covers FileBackend::getTopDirectoryList
+ * @covers FileBackend::getDirectoryList
+ */
public function testGetDirectoryList() {
$this->backend = $this->singleBackend;
$this->tearDownFiles();
$this->assertEquals( array(), $items, "Directory listing is empty." );
}
+ /**
+ * @covers FileBackend::lockFiles
+ * @covers FileBackend::unlockFiles
+ */
public function testLockCalls() {
$this->backend = $this->singleBackend;
$this->doTestLockCalls();
<?php
class FileRepoTest extends MediaWikiTestCase {
+
/**
* @expectedException MWException
+ * @covers FileRepo::__construct
*/
function testFileRepoConstructionOptionCanNotBeNull() {
new FileRepo();
/**
* @expectedException MWException
+ * @covers FileRepo::__construct
*/
function testFileRepoConstructionOptionCanNotBeAnEmptyArray() {
new FileRepo( array() );
/**
* @expectedException MWException
+ * @covers FileRepo::__construct
*/
function testFileRepoConstructionOptionNeedNameKey() {
new FileRepo( array(
/**
* @expectedException MWException
+ * @covers FileRepo::__construct
*/
function testFileRepoConstructionOptionNeedBackendKey() {
new FileRepo( array(
) );
}
+ /**
+ * @covers FileRepo::__construct
+ */
function testFileRepoConstructionWithRequiredOptions() {
$f = new FileRepo( array(
'name' => 'FileRepoTestRepository',
<?php
+
/**
* @group FileRepo
* @group medium
*/
class StoreBatchTest extends MediaWikiTestCase {
+ protected $createdFiles;
+ protected $date;
+ /** @var FileRepo */
+ protected $repo;
+
protected function setUp() {
global $wgFileBackends;
parent::setUp();
* @param $originalName string The title of the image
* @param $srcPath string The filepath or virtual URL
* @param $flags integer Flags to pass into repo::store().
+ * @return FileRepoStatus
*/
private function storeit( $originalName, $srcPath, $flags ) {
$hashPath = $this->repo->getHashPath( $originalName );
* @param $fn string The title of the image
* @param $infn string The name of the file (in the filesystem)
* @param $otherfn string The name of the different file (in the filesystem)
- * @param $fromrepo logical 'true' if we want to copy from a virtual URL out of the Repo.
+ * @param $fromrepo bool 'true' if we want to copy from a virtual URL out of the Repo.
*/
private function storecohort( $fn, $infn, $otherfn, $fromrepo ) {
$f = $this->storeit( $fn, $infn, 0 );
$this->assertEquals( $f->successCount, 0, "counts wrong {$f->successCount} {$f->failCount}" );
}
+ /**
+ * @covers FileRepo::store
+ */
public function teststore() {
global $IP;
$this->storecohort( "Test1.png", "$IP/skins/monobook/wiki.png", "$IP/skins/monobook/video.png", false );
/**
* @dataProvider provideOracleConnectStrings
+ * @covers OracleInstaller::checkConnectStringFormat
*/
function testCheckConnectStringFormat( $expected, $connectString, $msg = '' ) {
$validity = $expected ? 'should be valid' : 'should NOT be valid';
/**
* @dataProvider fileUrlProvider
+ * @covers MediaWikiSite::getFileUrl
*/
public function testGetFileUrl( $url, $filePath, $pathArgument, $expected ) {
$site = new MediaWikiSite();
/**
* @dataProvider provideGetPageUrl
+ * @covers MediaWikiSite::getPageUrl
*/
public function testGetPageUrl( $path, $page, $expected ) {
$site = new MediaWikiSite();
/**
* @dataProvider siteListProvider
* @param SiteList $sites
+ * @covers SiteList::isEmpty
*/
public function testIsEmpty( SiteList $sites ) {
$this->assertEquals( count( $sites ) === 0, $sites->isEmpty() );
/**
* @dataProvider siteListProvider
* @param SiteList $sites
+ * @covers SiteList::getSite
*/
public function testGetSiteByGlobalId( SiteList $sites ) {
if ( $sites->isEmpty() ) {
/**
* @dataProvider siteListProvider
* @param SiteList $sites
+ * @covers SiteList::getSiteByInternalId
*/
public function testGetSiteByInternalId( $sites ) {
/**
/**
* @dataProvider siteListProvider
* @param SiteList $sites
+ * @covers SiteList::hasSite
*/
public function testHasGlobalId( $sites ) {
$this->assertFalse( $sites->hasSite( 'non-existing-global-id' ) );
/**
* @dataProvider siteListProvider
* @param SiteList $sites
+ * @covers SiteList::hasInternalId
*/
public function testHasInternallId( $sites ) {
/**
/**
* @dataProvider siteListProvider
* @param SiteList $sites
+ * @covers SiteList::getGlobalIdentifiers
*/
public function testGetGlobalIdentifiers( SiteList $sites ) {
$identifiers = $sites->getGlobalIdentifiers();
* @since 1.21
*
* @param SiteList $list
+ * @covers SiteList::getSerializationData
+ * @covers SiteList::unserialize
*/
public function testSerialization( SiteList $list ) {
$serialization = serialize( $list );
*/
class SiteSQLStoreTest extends MediaWikiTestCase {
+ /**
+ * @covers SiteSQLStore::getSites
+ */
public function testGetSites() {
$expectedSites = TestSites::getSites();
TestSites::insertIntoDb();
}
}
+ /**
+ * @covers SiteSQLStore::saveSites
+ */
public function testSaveSites() {
$store = SiteSQLStore::newInstance();
$this->assertTrue( $site->getInternalId() >= 0 );
}
+ /**
+ * @covers SiteSQLStore::reset
+ */
public function testReset() {
$store1 = SiteSQLStore::newInstance();
$store2 = SiteSQLStore::newInstance();
$this->assertNull( $site );
}
+ /**
+ * @covers SiteSQLStore::clear
+ */
public function testClear() {
$store = SiteSQLStore::newInstance();
$this->assertTrue( $store->clear() );
/**
* @dataProvider instanceProvider
* @param Site $site
+ * @covers Site::getInterwikiIds
*/
public function testGetInterwikiIds( Site $site ) {
$this->assertInternalType( 'array', $site->getInterwikiIds() );
/**
* @dataProvider instanceProvider
* @param Site $site
+ * @covers Site::getNavigationIds
*/
public function testGetNavigationIds( Site $site ) {
$this->assertInternalType( 'array', $site->getNavigationIds() );
/**
* @dataProvider instanceProvider
* @param Site $site
+ * @covers Site::addNavigationId
*/
public function testAddNavigationId( Site $site ) {
$site->addNavigationId( 'foobar' );
/**
* @dataProvider instanceProvider
* @param Site $site
+ * @covers Site::addInterwikiId
*/
public function testAddInterwikiId( Site $site ) {
$site->addInterwikiId( 'foobar' );
/**
* @dataProvider instanceProvider
* @param Site $site
+ * @covers Site::getLanguageCode
*/
public function testGetLanguageCode( Site $site ) {
$this->assertTypeOrValue( 'string', $site->getLanguageCode(), null );
/**
* @dataProvider instanceProvider
* @param Site $site
+ * @covers Site::setLanguageCode
*/
public function testSetLanguageCode( Site $site ) {
$site->setLanguageCode( 'en' );
/**
* @dataProvider instanceProvider
* @param Site $site
+ * @covers Site::normalizePageName
*/
public function testNormalizePageName( Site $site ) {
$this->assertInternalType( 'string', $site->normalizePageName( 'Foobar' ) );
/**
* @dataProvider instanceProvider
* @param Site $site
+ * @covers Site::getGlobalId
*/
public function testGetGlobalId( Site $site ) {
$this->assertTypeOrValue( 'string', $site->getGlobalId(), null );
/**
* @dataProvider instanceProvider
* @param Site $site
+ * @covers Site::setGlobalId
*/
public function testSetGlobalId( Site $site ) {
$site->setGlobalId( 'foobar' );
/**
* @dataProvider instanceProvider
* @param Site $site
+ * @covers Site::getType
*/
public function testGetType( Site $site ) {
$this->assertInternalType( 'string', $site->getType() );
/**
* @dataProvider instanceProvider
* @param Site $site
+ * @covers Site::getPath
*/
public function testGetPath( Site $site ) {
$this->assertTypeOrValue( 'string', $site->getPath( 'page_path' ), null );
/**
* @dataProvider instanceProvider
* @param Site $site
+ * @covers Site::getAllPaths
*/
public function testGetAllPaths( Site $site ) {
$this->assertInternalType( 'array', $site->getAllPaths() );
/**
* @dataProvider instanceProvider
* @param Site $site
+ * @covers Site::setPath
+ * @covers Site::removePath
*/
public function testSetAndRemovePath( Site $site ) {
$count = count( $site->getAllPaths() );
$this->assertNull( $site->getPath( 'spam' ) );
}
+ /**
+ * @covers Site::setLinkPath
+ */
public function testSetLinkPath() {
$site = new Site();
$path = "TestPath/$1";
$this->assertEquals( $path, $site->getLinkPath() );
}
+ /**
+ * @covers Site::getLinkPathType
+ */
public function testGetLinkPathType() {
$site = new Site();
$this->assertEquals( $path, $site->getLinkPath() );
}
+ /**
+ * @covers Site::setPath
+ */
public function testSetPath() {
$site = new Site();
$this->assertEquals( $path, $site->getPath( 'foo' ) );
}
+ /**
+ * @covers Site::setPath
+ * @covers Site::getProtocol
+ */
public function testProtocolRelativePath() {
$site = new Site();
/**
* @dataProvider provideGetPageUrl
+ * @covers Site::getPageUrl
*/
public function testGetPageUrl( $path, $page, $expected ) {
$site = new Site();
/**
* @dataProvider instanceProvider
* @param Site $site
+ * @covers Site::serialize
+ * @covers Site::unserialize
*/
public function testSerialization( Site $site ) {
$this->assertInstanceOf( 'Serializable', $site );
<?php
+
/**
* @group Upload
*/
class UploadBaseTest extends MediaWikiTestCase {
- protected $upload;
+ /** @var UploadTestHandler */
+ protected $upload;
protected function setUp() {
global $wgHooks;
* of UploadBase::getTitle() and then the actual returned title
*
* @dataProvider provideTestTitleValidation
+ * @covers UploadBase::getTitle
*/
public function testTitleValidation( $srcFilename, $dstFilename, $code, $msg ) {
/* Check the result code */
/**
* Test the upload verification functions
+ * @covers UploadBase::verifyUpload
*/
public function testVerifyUpload() {
/* Setup with zero file size */
*
* This method should be abstracted so we can test different settings.
*/
-
public function testMaxUploadSize() {
global $wgMaxUploadSize;
$savedGlobal = $wgMaxUploadSize; // save global