/** * @dataProvider dataItemDataProvider */ public function testDetectChanges($storeValues, $dataValues, $propertiesToCompare, $expected) { $this->storeValues = $storeValues; $subject = new DIWikiPage(__METHOD__, SMW_NS_PROPERTY); $updateDispatcherJob = $this->getMockBuilder('SMW\\MediaWiki\\Jobs\\UpdateDispatcherJob')->disableOriginalConstructor()->getMock(); $expectedToRun = $expected['job'] ? $this->once() : $this->never(); $updateDispatcherJob->expects($expectedToRun)->method('run')->will($this->returnValue($subject)); $jobFactory = $this->getMockBuilder('SMW\\MediaWiki\\Jobs\\JobFactory')->disableOriginalConstructor()->getMock(); $jobFactory->expects($this->any())->method('newUpdateDispatcherJob')->will($this->returnValue($updateDispatcherJob)); $this->applicationFactory->registerObject('JobFactory', $jobFactory); $store = $this->getMockBuilder('SMW\\Store')->disableOriginalConstructor()->setMethods(array('getPropertyValues'))->getMockForAbstractClass(); $store->expects($this->atLeastOnce())->method('getPropertyValues')->will($this->returnCallback(array($this, 'mockStorePropertyValuesCallback'))); $semanticData = $this->getMockBuilder('\\SMW\\SemanticData')->disableOriginalConstructor()->getMock(); $semanticData->expects($this->atLeastOnce())->method('getSubject')->will($this->returnValue($subject)); $semanticData->expects($this->atLeastOnce())->method('getPropertyValues')->will($this->returnValue($dataValues)); $instance = new PropertySpecificationChangeNotifier($store, $semanticData); $instance->compareWith($propertiesToCompare); $this->assertEquals($expected['diff'], $instance->hasDiff()); }
/** * @note Comparison must happen *before* the storage update; * even finding uses of a property fails after its type changed. */ private function inspectPropertySpecification() { if (!$this->enabledWithUpdateJobs) { return; } $propertySpecificationChangeNotifier = new PropertySpecificationChangeNotifier($this->store, $this->semanticData); $propertySpecificationChangeNotifier->compareWith($this->applicationFactory->getSettings()->get('smwgDeclarationProperties')); }
/** * @note Comparison must happen *before* the storage update; * even finding uses of a property fails after its type changed. */ private function inspectPropertySpecification() { if (!$this->updateJobsEnabledState) { return; } $propertySpecificationChangeNotifier = new PropertySpecificationChangeNotifier($this->store, $this->semanticData); $propertySpecificationChangeNotifier->setPropertiesToCompare($this->applicationFactory->getSettings()->get('smwgDeclarationProperties')); $propertySpecificationChangeNotifier->compareForListedSpecification(); }