Skip to content

Commit

Permalink
III-578: test actor xml parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
Nick committed Jan 5, 2016
1 parent f41f041 commit 070a9d0
Show file tree
Hide file tree
Showing 6 changed files with 221 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/CultureFeed/Cdb/Item/Actor.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ public function __construct()

/**
* @see CultureFeed_Cdb_IElement::parseFromCdbXml(SimpleXMLElement $xmlElement)
* @throws CultureFeed_Cdb_ParseException
* @return CultureFeed_Cdb_Item_Actor
*/
public static function parseFromCdbXml(SimpleXMLElement $xmlElement)
Expand Down
30 changes: 30 additions & 0 deletions lib/CultureFeed/Cdb/Item/Base.php
Original file line number Diff line number Diff line change
Expand Up @@ -293,51 +293,81 @@ public function setLastUpdatedBy($author)
$this->lastUpdatedBy = $author;
}

/**
* @return string
*/
public function getAvailableFrom()
{
return $this->availableFrom;
}

/**
* @param string $value
*/
public function setAvailableFrom($value)
{
$this->availableFrom = $value;
}

/**
* @return string
*/
public function getAvailableTo()
{
return $this->availableTo;
}

/**
* @param string $value
*/
public function setAvailableTo($value)
{
$this->availableTo = $value;
}

/**
* @return string
*/
public function getCreatedBy()
{
return $this->createdBy;
}

/**
* @param string $author
*/
public function setCreatedBy($author)
{
$this->createdBy = $author;
}

/**
* @return string
*/
public function getCreationDate()
{
return $this->creationDate;
}

/**
* @param string $value
*/
public function setCreationDate($value)
{
$this->creationDate = $value;
}

/**
* @return string
*/
public function getOwner()
{
return $this->owner;
}

