$property = new DIProperty( 'Foo' );
$property->setPropertyTypeId( '_txt' );
$dataValue = DataValueFactory::getInstance()->newDataValueByProperty(
$property,
'Some text'
);
$this->assertInstanceof(
'\SMWStringValue',
$dataValue
);
$this->assertEquals(
'Some text',
$dataValue->getDataItem()->getString()
);
Using the MockBuilder
$store = $this->getMockBuilder( '\SMW\Store' )
->disableOriginalConstructor()
->getMockForAbstractClass();
$store->expects( $this->at( 0 ) )
->method( 'getPropertyValues' )
->will( $this->returnValue( array(
new DIWikiPage(
'SomePropertyOfTypeBlob', SMW_NS_PROPERTY ) ) ) );
$store->expects( $this->at( 1 ) )
->method( 'getPropertyValues' )
->with(
$this->equalTo(
new DIWikiPage(
'SomePropertyOfTypeBlob', SMW_NS_PROPERTY ) ),
$this->anything(),
$this->anything() )
->will( $this->returnValue( array(
ApplicationFactory::getInstance()->registerObject( 'Store', $store );
$dataValue = DataValueFactory::getInstance()->newDataValueByText(
'SomePropertyOfTypeBlob',
'Some text'
);
$this->assertInstanceof(
'\SMWStringValue',
$dataValue
);
$this->assertEquals(
'Some text',
$dataValue->getDataItem()->getString()
);
ApplicationFactory::getInstance()->clear();