Make DCES easily serializables

This commit is contained in:
Romain Neutron
2013-04-17 14:41:32 +02:00
parent 7553f53416
commit d7cd289dc8
31 changed files with 100 additions and 360 deletions

View File

@@ -9,6 +9,8 @@
* file that was distributed with this source code. * file that was distributed with this source code.
*/ */
use JMS\Serializer\Annotation\SerializedName;
/** /**
* *
* @package Databox DCES * @package Databox DCES
@@ -31,6 +33,7 @@ class databox_Field_DCES_Contributor extends databox_Field_DCESAbstract
to the resource.'; to the resource.';
/** /**
* @SerializedName("URI")
* *
* @var string * @var string
*/ */

View File

@@ -9,6 +9,8 @@
* file that was distributed with this source code. * file that was distributed with this source code.
*/ */
use JMS\Serializer\Annotation\SerializedName;
/** /**
* *
* @package Databox DCES * @package Databox DCES
@@ -33,6 +35,7 @@ class databox_Field_DCES_Coverage extends databox_Field_DCESAbstract
is relevant.'; is relevant.';
/** /**
* @SerializedName("URI")
* *
* @var string * @var string
*/ */

View File

@@ -9,6 +9,8 @@
* file that was distributed with this source code. * file that was distributed with this source code.
*/ */
use JMS\Serializer\Annotation\SerializedName;
/** /**
* *
* @package Databox DCES * @package Databox DCES
@@ -31,6 +33,7 @@ class databox_Field_DCES_Creator extends databox_Field_DCESAbstract
for making the resource.'; for making the resource.';
/** /**
* @SerializedName("URI")
* *
* @var string * @var string
*/ */

View File

@@ -9,6 +9,8 @@
* file that was distributed with this source code. * file that was distributed with this source code.
*/ */
use JMS\Serializer\Annotation\SerializedName;
/** /**
* *
* @package Databox DCES * @package Databox DCES
@@ -31,6 +33,7 @@ class databox_Field_DCES_Date extends databox_Field_DCESAbstract
in the lifecycle of the resource.'; in the lifecycle of the resource.';
/** /**
* @SerializedName("URI")
* *
* @var string * @var string
*/ */

View File

@@ -9,6 +9,8 @@
* file that was distributed with this source code. * file that was distributed with this source code.
*/ */
use JMS\Serializer\Annotation\SerializedName;
/** /**
* *
* @package Databox DCES * @package Databox DCES
@@ -30,6 +32,7 @@ class databox_Field_DCES_Description extends databox_Field_DCESAbstract
protected $definition = 'An account of the resource.'; protected $definition = 'An account of the resource.';
/** /**
* @SerializedName("URI")
* *
* @var string * @var string
*/ */

View File

@@ -9,6 +9,8 @@
* file that was distributed with this source code. * file that was distributed with this source code.
*/ */
use JMS\Serializer\Annotation\SerializedName;
/** /**
* *
* @package Databox DCES * @package Databox DCES
@@ -31,6 +33,7 @@ class databox_Field_DCES_Format extends databox_Field_DCESAbstract
or dimensions of the resource.'; or dimensions of the resource.';
/** /**
* @SerializedName("URI")
* *
* @var string * @var string
*/ */

View File

@@ -9,6 +9,8 @@
* file that was distributed with this source code. * file that was distributed with this source code.
*/ */
use JMS\Serializer\Annotation\SerializedName;
/** /**
* *
* @package Databox DCES * @package Databox DCES
@@ -31,6 +33,7 @@ class databox_Field_DCES_Identifier extends databox_Field_DCESAbstract
within a given context.'; within a given context.';
/** /**
* @SerializedName("URI")
* *
* @var string * @var string
*/ */

View File

@@ -9,6 +9,8 @@
* file that was distributed with this source code. * file that was distributed with this source code.
*/ */
use JMS\Serializer\Annotation\SerializedName;
/** /**
* *
* @package Databox DCES * @package Databox DCES
@@ -31,6 +33,7 @@ class databox_Field_DCES_Language extends databox_Field_DCESAbstract
(see [RFC4646] http://www.ietf.org/rfc/rfc4646.txt)'; (see [RFC4646] http://www.ietf.org/rfc/rfc4646.txt)';
/** /**
* @SerializedName("URI")
* *
* @var string * @var string
*/ */

