示例#1
0
 public function testFindPropertyId()
 {
     $datatypeRegistry = $this->getMockBuilder('\\SMW\\DataTypeRegistry')->disableOriginalConstructor()->getMock();
     $datatypeRegistry->expects($this->once())->method('getKnownTypeLabels')->will($this->returnValue(array()));
     $datatypeRegistry->expects($this->once())->method('getKnownTypeAliases')->will($this->returnValue(array()));
     $propertyLabels = array();
     $propertyAliases = array();
     $instance = new PropertyRegistry($datatypeRegistry, $propertyLabels, $propertyAliases);
     $instance->registerProperty(DIProperty::TYPE_HAS_TYPE, '__typ', 'Has type', true);
     $instance->registerPropertyAlias('_TYPE', 'foo');
     $this->assertEquals('_TYPE', $instance->findPropertyIdByLabel('Has type'));
     $this->assertEquals('_TYPE', $instance->findPropertyIdByLabel('foo', true));
     $this->assertFalse($instance->findPropertyIdByLabel('unknownLabel'));
     $this->assertFalse($instance->findPropertyIdByLabel('unknownLabel', true));
     // findPropertyId legacy test
     $this->assertEquals('_TYPE', $instance->findPropertyId('Has type'));
 }
 public function testFindPropertyInfoForUnregisteredId()
 {
     $datatypeRegistry = $this->getMockBuilder('\\SMW\\DataTypeRegistry')->disableOriginalConstructor()->getMock();
     $datatypeRegistry->expects($this->once())->method('getKnownTypeLabels')->will($this->returnValue(array()));
     $datatypeRegistry->expects($this->once())->method('getKnownTypeAliases')->will($this->returnValue(array()));
     $store = $this->getMockBuilder('\\SMW\\Store')->disableOriginalConstructor()->getMockForAbstractClass();
     $propertyLabelFinder = new PropertyLabelFinder($store, array());
     $propertyAliases = array();
     $instance = new PropertyRegistry($datatypeRegistry, $propertyLabelFinder, $propertyAliases);
     $this->assertEquals('', $instance->findPropertyLabelById('_UnknownId'));
     $this->assertEquals('', $instance->getPropertyTypeId('_UnknownId'));
     $this->assertFalse($instance->findPropertyIdByLabel('unknownLabel'));
     $this->assertFalse($instance->findPropertyIdByLabel('unknownLabel', true));
 }
 public function testDataTypePropertyExemptionList()
 {
     $datatypeRegistry = $this->getMockBuilder('\\SMW\\DataTypeRegistry')->disableOriginalConstructor()->getMock();
     $datatypeRegistry->expects($this->once())->method('getKnownTypeLabels')->will($this->returnValue(array('_foo' => 'Foo', '_foobar' => 'Foobar')));
     $datatypeRegistry->expects($this->once())->method('getKnownTypeAliases')->will($this->returnValue(array('Bar' => '_bar')));
     $store = $this->getMockBuilder('\\SMW\\Store')->disableOriginalConstructor()->getMockForAbstractClass();
     $propertyLabelFinder = new PropertyLabelFinder($store, array());
     $propertyAliases = new PropertyAliasFinder();
     $dataTypePropertyExemptionList = array('Foo', 'Bar');
     $instance = new PropertyRegistry($datatypeRegistry, $propertyLabelFinder, $propertyAliases, $dataTypePropertyExemptionList);
     $this->assertEquals('_foobar', $instance->findPropertyIdByLabel('Foobar'));
     $this->assertFalse($instance->findPropertyIdByLabel('Foo'));
     $this->assertFalse($instance->findPropertyIdByLabel('Bar'));
 }