Skip to content

Commit

Permalink
Merge pull request #1423 from NatLibFi/fix-datetime-to-string-in-cont…
Browse files Browse the repository at this point in the history
…ainshtml

fix conversion of DateTime to string in getContainsHtml
  • Loading branch information
osma authored Mar 22, 2023
2 parents a59f251 + bc490ba commit 7d7b1bb
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion model/ConceptPropertyValueLiteral.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public function getType()
}

public function getContainsHtml() {
return preg_match("/\/[a-z]*>/i", $this->literal->getValue()) != 0;
return preg_match("/\/[a-z]*>/i", $this->getLabel()) != 0;
}

public function getLabel()
Expand Down
11 changes: 11 additions & 0 deletions tests/ConceptPropertyValueLiteralTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,17 @@ public function testGetContainsHtmlWhenThereIsOnlyAOpeningTag() {
$this->assertFalse($lit->getContainsHtml());
}

/**
* @covers ConceptPropertyValueLiteral::getContainsHtml
*/
public function testGetContainsHtmlWhenValueIsDate() {
$litmock = $this->getMockBuilder('EasyRdf\Literal\Date')->disableOriginalConstructor()->getMock();
$litmock->method('getValue')->will($this->returnValue(DateTime::createFromFormat('Y-m-d', '2013-10-14')));
$resmock = $this->getMockBuilder('EasyRdf\Resource')->disableOriginalConstructor()->getMock();
$lit = new ConceptPropertyValueLiteral($this->model, $this->vocab, $resmock, $litmock, 'skosmos:testType');
$this->assertFalse($lit->getContainsHtml());
}

/**
* @covers ConceptPropertyValueLiteral::getContainsHtml
*/
Expand Down

0 comments on commit 7d7b1bb

Please sign in to comment.