View File

@@ -9,6 +9,8 @@
* file that was distributed with this source code. * file that was distributed with this source code.
*/ */
use JMS\Serializer\Annotation\SerializedName;
/** /**
* *
* @package Databox DCES * @package Databox DCES
@@ -31,6 +33,7 @@ class databox_Field_DCES_Publisher extends databox_Field_DCESAbstract
available.'; available.';
/** /**
* @SerializedName("URI")
* *
* @var string * @var string
*/ */

View File

@@ -9,6 +9,8 @@
* file that was distributed with this source code. * file that was distributed with this source code.
*/ */
use JMS\Serializer\Annotation\SerializedName;
/** /**
* *
* @package Databox DCES * @package Databox DCES
@@ -30,6 +32,7 @@ class databox_Field_DCES_Relation extends databox_Field_DCESAbstract
protected $definition = 'A related resource.'; protected $definition = 'A related resource.';
/** /**
* @SerializedName("URI")
* *
* @var string * @var string
*/ */

View File

@@ -9,6 +9,8 @@
* file that was distributed with this source code. * file that was distributed with this source code.
*/ */
use JMS\Serializer\Annotation\SerializedName;
/** /**
* *
* @package Databox DCES * @package Databox DCES
@@ -31,6 +33,7 @@ class databox_Field_DCES_Rights extends databox_Field_DCESAbstract
in and over the resource.'; in and over the resource.';
/** /**
* @SerializedName("URI")
* *
* @var string * @var string
*/ */

View File

@@ -9,6 +9,8 @@
* file that was distributed with this source code. * file that was distributed with this source code.
*/ */
use JMS\Serializer\Annotation\SerializedName;
/** /**
* *
* @package Databox DCES * @package Databox DCES
@@ -31,6 +33,7 @@ class databox_Field_DCES_Source extends databox_Field_DCESAbstract
the described resource is derived.'; the described resource is derived.';
/** /**
* @SerializedName("URI")
* *
* @var string * @var string
*/ */

View File

@@ -9,6 +9,8 @@
* file that was distributed with this source code. * file that was distributed with this source code.
*/ */
use JMS\Serializer\Annotation\SerializedName;
/** /**
* *
* @package Databox DCES * @package Databox DCES
@@ -30,6 +32,7 @@ class databox_Field_DCES_Subject extends databox_Field_DCESAbstract
protected $definition = 'The topic of the resource.'; protected $definition = 'The topic of the resource.';
/** /**
* @SerializedName("URI")
* *
* @var string * @var string
*/ */

View File

@@ -9,6 +9,8 @@
* file that was distributed with this source code. * file that was distributed with this source code.
*/ */
use JMS\Serializer\Annotation\SerializedName;
/** /**
* *
* @package Databox DCES * @package Databox DCES
@@ -30,6 +32,7 @@ class databox_Field_DCES_Title extends databox_Field_DCESAbstract
protected $definition = 'A name given to the resource.'; protected $definition = 'A name given to the resource.';
/** /**
* @SerializedName("URI")
* *
* @var string * @var string
*/ */

View File

@@ -9,6 +9,8 @@
* file that was distributed with this source code. * file that was distributed with this source code.
*/ */
use JMS\Serializer\Annotation\SerializedName;
/** /**
* *
* @package Databox DCES * @package Databox DCES
@@ -30,6 +32,7 @@ class databox_Field_DCES_Type extends databox_Field_DCESAbstract
protected $definition = 'The nature or genre of the resource.'; protected $definition = 'The nature or genre of the resource.';
/** /**
* @SerializedName("URI")
* *
* @var string * @var string
*/ */

View File

