test/snac/util/EACCPFParserTest.php
/**
     * Test that the parser correctly parses a given sample file
     */
Test that the parser correctly parses a given sample file
Test that the parser correctly parses a given sample file
public function testParseFile() {
        $parser = new \snac\util\EACCPFParser();
        try {
            $identity = $parser->parseFile("test/snac/util/eac-cpf/test1.xml");
            $this->assertEquals("http://n2t.net/ark:/99166/w6kw9c2x", $identity->getArk());
            $this->assertEquals($identity->getEntityType()->getTerm(), "person");
            $this->assertEquals("SNAC: Social Networks and Archival Context Project", $identity->getMaintenanceAgency());
            $this->assertNotEmpty($identity->getLanguagesUsed(), "Did not parse any languages used");
            $lang = $identity->getLanguagesUsed()[0];
            $this->assertEquals("eng", $lang->getLanguage()->getTerm());
            $this->assertEquals("Latn", $lang->getScript()->getTerm());
        } catch (\snac\exceptions\SNACParserException $e) {
            $this->fail("Hit exception: " . $e->getMessage());
        }
    }
public function testParseFile ( ) { $ parser = new \ snac \ util \ EACCPFParser ( ) ; try { $ identity = $ parser -> parseFile ( " test/snac/util/eac-cpf/test1.xml " ) ; $ this -> assertEquals ( " http://n2t.net/ark:/99166/w6kw9c2x " , $ identity -> getArk ( ) ) ; $ this -> assertEquals ( $ identity -> getEntityType ( ) -> getTerm ( ) , " person " ) ; $ this -> assertEquals ( " SNAC: Social Networks and Archival Context Project " , $ identity -> getMaintenanceAgency ( ) ) ; $ this -> assertNotEmpty ( $ identity -> getLanguagesUsed ( ) , " Did not parse any languages used " ) ; $ lang = $ identity -> getLanguagesUsed ( ) [ 0 ] ; $ this -> assertEquals ( " eng " , $ lang -> getLanguage ( ) -> getTerm ( ) ) ; $ this -> assertEquals ( " Latn " , $ lang -> getScript ( ) -> getTerm ( ) ) ; } catch ( \ snac \ exceptions \ SNACParserException $ e ) { $ this -> fail ( " Hit exception:  " . $ e -> getMessage ( ) ) ; } }
Test that the parser correctly parses a given sample file
Test that the parser correctly parses a given sample file
// $parser->setVocabulary(new TestVocabulary()); // Parse the file into an identity // Check that attributes matched the parsed versions // Check that the entity type is person // Check that the language Used makes it through