Skip to content

Commit

Permalink
Merge branch 'feature/MSS-151' of https://github.com/cultuurnet/Cdb i…
Browse files Browse the repository at this point in the history
…nto feature/MSS-151
  • Loading branch information
HnLn committed May 7, 2015
2 parents 98b3320 + 8f61af9 commit d4f5c23
Show file tree
Hide file tree
Showing 8 changed files with 235 additions and 3 deletions.
2 changes: 2 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
language: php
php:
- 5.6
- 5.5
- 5.4
- 5.3
before_script:
Expand Down
8 changes: 8 additions & 0 deletions changelogs/changelog-2.1.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
## 2.1.0

Changes from 2.0.2

- Keywords are now represented as CultureFeed_Cdb_Data_Keyword objects, although
discouraged strings can be still used for backwards compatibility reasons
- Update default cdbxml schema URI to version 3.3
- Implement additions in cdbxml schema version 3.3
4 changes: 2 additions & 2 deletions lib/CultureFeed/Cdb/Data/File.php
Original file line number Diff line number Diff line change
Expand Up @@ -544,11 +544,11 @@ public static function parseFromCdbXml(SimpleXMLElement $xmlElement) {
}

if (!empty($xmlElement->subbrand)) {
$file->subBrand = (string)$xmlElement->subbrand;
$file->subBrand = trim((string)$xmlElement->subbrand);
}

if (!empty($xmlElement->description)) {
$file->description = (string)$xmlElement->description;
$file->description = trim((string)$xmlElement->description);
}

return $file;
Expand Down
3 changes: 2 additions & 1 deletion lib/CultureFeed/Cdb/Data/Keyword.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public function setVisibility($visible)
}

/**
* @see CultureFeed_Cdb_IElement::appendToDOM()
* @inheritdoc
*/
public function appendToDOM(DOMElement $element)
{
Expand All @@ -90,6 +90,7 @@ public function appendToDOM(DOMElement $element)
}

/**
* @param SimpleXMLElement $xmlElement
* @see CultureFeed_Cdb_IElement::parseFromCdbXml(SimpleXMLElement $xmlElement)
* @return CultureFeed_Cdb_Data_Keyword
*/
Expand Down
47 changes: 47 additions & 0 deletions tests/CultureFeed/Cdb/Data/FileTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,51 @@ public function testAppendsTitleElementContainingTitle()

$this->assertEquals($title, $items->item(0)->textContent);
}

public function testGetSubBrand()
{
$this->assertNull($this->file->getSubBrand());

$subBrand = '2b88e17a-27fc-4310-9556-4df7188a051f';
$this->file->setSubBrand($subBrand);

$this->assertEquals($subBrand, $this->file->getSubBrand());
}

public function testAppendsSubBrand()
{
$subBrand = '2b88e17a-27fc-4310-9556-4df7188a051f';
$this->file->setSubBrand($subBrand);

$xpath = $this->xpathOnMediaWithFileAppended($this->file);
$items = $xpath->query('/media/file/subbrand');
$this->assertEquals(1, $items->length);

$this->assertEquals($subBrand, $items->item(0)->textContent);
}

/**
* @return DOMXPath
*/
private function xpathOnMediaWithFileAppended(CultureFeed_Cdb_Data_File $file)
{
$dom = new DOMDocument();
$mediaElement = $dom->createElement('media');
$dom->appendChild($mediaElement);

$file->appendToDOM($mediaElement);

return new DOMXPath($dom);
}

public function testGetDescription()
{
$this->assertNull($this->file->getDescription());

$description = 'Lorem Ipsum';
$this->file->setDescription($description);

$this->assertEquals($description, $this->file->getDescription());
}

}
12 changes: 12 additions & 0 deletions tests/CultureFeed/Cdb/Data/KeywordTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,18 @@ public function testVisibilityPassedToConstructor() {
$this->assertFalse($invisibleKeyword->isVisible());
}

public function testChangeVisibility() {
$keyword = new CultureFeed_Cdb_Data_Keyword('foo');

$keyword->setVisibility(FALSE);

$this->assertFalse($keyword->isVisible());

$keyword->setVisibility(TRUE);

$this->assertTrue($keyword->isVisible());
}