@@ -0,0 +1,40 @@
<?php
class databox_Field_DCES_DCESTestCase extends PhraseanetPHPUnitAbstract
{
public function testGet_label()
{
$data = explode('_', get_class($this));
$name = str_replace('Test', '', array_pop($data));
$this->assertEquals($name, $this->object->get_label());
}
public function testGet_definition()
{
$this->assertTrue(is_string($this->object->get_definition()));
$this->assertTrue(strlen($this->object->get_definition()) > 18);
}
public function testGet_documentation_link()
{
$this->assertRegExp('/^http:\/\/dublincore\.org\/documents\/dces\/#[a-z]+$/', $this->object->get_documentation_link());
}
public function testSerialization()
{
$serializer = self::$DI['app']['serializer'];
$data = json_decode($serializer->serialize($this->object, 'json'), true);
$this->assertInternalType('array', $data);
$this->assertCount(3, $data);
$this->assertArrayHasKey('label', $data);
$this->assertArrayHasKey('definition', $data);
$this->assertArrayHasKey('URI', $data);
$this->assertInternalType('string', $data['label']);
$this->assertInternalType('string', $data['definition']);
$this->assertInternalType('string', $data['URI']);
}
}

View File

@@ -1,33 +1,10 @@
<?php <?php
class databox_Field_DCES_ContributorTest extends PhraseanetPHPUnitAbstract class databox_Field_DCES_ContributorTest extends databox_Field_DCES_DCESTestCase
{ {
/**
* @var databox_Field_DCES_Contributor
*/
protected $object;
public function setUp() public function setUp()
{ {
parent::setUp(); parent::setUp();
$this->object = new databox_Field_DCES_Contributor; $this->object = new databox_Field_DCES_Contributor;
} }
public function testGet_label()
{
$data = explode('_', __CLASS__);
$name = str_replace('Test', '', array_pop($data));
$this->assertEquals($name, $this->object->get_label());
}
public function testGet_definition()
{
$this->assertTrue(is_string($this->object->get_definition()));
$this->assertTrue(strlen($this->object->get_definition()) > 20);
}
public function testGet_documentation_link()
{
$this->assertRegExp('/^http:\/\/dublincore\.org\/documents\/dces\/#[a-z]+$/', $this->object->get_documentation_link());
}
} }

View File

@@ -1,33 +1,10 @@
<?php <?php
class databox_Field_DCES_CoverageTest extends PhraseanetPHPUnitAbstract class databox_Field_DCES_CoverageTest extends databox_Field_DCES_DCESTestCase
{ {
/**
* @var databox_Field_DCES_Coverage
*/
protected $object;
public function setUp() public function setUp()
{ {
parent::setUp(); parent::setUp();
$this->object = new databox_Field_DCES_Coverage; $this->object = new databox_Field_DCES_Coverage;
} }
public function testGet_label()
{
$data = explode('_', __CLASS__);
$name = str_replace('Test', '', array_pop($data));
$this->assertEquals($name, $this->object->get_label());
}
public function testGet_definition()
{
$this->assertTrue(is_string($this->object->get_definition()));
$this->assertTrue(strlen($this->object->get_definition()) > 20);
}
public function testGet_documentation_link()
{
$this->assertRegExp('/^http:\/\/dublincore\.org\/documents\/dces\/#[a-z]+$/', $this->object->get_documentation_link());
}
} }

View File

@@ -1,33 +1,10 @@
<?php <?php
class databox_Field_DCES_CreatorTest extends PhraseanetPHPUnitAbstract class databox_Field_DCES_CreatorTest extends databox_Field_DCES_DCESTestCase
{ {
/**
* @var databox_Field_DCES_Creator
*/
protected $object;
public function setUp() public function setUp()
{ {
parent::setUp(); parent::setUp();
$this->object = new databox_Field_DCES_Creator; $this->object = new databox_Field_DCES_Creator;
} }
public function testGet_label()
{
$data = explode('_', __CLASS__);
$name = str_replace('Test', '', array_pop($data));
$this->assertEquals($name, $this->object->get_label());
}
public function testGet_definition()
{
$this->assertTrue(is_string($this->object->get_definition()));
$this->assertTrue(strlen($this->object->get_definition()) > 20);
}
public function testGet_documentation_link()
{
$this->assertRegExp('/^http:\/\/dublincore\.org\/documents\/dces\/#[a-z]+$/', $this->object->get_documentation_link());
}
} }

View File

