作者:ReachingOu
项目:SemanticMediaWik
protected function setUp()
{
parent::setUp();
$this->applicationFactory = ApplicationFactory::getInstance();
$settings = Settings::newFromArray(array('smwgShowFactbox' => SMW_FACTBOX_NONEMPTY, 'smwgFactboxUseCache' => true, 'smwgCacheType' => 'hash', 'smwgLinksInValues' => false, 'smwgInlineErrors' => true));
$this->applicationFactory->registerObject('Settings', $settings);
}
作者:ReachingOu
项目:SemanticMediaWik
/**
* @since 1.9
*/
protected function loadAtInstantiation()
{
/**
* Settings object definition
*
* @since 1.9
*
* @return Settings
*/
$this->registerObject('Settings', function () {
return Settings::newFromGlobals();
}, DependencyObject::SCOPE_SINGLETON);
/**
* Store object definition
*
* @since 1.9
*
* @return Store
*/
$this->registerObject('Store', function (DependencyBuilder $builder) {
return StoreFactory::getStore($builder->newObject('Settings')->get('smwgDefaultStore'));
}, DependencyObject::SCOPE_SINGLETON);
/**
* @since 1.9
*
* @return Cache
*/
$this->registerObject('Cache', function (DependencyBuilder $builder) {
return ApplicationFactory::getInstance()->newCacheFactory()->newMediaWikiCompositeCache();
}, DependencyObject::SCOPE_SINGLETON);
}
作者:whysass
项目:kmwik
/**
* @depends testGetPropertyTables
*/
public function testPropertyTablesWithValidCustomizableProperties()
{
$instance = $this->acquireInstance();
$instance->setConfiguration(Settings::newFromArray(array('smwgFixedProperties' => array(), 'smwgPageSpecialProperties' => array('_MDAT', '_MEDIA'))));
$this->assertCount($this->defaultPropertyTableCount + 2, $instance->getPropertyTables());
$instance->clear();
}
作者:WolfgangFah
项目:SemanticMediaWik
/**
* Returns a static instance with an invoked global settings array
*
* @par Example:
* @code
* \SMW\NamespaceExaminer::getInstance()->isSemanticEnabled( NS_MAIN )
* @endcode
*
* @note Used in smwfIsSemanticsProcessed
*
* @since 1.9
*
* @return NamespaceExaminer
*/
public static function getInstance()
{
if (self::$instance === null) {
self::$instance = self::newFromArray(Settings::newFromGlobals()->get('smwgNamespacesWithSemanticLinks'));
}
return self::$instance;
}
作者:whysass
项目:kmwik
/**
* @since 1.9
*/
protected function loadAtInstantiation()
{
/**
* Settings object definition
*
* @since 1.9
*
* @return Settings
*/
$this->registerObject('Settings', function () {
return Settings::newFromGlobals();
}, DependencyObject::SCOPE_SINGLETON);
/**
* Store object definition
*
* @since 1.9
*
* @return Store
*/
$this->registerObject('Store', function (DependencyBuilder $builder) {
return StoreFactory::getStore($builder->newObject('Settings')->get('smwgDefaultStore'));
}, DependencyObject::SCOPE_SINGLETON);
/**
* CacheHandler object definition
*
* @since 1.9
*
* @return CacheHandler
*/
$this->registerObject('CacheHandler', function (DependencyBuilder $builder) {
return CacheHandler::newFromId($builder->newObject('Settings')->get('smwgCacheType'));
}, DependencyObject::SCOPE_SINGLETON);
}
作者:jongfel
项目:SemanticMediaWik
private function registerSettings()
{
$this->applicationFactory->registerObject('Settings', Settings::newFromGlobals($this->globalVars));
if (CompatibilityMode::extensionNotEnabled()) {
CompatibilityMode::disableSemantics();
}
}
作者:WolfgangFah
项目:SemanticMediaWik
protected function setUp()
{
parent::setUp();
$this->applicationFactory = ApplicationFactory::getInstance();
$settings = Settings::newFromArray(array('smwgFactboxUseCache' => true, 'smwgCacheType' => 'hash'));
$this->applicationFactory->registerObject('Settings', $settings);
}
作者:jongfel
项目:SemanticMediaWik
protected function setUp()
{
parent::setUp();
$this->store = $this->getMockBuilder('\\SMW\\Store')->disableOriginalConstructor()->getMockForAbstractClass();
$this->skin = $this->getMockBuilder('\\Skin')->disableOriginalConstructor()->getMock();
$this->settings = Settings::newFromArray(array('smwgPDefaultType' => '_wpg', 'smwgPropertyLowUsageThreshold' => 5, 'smwgPropertyZeroCountDisplay' => true));
$this->dataItemFactory = new DataItemFactory();
}
作者:WolfgangFah
项目:SemanticMediaWik
public function testGetDefaultStore()
{
$instance = StoreFactory::getStore();
$this->assertInstanceOf(Settings::newFromGlobals()->get('smwgDefaultStore'), $instance);
$this->assertSame(StoreFactory::getStore(), $instance);
StoreFactory::clear();
$this->assertNotSame(StoreFactory::getStore(), $instance);
}
作者:jongfel
项目:SemanticMediaWik
protected function setUp()
{
parent::setUp();
$this->store = $this->getMockBuilder('\\SMW\\Store')->disableOriginalConstructor()->getMockForAbstractClass();
$this->skin = $this->getMockBuilder('\\Skin')->disableOriginalConstructor()->getMock();
$this->settings = Settings::newFromArray(array());
$this->dataItemFactory = new DataItemFactory();
}
作者:brandonphuon
项目:mediawik
protected function tearDown()
{
ApplicationFactory::clear();
NamespaceExaminer::clear();
PropertyRegistry::clear();
Settings::clear();
Exporter::getInstance()->clear();
parent::tearDown();
}
作者:ReachingOu
项目:SemanticMediaWik
protected function setUp()
{
parent::setUp();
$this->applicationFactory = ApplicationFactory::getInstance();
$settings = Settings::newFromArray(array('smwgCacheType' => 'hash', 'smwgEnableUpdateJobs' => false));
$store = $this->getMockBuilder('\\SMW\\Store')->disableOriginalConstructor()->getMockForAbstractClass();
$this->applicationFactory->registerObject('Store', $store);
$this->applicationFactory->registerObject('Settings', $settings);
}
作者:ReachingOu
项目:SemanticMediaWik
protected function setUp()
{
parent::setUp();
$this->applicationFactory = ApplicationFactory::getInstance();
$settings = Settings::newFromArray(array('smwgFactboxUseCache' => true, 'smwgCacheType' => 'hash', 'smwgLinksInValues' => false, 'smwgInlineErrors' => true));
$this->applicationFactory->registerObject('Settings', $settings);
$this->cache = $this->applicationFactory->newCacheFactory()->newFixedInMemoryCache();
$this->applicationFactory->registerObject('Cache', $this->cache);
}
作者:jongfel
项目:SemanticMediaWik
/**
* @dataProvider skinTemplateDataProvider
*/
public function testProcess($setup, $expected)
{
$toolbox = '';
ApplicationFactory::getInstance()->registerObject('Settings', Settings::newFromArray($setup['settings']));
$instance = new BaseTemplateToolbox($setup['skinTemplate'], $toolbox);
$this->assertTrue($instance->process());
if ($expected['count'] == 0) {
return $this->assertEmpty($toolbox);
}
$this->assertCount($expected['count'], $toolbox['smw-browse']);
}
作者:whysass
项目:kmwik
public function testProcess()
{
$oldTitle = MockTitle::buildMock('old');
$newTitle = MockTitle::buildMock('new');
$store = $this->getMockBuilder('\\SMW\\Store')->disableOriginalConstructor()->getMockForAbstractClass();
$store->expects($this->once())->method('changeTitle')->with($this->equalTo($oldTitle), $this->equalTo($newTitle), $this->anything(), $this->anything());
$this->applicationFactory->registerObject('Settings', Settings::newFromArray(array('smwgCacheType' => 'hash', 'smwgAutoRefreshOnPageMove' => true)));
$this->applicationFactory->registerObject('Store', $store);
$instance = new TitleMoveComplete($oldTitle, $newTitle, new MockSuperUser(), 0, 0);
$this->assertTrue($instance->process());
}
作者:jongfel
项目:SemanticMediaWik
/**
* @dataProvider wikiPageDataProvider
*/
public function testProcess($parameters, $expected)
{
$this->applicationFactory->registerObject('Settings', Settings::newFromArray($parameters['settings']));
$instance = new NewRevisionFromEditComplete($parameters['wikiPage'], $parameters['revision'], 0);
$this->assertTrue($instance->process());
$editInfo = $parameters['editInfo'];
if ($editInfo && $editInfo->output instanceof ParserOutput) {
$parserData = $this->applicationFactory->newParserData($parameters['wikiPage']->getTitle(), $editInfo->output);
$this->semanticDataValidator->assertThatPropertiesAreSet($expected, $parserData->getSemanticData());
}
}
作者:ReachingOu
项目:SemanticMediaWik
public function testDeleteSubjectForNotSupportedSemanticNamespace()
{
$oldTitle = \Title::newFromText('Old');
$newTitle = \Title::newFromText('New', NS_HELP);
$store = $this->getMockBuilder('\\SMW\\Store')->disableOriginalConstructor()->getMockForAbstractClass();
$store->expects($this->once())->method('deleteSubject')->with($this->equalTo($oldTitle));
$this->applicationFactory->registerObject('Settings', Settings::newFromArray(array('smwgCacheType' => 'hash', 'smwgAutoRefreshOnPageMove' => true, 'smwgNamespacesWithSemanticLinks' => array(NS_MAIN => true, NS_HELP => false))));
$this->applicationFactory->registerObject('Store', $store);
$instance = new TitleMoveComplete($oldTitle, $newTitle, new MockSuperUser(), 0, 0);
$this->assertTrue($instance->process());
}
作者:ReachingOu
项目:SemanticMediaWik
/**
* @dataProvider specialPropertiesDataProvider
*/
public function testAddSpecialProperties(array $parameters, array $expected)
{
$semanticData = $this->semanticDataFactory->setSubject($parameters['subject'])->newEmptySemanticData();
$pageInfo = $this->getMockBuilder('\\SMW\\PageInfo')->disableOriginalConstructor()->getMock();
foreach ($parameters['pageInfo'] as $method => $returnValue) {
$pageInfo->expects($this->any())->method($method)->will($this->returnValue($returnValue));
}
$this->applicationFactory->registerObject('Settings', Settings::newFromArray($parameters['settings']));
$instance = new PredefinedPropertyAnnotator(new NullPropertyAnnotator($semanticData), $pageInfo);
$instance->addAnnotation();
$this->semanticDataValidator->assertThatPropertiesAreSet($expected, $instance->getSemanticData());
}
作者:Rikuforeve
项目:wik
/**
* @dataProvider textDataProvider
*/
public function testTextChangeWithParserOuputUpdateIntegration($parameters, $expected)
{
$text = $parameters['text'];
$parser = $this->parserFactory->newFromTitle($parameters['title']);
$instance = new InternalParseBeforeLinks($parser, $text);
$this->applicationFactory->registerObject('Settings', Settings::newFromArray($parameters['settings']));
$this->assertTrue($instance->process());
$this->assertEquals($expected['resultText'], $text);
$parserData = $this->applicationFactory->newParserData($parser->getTitle(), $parser->getOutput());
$this->assertEquals($expected['propertyCount'] > 0, $parser->getOutput()->getProperty('smw-semanticdata-status'));
$this->semanticDataValidator->assertThatPropertiesAreSet($expected, $parserData->getSemanticData());
}
作者:whysass
项目:kmwik
/**
* @dataProvider annotationDataProvider
*/
public function testChainableDecoratorAnnotation(array $parameters, array $expected)
{
$pageInfoProvider = $this->getMockBuilder('\\SMW\\PageInfo')->disableOriginalConstructor()->getMock();
$pageInfoProvider->expects($this->atLeastOnce())->method('getModificationDate')->will($this->returnValue($parameters['modificationDate']));
$semanticData = $this->semanticDataFactory->newEmptySemanticData(__METHOD__);
$this->applicationFactory->registerObject('Settings', Settings::newFromArray($parameters['settings']));
$instance = new CategoryPropertyAnnotator(new NullPropertyAnnotator($semanticData), $parameters['categories']);
$instance = new SortKeyPropertyAnnotator($instance, $parameters['sortkey']);
$instance = new PredefinedPropertyAnnotator($instance, $pageInfoProvider);
$instance->addAnnotation();
$this->semanticDataValidator->assertThatPropertiesAreSet($expected, $instance->getSemanticData());
}