/** * @dataProvider dataItemDataProvider */ public function testDetectChanges($storeValues, $dataValues, $settings, $expected) { $this->storeValues = $storeValues; $subject = DIWikiPage::newFromTitle(Title::newFromText(__METHOD__, SMW_NS_PROPERTY)); $settings = Settings::newFromArray(array('smwgDeclarationProperties' => $settings)); $this->applicationFactory->registerObject('Settings', $settings); $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 PropertyTypeDiffFinder($store, $semanticData); $instance->findDiff(); $this->assertEquals($subject->getTitle(), $instance->getTitle()); $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 inspectPropertyType() { if ($this->updateJobsEnabledState) { $propertyTypeDiffFinder = new PropertyTypeDiffFinder($this->store, $this->semanticData); $propertyTypeDiffFinder->findDiff(); } }