@@ -1,33 +1,10 @@
<?php <?php
class databox_Field_DCES_DateTest extends PhraseanetPHPUnitAbstract class databox_Field_DCES_DateTest extends databox_Field_DCES_DCESTestCase
{ {
/**
* @var databox_Field_DCES_Date
*/
protected $object;
public function setUp() public function setUp()
{ {
parent::setUp(); parent::setUp();
$this->object = new databox_Field_DCES_Date; $this->object = new databox_Field_DCES_Date;
} }
public function testGet_label()
{
$data = explode('_', __CLASS__);
$name = str_replace('Test', '', array_pop($data));
$this->assertEquals($name, $this->object->get_label());
}
public function testGet_definition()
{
$this->assertTrue(is_string($this->object->get_definition()));
$this->assertTrue(strlen($this->object->get_definition()) > 20);
}
public function testGet_documentation_link()
{
$this->assertRegExp('/^http:\/\/dublincore\.org\/documents\/dces\/#[a-z]+$/', $this->object->get_documentation_link());
}
} }

View File

@@ -1,33 +1,10 @@
<?php <?php
class databox_Field_DCES_DescriptionTest extends PhraseanetPHPUnitAbstract class databox_Field_DCES_DescriptionTest extends databox_Field_DCES_DCESTestCase
{ {
/**
* @var databox_Field_DCES_Description
*/
protected $object;
public function setUp() public function setUp()
{ {
parent::setUp(); parent::setUp();
$this->object = new databox_Field_DCES_Description; $this->object = new databox_Field_DCES_Description;
} }
public function testGet_label()
{
$data = explode('_', __CLASS__);
$name = str_replace('Test', '', array_pop($data));
$this->assertEquals($name, $this->object->get_label());
}
public function testGet_definition()
{
$this->assertTrue(is_string($this->object->get_definition()));
$this->assertTrue(strlen($this->object->get_definition()) > 20);
}
public function testGet_documentation_link()
{
$this->assertRegExp('/^http:\/\/dublincore\.org\/documents\/dces\/#[a-z]+$/', $this->object->get_documentation_link());
}
} }

View File

@@ -1,33 +1,10 @@
<?php <?php
class databox_Field_DCES_FormatTest extends PhraseanetPHPUnitAbstract class databox_Field_DCES_FormatTest extends databox_Field_DCES_DCESTestCase
{ {
/**
* @var databox_Field_DCES_Format
*/
protected $object;
public function setUp() public function setUp()
{ {
parent::setUp(); parent::setUp();
$this->object = new databox_Field_DCES_Format; $this->object = new databox_Field_DCES_Format;
} }
public function testGet_label()
{
$data = explode('_', __CLASS__);
$name = str_replace('Test', '', array_pop($data));
$this->assertEquals($name, $this->object->get_label());
}
public function testGet_definition()
{
$this->assertTrue(is_string($this->object->get_definition()));
$this->assertTrue(strlen($this->object->get_definition()) > 20);
}
public function testGet_documentation_link()
{
$this->assertRegExp('/^http:\/\/dublincore\.org\/documents\/dces\/#[a-z]+$/', $this->object->get_documentation_link());
}
} }

View File

@@ -1,33 +1,10 @@
<?php <?php
class databox_Field_DCES_IdentifierTest extends PhraseanetPHPUnitAbstract class databox_Field_DCES_IdentifierTest extends databox_Field_DCES_DCESTestCase
{ {
/**
* @var databox_Field_DCES_Identifier
*/
protected $object;
public function setUp() public function setUp()
{ {
parent::setUp(); parent::setUp();
$this->object = new databox_Field_DCES_Identifier; $this->object = new databox_Field_DCES_Identifier;
} }
public function testGet_label()
{
$data = explode('_', __CLASS__);
$name = str_replace('Test', '', array_pop($data));
$this->assertEquals($name, $this->object->get_label());
}
public function testGet_definition()
{
$this->assertTrue(is_string($this->object->get_definition()));
$this->assertTrue(strlen($this->object->get_definition()) > 20);
}
public function testGet_documentation_link()
{
$this->assertRegExp('/^http:\/\/dublincore\.org\/documents\/dces\/#[a-z]+$/', $this->object->get_documentation_link());
}
} }

View File

