Skip to content

Commit

Permalink
Support DIUri
Browse files Browse the repository at this point in the history
  • Loading branch information
mwjames committed Feb 18, 2015
1 parent 919683e commit c94ee19
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
3 changes: 2 additions & 1 deletion src/PropertyValueContentFinder.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use SMW\DIProperty;
use SMW\DIWikiPage;
use SMWDIBlob as DIBlob;
use SMWDIUri as DIUri;

/**
* @license GNU GPL v2+
Expand Down Expand Up @@ -70,7 +71,7 @@ private function iterateOverPropertyValues( array $propertyValues, &$values ) {

if ( $value instanceOf DIBlob ) {
$values[] = htmlspecialchars( $value->getString() );
} elseif( $value instanceOf DIWikiPage ) {
} elseif( $value instanceOf DIWikiPage || $value instanceOf DIUri ) {
$values[] = htmlspecialchars( $value->getSortKey() );
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,14 @@ public function testAddStandardMetaTag() {

$this->pageCreator
->createPage( $subject->getTitle() )
->doEdit( '[[SMT keywords::KeywordMetaTags]]' );
->doEdit( '[[SMT keywords::KeywordMetaTag]] [[SMT keywords::AnotherKeywordMetaTag]]' );

$parserOutput = $this->pageCreator->getEditInfo()->output;

$outputPage->addParserOutputMetadata( $parserOutput );

$this->assertEquals(
array( array( 'keywords', 'KeywordMetaTags' ) ),
array( array( 'keywords', 'KeywordMetaTag,AnotherKeywordMetaTag' ) ),
$outputPage->getMetaTags()
);

Expand Down
11 changes: 8 additions & 3 deletions tests/phpunit/Unit/PropertyValueContentFinderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use SMW\DIProperty;
use SMW\DIWikiPage;
use SMWDIBlob as DIBlob;
use SMWDIUri as DIUri;

/**
* @covers \SMT\PropertyValueContentFinder
Expand Down Expand Up @@ -100,12 +101,16 @@ public function testFindContentForMultipleProperties() {
$semanticData->expects( $this->at( 0 ) )
->method( 'getPropertyValues' )
->with( $this->equalTo( DIProperty::newFromUserLabel( 'foo' ) ) )
->will( $this->returnValue( array( new DIWikiPage( '"Foo"', NS_MAIN ) ) ) );
->will( $this->returnValue( array(
new DIUri( 'http', 'username@example.org/foo', '', '' ),
new DIWikiPage( '"Foo"', NS_MAIN ) ) ) );

$semanticData->expects( $this->at( 2 ) )
->method( 'getPropertyValues' )
->with( $this->equalTo( DIProperty::newFromUserLabel( 'bar' ) ) )
->will( $this->returnValue( array( new DIBlob( 'Mo' ), new DIBlob( 'fo' ) ) ) );
->will( $this->returnValue( array(
new DIBlob( 'Mo' ),
new DIBlob( 'fo' ) ) ) );

$semanticData->expects( $this->any() )
->method( 'getSubSemanticData' )
Expand All @@ -114,7 +119,7 @@ public function testFindContentForMultipleProperties() {
$instance = new PropertyValueContentFinder( $semanticData );

$this->assertSame(
'"Foo",Mo,fo',
'http://username@example.org/foo,"Foo",Mo,fo',
$instance->findContentForProperties( $properties )
);
}
Expand Down

0 comments on commit c94ee19

Please sign in to comment.