test/snac/util/EACCPFSerializerTest.php
/**
     * Test basic XML rendering
     *
     * The simplest test is number of lines. This test is quite sensitive and a bit of a problem since this
     * has to be changed everytime the template gets an update that changes number of lines of output.
     *
     * Other tests do a Constellation->equals().
     */
Test basic XML rendering
The simplest test is number of lines. This test is quite sensitive and a bit of a problem since this
has to be changed everytime the template gets an update that changes number of lines of output.

Other tests do a Constellation->equals().
Test basic XML rendering The simplest test is number of lines . This test is quite sensitive and a bit of a problem since this has to be changed everytime the template gets an update that changes number of lines of output . Other tests do a Constellation - > equals () .
public function testRenderWithJing() {
        $cpfRng = \snac\Config::$RNG_DIR . "/cpf.rng";
        $jingCmd = '/usr/bin/jing';
        if (file_exists($cpfRng) && file_exists($jingCmd)) {
            $xCon = $this->dbu->readPublishedConstellationByARK('http://n2t.net/ark:/99166/w6fr4rx5');
            $eSerializer = new \snac\util\EACCPFSerializer();
            $cpfXML = $eSerializer->serialize($xCon);
            $fn = '/tmp/' . uniqid(rand(), true) . '.xml';
            $cfile = fopen($fn, 'w');
            fwrite($cfile, $cpfXML);
            fclose($cfile);
            $jingResult = `$jingCmd $cpfRng $fn`;
            $this->logger->addDebug("jing result (should be empty): $jingResult");
            $this->logger->addDebug("temp xml: $fn");
            unlink($fn);
        } else {
            $msg = "Not checking via jing. ";
            if (! file_exists($cpfRng)) {
                $msg .= "File not exists: $cpfRng ";
            }
            if (! file_exists($jingCmd)) {
                $msg .= "File not exists: $jingCmd";
            }
            $this->logger->addDebug($msg);
        }
    }
public function testRenderWithJing ( ) { $ cpfRng = \ snac \ Config :: $ RNG_DIR . " /cpf.rng " ; $ jingCmd = '/usr/bin/jing' ; if ( file_exists ( $ cpfRng ) && file_exists ( $ jingCmd ) ) { $ xCon = $ this -> dbu -> readPublishedConstellationByARK ( 'http://n2t.net/ark:/99166/w6fr4rx5' ) ; $ eSerializer = new \ snac \ util \ EACCPFSerializer ( ) ; $ cpfXML = $ eSerializer -> serialize ( $ xCon ) ; $ fn = '/tmp/' . uniqid ( rand ( ) , true ) . '.xml' ; $ cfile = fopen ( $ fn , 'w' ) ; fwrite ( $ cfile , $ cpfXML ) ; fclose ( $ cfile ) ; $ jingResult = ` $ jingCmd $ cpfRng $ fn ` ; $ this -> logger -> addDebug ( " jing result (should be empty):  $ jingResult " ) ; $ this -> logger -> addDebug ( " temp xml:  $ fn " ) ; unlink ( $ fn ) ; } else { $ msg = " Not checking via jing.  " ; if ( ! file_exists ( $ cpfRng ) ) { $ msg .= " File not exists:  $ cpfRng " ; } if ( ! file_exists ( $ jingCmd ) ) { $ msg .= " File not exists:  $ jingCmd " ; } $ this -> logger -> addDebug ( $ msg ) ; } }
Test basic XML rendering
 The simplest test is number of lines.
Test basic XML rendering The simplest test is number of lines .
/*
         * A bug was revealed by /data/merge/99166-w6fr4rx5.xml  http://n2t.net/ark:/99166/w6fr4rx5
         *
         * The composer script automatically pulls in the cpf.rng file into the main repository. It should
         * then always deposit the newest rng file in vendor/npm-asset/eac-validator/rng. Use the const
         * RNG_DIR for that path.
         *
         * In other words, if the test below doesn't run due to missing cpf.rng, then you should run:
         *
         * composer update
         *
         * Jing's error and warning output goes to stdout, so we should see it in $jingResult. No need to io
         * redirect stderr from the jing command.
         *
         * Class path constants don't interpolate, so we have to use the . operator to build the full
         * filename.
         */ /*
             * $cfile = fopen('cpf_data.txt', 'w');
             * fwrite($cfile, $xCon->toJSON());
             * fclose($cfile);
             */ /*
             * Delete before calling assert, so that a failed assert doesn't leave our temp file.
             *
             * Comment this out for debugging. The file is in /tmp.
             */ /*
             * Assertion disabled until we resolve the regex for snac:preferenceScore
             */ // $this->assertTrue($jingResult == '');