@@ -1,33 +1,10 @@
<?php <?php
class databox_Field_DCES_LanguageTest extends PhraseanetPHPUnitAbstract class databox_Field_DCES_LanguageTest extends databox_Field_DCES_DCESTestCase
{ {
/**
* @var databox_Field_DCES_Language
*/
protected $object;
public function setUp() public function setUp()
{ {
parent::setUp(); parent::setUp();
$this->object = new databox_Field_DCES_Language; $this->object = new databox_Field_DCES_Language;
} }
public function testGet_label()
{
$data = explode('_', __CLASS__);
$name = str_replace('Test', '', array_pop($data));
$this->assertEquals($name, $this->object->get_label());
}
public function testGet_definition()
{
$this->assertTrue(is_string($this->object->get_definition()));
$this->assertTrue(strlen($this->object->get_definition()) > 20);
}
public function testGet_documentation_link()
{
$this->assertRegExp('/^http:\/\/dublincore\.org\/documents\/dces\/#[a-z]+$/', $this->object->get_documentation_link());
}
} }

View File

@@ -1,33 +1,10 @@
<?php <?php
class databox_Field_DCES_PublisherTest extends PhraseanetPHPUnitAbstract class databox_Field_DCES_PublisherTest extends databox_Field_DCES_DCESTestCase
{ {
/**
* @var databox_Field_DCES_Publisher
*/
protected $object;
public function setUp() public function setUp()
{ {
parent::setUp(); parent::setUp();
$this->object = new databox_Field_DCES_Publisher; $this->object = new databox_Field_DCES_Publisher;
} }
public function testGet_label()
{
$data = explode('_', __CLASS__);
$name = str_replace('Test', '', array_pop($data));
$this->assertEquals($name, $this->object->get_label());
}
public function testGet_definition()
{
$this->assertTrue(is_string($this->object->get_definition()));
$this->assertTrue(strlen($this->object->get_definition()) > 20);
}
public function testGet_documentation_link()
{
$this->assertRegExp('/^http:\/\/dublincore\.org\/documents\/dces\/#[a-z]+$/', $this->object->get_documentation_link());
}
} }

View File

@@ -1,33 +1,10 @@
<?php <?php
class databox_Field_DCES_RelationTest extends PhraseanetPHPUnitAbstract class databox_Field_DCES_RelationTest extends databox_Field_DCES_DCESTestCase
{ {
/**
* @var databox_Field_DCES_Relation
*/
protected $object;
public function setUp() public function setUp()
{ {
parent::setUp(); parent::setUp();
$this->object = new databox_Field_DCES_Relation; $this->object = new databox_Field_DCES_Relation;
} }
public function testGet_label()
{
$data = explode('_', __CLASS__);
$name = str_replace('Test', '', array_pop($data));
$this->assertEquals($name, $this->object->get_label());
}
public function testGet_definition()
{
$this->assertTrue(is_string($this->object->get_definition()));
$this->assertTrue(strlen($this->object->get_definition()) > 18);
}
public function testGet_documentation_link()
{
$this->assertRegExp('/^http:\/\/dublincore\.org\/documents\/dces\/#[a-z]+$/', $this->object->get_documentation_link());
}
} }

View File

@@ -1,33 +1,10 @@
<?php <?php
class databox_Field_DCES_RightsTest extends PhraseanetPHPUnitAbstract class databox_Field_DCES_RightsTest extends databox_Field_DCES_DCESTestCase
{ {
/**
* @var databox_Field_DCES_Rights
*/
protected $object;
public function setUp() public function setUp()
{ {
parent::setUp(); parent::setUp();
$this->object = new databox_Field_DCES_Rights; $this->object = new databox_Field_DCES_Rights;
} }
public function testGet_label()
{
$data = explode('_', __CLASS__);
$name = str_replace('Test', '', array_pop($data));
$this->assertEquals($name, $this->object->get_label());
}
public function testGet_definition()
{
$this->assertTrue(is_string($this->object->get_definition()));
$this->assertTrue(strlen($this->object->get_definition()) > 20);
}
public function testGet_documentation_link()
{
$this->assertRegExp('/^http:\/\/dublincore\.org\/documents\/dces\/#[a-z]+$/', $this->object->get_documentation_link());
}
} }

View File