/**
* Provider for valid keyword values.
*
Expand Down
53 changes: 53 additions & 0 deletions tests/CultureFeed/Cdb/Item/EventTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -995,4 +995,57 @@ public function testKeywordAppendToDomAsTag() {
$xml = $dom->saveXML($items->item(0));
$this->assertXmlStringEqualsXmlFile(__DIR__ . '/samples/EventTest/cdbxml-3.3/keyword_tags.xml', $xml);
}

public function testGetAndSetPublisher()
{
$event = new CultureFeed_Cdb_Item_Event();
$this->assertNull($event->getPublisher());

$event->setPublisher('xyz');
$this->assertSame('xyz', $event->getPublisher());
}

public function testGetAndSetWeight()
{
$event = new CultureFeed_Cdb_Item_Event();
$this->assertNull($event->getWeight());

$event->setWeight(1);
$this->assertSame(1, $event->getWeight());
}

/**
* Integration test for parsing the following additions to cdbxml version 3.3:
* - event publisher and weight
* - file subbrand and description
*/
public function testParseCdbXml3Dot3SchemaAdditions() {
$xml = $this->loadSample('085377d6-a3c9-4c8f-88b9-3d6ab0201361.xml', '3.3');
$event = CultureFeed_Cdb_Item_Event::parseFromCdbXml($xml);

$this->assertEquals('085377d6-a3c9-4c8f-88b9-3d6ab0201361', $event->getCdbId());

$this->assertEquals('48fe254ceba710aec4609017d2e34d91', $event->getPublisher());

$this->assertSame(12, $event->getWeight());

$nlDetail = $event->getDetails()->getDetailByLanguage('nl');
$media = $nlDetail->getMedia();
$media->next();
/** @var CultureFeed_Cdb_Data_File $secondFile */
$secondFile = $media->current();

$this->assertEquals(
'{"keyword": "Culturefeed.be selectie",
"text": "Hello World",
"image": "https://www.facebook.com/23424317091/photos/a.200759332091.131532.23424317091/10153148846107092/?type=1",
"article": "http://www.humo.be/jeroom/3973/"}',
$secondFile->getDescription()
);

$this->assertEquals(
'2b88e17a-27fc-4310-9556-4df7188a051f',
$secondFile->getSubBrand()
);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
<?xml version="1.0" encoding="utf-8"?>
<event xsi:schemaLocation="http://www.cultuurdatabank.com/XMLSchema/CdbXSD/3.3/FINAL http://www.cultuurdatabank.com/XMLSchema/CdbXSD/3.3/FINAL/CdbXSD.xsd"
xmlns="http://www.cultuurdatabank.com/XMLSchema/CdbXSD/3.3/FINAL"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
availablefrom="2015-04-13T13:51:06" availableto="2020-12-13T00:00:00"
cdbid="085377d6-a3c9-4c8f-88b9-3d6ab0201361"
createdby="sven.houtmeyers+aanvrager@gmail.com"
creationdate="2015-04-21T15:50:27" externalid="testEventSven10"
lastupdated="2015-05-05T10:26:39"
lastupdatedby="sven.houtmeyers+aanvrager@gmail.com"
owner="Invoerders Algemeen " pctcomplete="75" private="false"
published="true" publisher="48fe254ceba710aec4609017d2e34d91"
validator="UiTdatabank Validatoren" wfstatus="readyforvalidation"
isparent="false"
weight="12">
<agefrom>12</agefrom>
<calendar>
<timestamps>
<timestamp>
<date>2020-12-12</date>
<timestart>18:00:00</timestart>
<timeend>20:00:00</timeend>
</timestamp>
</timestamps>
</calendar>
<categories>
<category type="theme" catid="1.8.3.1.0">Pop en rock</category>
<category type="targetaudience" catid="2.2.3.0.0">Jongeren vanaf 12
jaar (12+)
</category>
<category type="flanderstouristregion" catid="reg.357">Kunststad
Brussel
</category>
<category type="eventtype" catid="0.50.4.0.0">Concert</category>
<category type="flandersregion" catid="reg.1565">1000 Brussel
</category>
</categories>
<contactinfo>
<address>
<physical>
<city>Brussel</city>
<country>BE</country>
<gis>
<xcoordinate>4.351550</xcoordinate>
<ycoordinate>50.842750</ycoordinate>
</gis>
<zipcode>1000</zipcode>
</physical>
</address>
<phone type="phone">666</phone>
<url>http://www.moreinfo.info</url>
</contactinfo>
<eventdetails>
<eventdetail lang="nl">
<calendarsummary>za 12/12/20 van 18:00 tot 20:00
</calendarsummary>
<performers>
<performer>
<label>Jan De Groot</label>
</performer>
<performer>
<role>Regisseur</role>
<label>Karel Nieuwenhuyze</label>
</performer>
</performers>
<media>
<file>
<hlink>http://www.moreinfo.info</hlink>
<mediatype>webresource</mediatype>
</file>
<file>
<copyright>His master Jeroom</copyright>
<description>
{"keyword": "Culturefeed.be selectie",
"text": "Hello World",
"image": "https://www.facebook.com/23424317091/photos/a.200759332091.131532.23424317091/10153148846107092/?type=1",
"article": "http://www.humo.be/jeroom/3973/"}
</description>
<plaintext>Hello World</plaintext>
<mediatype>roadmap</mediatype>
<title>This is a title of Hello World</title>
<subbrand>2b88e17a-27fc-4310-9556-4df7188a051f
</subbrand>
</file>
</media>
<shortdescription>Een beschrijving van maximaal 400 karakters.
</shortdescription>
<title>testevent sven</title>
</eventdetail>
</eventdetails>
<keywords>
<keyword>keyword2</keyword>
<keyword visible="false">Culturefeed.be selectie</keyword>
</keywords>
<location>
<address>
<physical>
<city>Brussel</city>
<country>BE</country>
<gis>
<xcoordinate>4.351550</xcoordinate>
<ycoordinate>50.842750</ycoordinate>
</gis>
<zipcode>1000</zipcode>
</physical>
</address>
<label>Naam locatie</label>
</location>
</event>

0 comments on commit d4f5c23

Please sign in to comment.