diff -r 7b2dcd2b31c1 -r 74fba571487e server/src/tests/Models/DocumentTest.php --- a/server/src/tests/Models/DocumentTest.php Mon Feb 06 16:05:02 2017 +0100 +++ b/server/src/tests/Models/DocumentTest.php Wed Feb 08 15:25:24 2017 +0100 @@ -36,6 +36,16 @@ $this->assertEquals(config('corpusparole.corpus_id_scheme').'crdo-CFPP2000_35_SOUNDid',$doc->getId(),'Must have the correct id'); } + public function testCocoonId() { + $doc = new Document(config('corpusparole.corpus_doc_id_base_uri')."crdo-CFPP2000_35_SOUND", $this->inputGraphes['TEST']); + $this->assertEquals('crdo-CFPP2000_35_SOUND',$doc->getCocoonId(),'Must have the correct cocoon id'); + } + public function testCocoonIdWithIdBefore() { + $doc = new Document(config('corpusparole.corpus_doc_id_base_uri')."crdo-CFPP2000_35_SOUND", $this->inputGraphes['TEST']); + $this->assertEquals(config('corpusparole.corpus_id_scheme').'crdo-CFPP2000_35_SOUNDid',$doc->getId(),'Must have the correct id'); + $this->assertEquals('crdo-CFPP2000_35_SOUND',$doc->getCocoonId(),'Must have the correct cocoon id'); + } + public function testTitle() { $this->assertNotNull($this->inputGraphes['TEST'], 'Graph shoud not be null'); @@ -427,13 +437,37 @@ $json = $doc->jsonSerialize(); $this->assertTrue(is_array($json), 'Returned json must be an array'); - $this->assertEquals( - [ "id", "uri", "title", "languages", "modified", "issued", + $expectedKeys = [ "id", "cocoonId", "uri", "title", "languages", "modified", "issued", "created", "publishers", "contributors", "subjects", "types", "transcript", "mediaArray", "geoInfo", "descriptions", - "alternativeTitle", "rights"], - array_keys($json) - ); + "alternativeTitle", "rights"]; + sort($expectedKeys); + $arrayKeys = array_keys($json); + sort($arrayKeys); + $this->assertEquals($expectedKeys, $arrayKeys); + $this->assertEquals(sprintf('%1$s/crdo-CFPP2000_35_SOUNDid', config('corpusparole.handle_prefix')), $json['id']); + $this->assertTrue(is_array($json['transcript'])); + $this->assertTrue(is_array($json['mediaArray'])); + $this->assertTrue(is_array($json['subjects'])); + $this->assertTrue(is_array($json['types'])); + + } + + public function testJsonSerializeSetCountryCode() { + $doc = new Document(config('corpusparole.corpus_doc_id_base_uri')."crdo-CFPP2000_35_SOUND", $this->inputGraphes['TEST']); + + $doc->setCountryCode('3017382'); + $json = $doc->jsonSerialize(); + + $this->assertTrue(is_array($json), 'Returned json must be an array'); + $expectedKeys = [ "id", "cocoonId", "uri", "title", "languages", "modified", "issued", + "created", "publishers", "contributors", "subjects", "types", + "transcript", "mediaArray", "geoInfo", "descriptions", + "alternativeTitle", "rights", 'countryCode' ]; + sort($expectedKeys); + $arrayKeys = array_keys($json); + sort($arrayKeys); + $this->assertEquals($expectedKeys, $arrayKeys); $this->assertEquals(sprintf('%1$s/crdo-CFPP2000_35_SOUNDid', config('corpusparole.handle_prefix')), $json['id']); $this->assertTrue(is_array($json['transcript'])); $this->assertTrue(is_array($json['mediaArray']));