@@ -1,33 +1,10 @@
<?php <?php
class databox_Field_DCES_SourceTest extends PhraseanetPHPUnitAbstract class databox_Field_DCES_SourceTest extends databox_Field_DCES_DCESTestCase
{ {
/**
* @var databox_Field_DCES_Source
*/
protected $object;
public function setUp() public function setUp()
{ {
parent::setUp(); parent::setUp();
$this->object = new databox_Field_DCES_Source; $this->object = new databox_Field_DCES_Source;
} }
public function testGet_label()
{
$data = explode('_', __CLASS__);
$name = str_replace('Test', '', array_pop($data));
$this->assertEquals($name, $this->object->get_label());
}
public function testGet_definition()
{
$this->assertTrue(is_string($this->object->get_definition()));
$this->assertTrue(strlen($this->object->get_definition()) > 20);
}
public function testGet_documentation_link()
{
$this->assertRegExp('/^http:\/\/dublincore\.org\/documents\/dces\/#[a-z]+$/', $this->object->get_documentation_link());
}
} }

View File

@@ -1,33 +1,10 @@
<?php <?php
class databox_Field_DCES_SubjectTest extends PhraseanetPHPUnitAbstract class databox_Field_DCES_SubjectTest extends databox_Field_DCES_DCESTestCase
{ {
/**
* @var databox_Field_DCES_Subject
*/
protected $object;
public function setUp() public function setUp()
{ {
parent::setUp(); parent::setUp();
$this->object = new databox_Field_DCES_Subject; $this->object = new databox_Field_DCES_Subject;
} }
public function testGet_label()
{
$data = explode('_', __CLASS__);
$name = str_replace('Test', '', array_pop($data));
$this->assertEquals($name, $this->object->get_label());
}
public function testGet_definition()
{
$this->assertTrue(is_string($this->object->get_definition()));
$this->assertTrue(strlen($this->object->get_definition()) > 20);
}
public function testGet_documentation_link()
{
$this->assertRegExp('/^http:\/\/dublincore\.org\/documents\/dces\/#[a-z]+$/', $this->object->get_documentation_link());
}
} }

View File

@@ -1,33 +1,10 @@
<?php <?php
class databox_Field_DCES_TitleTest extends PhraseanetPHPUnitAbstract class databox_Field_DCES_TitleTest extends databox_Field_DCES_DCESTestCase
{ {
/**
* @var databox_Field_DCES_Title
*/
protected $object;
public function setUp() public function setUp()
{ {
parent::setUp(); parent::setUp();
$this->object = new databox_Field_DCES_Title; $this->object = new databox_Field_DCES_Title;
} }
public function testGet_label()
{
$data = explode('_', __CLASS__);
$name = str_replace('Test', '', array_pop($data));
$this->assertEquals($name, $this->object->get_label());
}
public function testGet_definition()
{
$this->assertTrue(is_string($this->object->get_definition()));
$this->assertTrue(strlen($this->object->get_definition()) > 20);
}
public function testGet_documentation_link()
{
$this->assertRegExp('/^http:\/\/dublincore\.org\/documents\/dces\/#[a-z]+$/', $this->object->get_documentation_link());
}
} }

View File

@@ -1,33 +1,10 @@
<?php <?php
class databox_Field_DCES_TypeTest extends PhraseanetPHPUnitAbstract class databox_Field_DCES_TypeTest extends databox_Field_DCES_DCESTestCase
{ {
/**
* @var databox_Field_DCES_Type
*/
protected $object;
public function setUp() public function setUp()
{ {
parent::setUp(); parent::setUp();
$this->object = new databox_Field_DCES_Type; $this->object = new databox_Field_DCES_Type;
} }
public function testGet_label()
{
$data = explode('_', __CLASS__);
$name = str_replace('Test', '', array_pop($data));
$this->assertEquals($name, $this->object->get_label());
}
public function testGet_definition()
{
$this->assertTrue(is_string($this->object->get_definition()));
$this->assertTrue(strlen($this->object->get_definition()) > 20);
}
public function testGet_documentation_link()
{
$this->assertRegExp('/^http:\/\/dublincore\.org\/documents\/dces\/#[a-z]+$/', $this->object->get_documentation_link());
}
} }