/**
* @param string $owner
*/
public function setOwner($owner)
{
$this->owner = $owner;
Expand Down
70 changes: 70 additions & 0 deletions tests/CultureFeed/Cdb/Item/ActorTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
<?php

class CultureFeed_Cdb_Item_ActorTest extends PHPUnit_Framework_TestCase
{
public function setUp()
{
$this->actor = new CultureFeed_Cdb_Item_Actor();
}

/**
* @param $fileName
* @param $cdbScheme
* @return SimpleXMLElement
*/
public function loadSample($fileName, $cdbScheme = '3.2')
{
$sampleDir = __DIR__ . '/samples/ActorTest/cdbxml-' . $cdbScheme . '/';
$filePath = $sampleDir . $fileName;

$xml = simplexml_load_file(
$filePath,
'SimpleXMLElement',
0,
'http://www.cultuurdatabank.com/XMLSchema/CdbXSD/' . $cdbScheme . '/FINAL'
);

return $xml;
}

/**
* Integration test for parsing cdbxml version 3.2
*/
public function testParseCdbXml()
{
$xml = $this->loadSample('actor.xml');
$actor = CultureFeed_Cdb_Item_Actor::parseFromCdbXml($xml);

$this->assertInstanceOf('CultureFeed_Cdb_Item_Actor', $actor);

$this->assertEquals('a761b5d6-0349-4dd4-a39f-c471b0fb64e8', $actor->getCdbId());
$this->assertEquals('SKB Import:Organisation_488', $actor->getExternalId());
$this->assertEquals('2011-01-03T10:39:18', $actor->getAvailableFrom());
$this->assertEquals('2100-01-01T00:00:00', $actor->getAvailableTo());
$this->assertEquals('admin ferranti', $actor->getCreatedBy());
$this->assertEquals('2010-01-19T04:59:14', $actor->getCreationDate());
$this->assertEquals('2011-01-03T10:39:18', $actor->getLastUpdated());
$this->assertEquals('soetkin.vanassche@cultuurnet.be', $actor->getLastUpdatedBy());
$this->assertEquals('Invoerders Algemeen ', $actor->getOwner());
}

/**
* @expectedException CultureFeed_Cdb_ParseException
* @expectedExceptionMessage Categories missing for actor element
*/
public function testParseCdbXmlWithoutCategories()
{
$xml = $this->loadSample('actor-no-categories.xml');
CultureFeed_Cdb_Item_Actor::parseFromCdbXml($xml);
}

/**
* @expectedException CultureFeed_Cdb_ParseException
* @expectedExceptionMessage Actordetails missing for actor element
*/
public function testParseCdbXmlWithoutActorDetails()
{
$xml = $this->loadSample('actor-no-actordetails.xml');
CultureFeed_Cdb_Item_Actor::parseFromCdbXml($xml);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?xml version="1.0" encoding="UTF-8"?>
<actor xmlns:cdb="http://www.cultuurdatabank.com/XMLSchema/CdbXSD/3.2/FINAL" asset="true" availablefrom="2011-01-03T10:39:18" availableto="2100-01-01T00:00:00" createdby="admin ferranti" creationdate="2010-01-19T04:59:14" cdbid="a761b5d6-0349-4dd4-a39f-c471b0fb64e8" externalid="SKB Import:Organisation_488" lastupdated="2011-01-03T10:39:18" lastupdatedby="soetkin.vanassche@cultuurnet.be" owner="Invoerders Algemeen ">
<actordetails/>
<categories>
<category catid="8.15.0.0.0" type="actortype">Locatie</category>
<category catid="8.11.0.0.0" type="actortype">Organisator(en)</category>
<category catid="6.4.0.0.0" type="publicscope">Internationaal</category>
<category catid="8.3.0.0.0" type="actortype">Museum</category>
</categories>
<contactinfo>
<address>
<physical>
<city>Brussel</city>
<country>BE</country>
<gis>
<xcoordinate>4.358241</xcoordinate>
<ycoordinate>50.841680</ycoordinate>
</gis>
<housenr>3</housenr>
<street>Regentschapsstr.</street>
<zipcode>1000</zipcode>
</physical>
</address>
<mail>info@fine-arts-museum.be</mail>
<phone type="phone">02-508.32.11</phone>
<phone type="fax">02-508.32.32</phone>
<url main="true">http://www.fine-arts-museum.be</url>
</contactinfo>
</actor>
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?xml version="1.0" encoding="UTF-8"?>
<actor xmlns:cdb="http://www.cultuurdatabank.com/XMLSchema/CdbXSD/3.2/FINAL" asset="true" availablefrom="2011-01-03T10:39:18" availableto="2100-01-01T00:00:00" createdby="admin ferranti" creationdate="2010-01-19T04:59:14" cdbid="a761b5d6-0349-4dd4-a39f-c471b0fb64e8" externalid="SKB Import:Organisation_488" lastupdated="2011-01-03T10:39:18" lastupdatedby="soetkin.vanassche@cultuurnet.be" owner="Invoerders Algemeen ">
<actordetails>
<actordetail lang="nl">
<media>
<file creationdate="3/01/2011 10:38:42" main="true">
<copyright>KMSKB - MRBAB 2001</copyright>
<filename>35a1c617-0685-49a1-af8f-17b93bbe749d.jpg</filename>
<filetype>jpeg</filetype>
<hlink>
//test-media.uitdatabank.be/images/20100119/35a1c617-0685-49a1-af8f-17b93bbe749d.jpg
</hlink>
</file>
</media>
<shortdescription>
In de Koninklijke Musea voor Schone Kunsten van België, die twee eeuwen oud zijn, worden ongeveer twintigduizend schilderijen, sculpturen en tekeningen bewaard. Ze zijn gevestigd in Brussel en bestaan uit het Museum voor Oude Kunst (15de-18de eeuw), het Museum voor Moderne Kunst (19de-20ste eeuw), het Wiertzmuseum, het Meuniermuseum en het Musée Magritte Museum.
</shortdescription>
<title>
Koninklijke Musea voor Schone Kunsten van België (KMSKB)
</title>
</actordetail>
</actordetails>
<categories />
<contactinfo>
<address>
<physical>
<city>Brussel</city>
<country>BE</country>
<gis>
<xcoordinate>4.358241</xcoordinate>
<ycoordinate>50.841680</ycoordinate>
</gis>
<housenr>3</housenr>
<street>Regentschapsstr.</street>
<zipcode>1000</zipcode>
</physical>
</address>
<mail>info@fine-arts-museum.be</mail>
<phone type="phone">02-508.32.11</phone>
<phone type="fax">02-508.32.32</phone>
<url main="true">http://www.fine-arts-museum.be</url>
</contactinfo>
</actor>
48 changes: 48 additions & 0 deletions tests/CultureFeed/Cdb/Item/samples/ActorTest/cdbxml-3.2/actor.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<?xml version="1.0" encoding="UTF-8"?>
<actor xmlns:cdb="http://www.cultuurdatabank.com/XMLSchema/CdbXSD/3.2/FINAL" asset="true" availablefrom="2011-01-03T10:39:18" availableto="2100-01-01T00:00:00" createdby="admin ferranti" creationdate="2010-01-19T04:59:14" cdbid="a761b5d6-0349-4dd4-a39f-c471b0fb64e8" externalid="SKB Import:Organisation_488" lastupdated="2011-01-03T10:39:18" lastupdatedby="soetkin.vanassche@cultuurnet.be" owner="Invoerders Algemeen ">
<actordetails>
<actordetail lang="nl">
<media>
<file creationdate="3/01/2011 10:38:42" main="true">
<copyright>KMSKB - MRBAB 2001</copyright>
<filename>35a1c617-0685-49a1-af8f-17b93bbe749d.jpg</filename>
<filetype>jpeg</filetype>
<hlink>
//test-media.uitdatabank.be/images/20100119/35a1c617-0685-49a1-af8f-17b93bbe749d.jpg
</hlink>
</file>
</media>
<shortdescription>
In de Koninklijke Musea voor Schone Kunsten van België, die twee eeuwen oud zijn, worden ongeveer twintigduizend schilderijen, sculpturen en tekeningen bewaard. Ze zijn gevestigd in Brussel en bestaan uit het Museum voor Oude Kunst (15de-18de eeuw), het Museum voor Moderne Kunst (19de-20ste eeuw), het Wiertzmuseum, het Meuniermuseum en het Musée Magritte Museum.
</shortdescription>
<title>
Koninklijke Musea voor Schone Kunsten van België (KMSKB)
</title>
</actordetail>
</actordetails>
<categories>
<category catid="8.15.0.0.0" type="actortype">Locatie</category>
<category catid="8.11.0.0.0" type="actortype">Organisator(en)</category>
<category catid="6.4.0.0.0" type="publicscope">Internationaal</category>
<category catid="8.3.0.0.0" type="actortype">Museum</category>
</categories>
<contactinfo>
<address>
<physical>
<city>Brussel</city>
<country>BE</country>
<gis>
<xcoordinate>4.358241</xcoordinate>
<ycoordinate>50.841680</ycoordinate>
</gis>
<housenr>3</housenr>
<street>Regentschapsstr.</street>
<zipcode>1000</zipcode>
</physical>
</address>
<mail>info@fine-arts-museum.be</mail>
<phone type="phone">02-508.32.11</phone>
<phone type="fax">02-508.32.32</phone>
<url main="true">http://www.fine-arts-museum.be</url>
</contactinfo>
</actor>

0 comments on commit 070a9d0

Please sign in to comment.