test/snac/server/database/DBUtilTest.php
/**
     * Parse a file, and write to the db.
     * Get the just-inserted constellation back from the db.
     * Verify versoin and id of constellation read from db.
     * If the constellation has a function, verify non-zero version and id for the function.
     * Update the constellation, and quickly check version and id.
     *
     */
Parse a file, and write to the db.
Get the just-inserted constellation back from the db.
Verify versoin and id of constellation read from db.
If the constellation has a function, verify non-zero version and id for the function.
Update the constellation, and quickly check version and id.
Parse a file and write to the db . Get the just - inserted constellation back from the db . Verify versoin and id of constellation read from db . If the constellation has a function verify non - zero version and id for the function . Update the constellation and quickly check version and id .
public function testParseToDB()
    {
        $this->logger->addDebug("Starting: " . __METHOD__);
        $eParser = new \snac\util\EACCPFParser();
        $eParser->setConstellationOperation("insert");
        $constellationObj = $eParser->parseFile("test/snac/server/database/99166-w6f2061g.xml");
        $this->insertResources($constellationObj);
        $retObj = $this->dbu->writeConstellation($this->user,
                                                 $constellationObj,
                                                 'machine ingest of hand-crafted, full CPF test record',
                                                 'ingest cpf');
        $this->assertNotNull($retObj);
        $cObj = $this->dbu->readConstellation($retObj->getID(), $retObj->getVersion());
        $this->assertNotNull($cObj);
        $this->assertTrue($cObj->getVersion() > 0);
        $this->assertTrue($cObj->getID() > 0);
        $this->assertEquals($retObj->getID(), $cObj->getID());
        $this->assertEquals($retObj->getVersion(), $cObj->getVersion());
        if (($fObj = $cObj->getActivities()))
        {
            $this->assertTrue($fObj->getVersion() > 0);
            $this->assertTrue($fObj->getID() > 0);
        }
        $cObj->setOperation(\snac\data\AbstractData::$OPERATION_UPDATE);
        $updatedObj = $this->dbu->writeConstellation($this->user,
                                                     $cObj,
                                                     'updating constellation for test',
                                                     'ingest cpf');
        $this->dbu->writeConstellationStatus($this->user, $updatedObj->getID(), 'needs review');
        $this->assertTrue($retObj->getVersion() < $updatedObj->getVersion());
        $this->assertEquals($retObj->getID(), $updatedObj->getID());
        $this->logger->addDebug("Ending: " . __METHOD__);
    }
public function testParseToDB ( ) { $ this -> logger -> addDebug ( " Starting:  " . __METHOD__ ) ; $ eParser = new \ snac \ util \ EACCPFParser ( ) ; $ eParser -> setConstellationOperation ( " insert " ) ; $ constellationObj = $ eParser -> parseFile ( " test/snac/server/database/99166-w6f2061g.xml " ) ; $ this -> insertResources ( $ constellationObj ) ; $ retObj = $ this -> dbu -> writeConstellation ( $ this -> user , $ constellationObj , 'machine ingest of hand-crafted, full CPF test record' , 'ingest cpf' ) ; $ this -> assertNotNull ( $ retObj ) ; $ cObj = $ this -> dbu -> readConstellation ( $ retObj -> getID ( ) , $ retObj -> getVersion ( ) ) ; $ this -> assertNotNull ( $ cObj ) ; $ this -> assertTrue ( $ cObj -> getVersion ( ) > 0 ) ; $ this -> assertTrue ( $ cObj -> getID ( ) > 0 ) ; $ this -> assertEquals ( $ retObj -> getID ( ) , $ cObj -> getID ( ) ) ; $ this -> assertEquals ( $ retObj -> getVersion ( ) , $ cObj -> getVersion ( ) ) ; if ( ( $ fObj = $ cObj -> getActivities ( ) ) ) { $ this -> assertTrue ( $ fObj -> getVersion ( ) > 0 ) ; $ this -> assertTrue ( $ fObj -> getID ( ) > 0 ) ; } $ cObj -> setOperation ( \ snac \ data \ AbstractData :: $ OPERATION_UPDATE ) ; $ updatedObj = $ this -> dbu -> writeConstellation ( $ this -> user , $ cObj , 'updating constellation for test' , 'ingest cpf' ) ; $ this -> dbu -> writeConstellationStatus ( $ this -> user , $ updatedObj -> getID ( ) , 'needs review' ) ; $ this -> assertTrue ( $ retObj -> getVersion ( ) < $ updatedObj -> getVersion ( ) ) ; $ this -> assertEquals ( $ retObj -> getID ( ) , $ updatedObj -> getID ( ) ) ; $ this -> logger -> addDebug ( " Ending:  " . __METHOD__ ) ; }
Parse a file, and write to the db.
Parse a file and write to the db .
// Parse a file, write the data into the db. // printf("\nAfter first write version: %s\n", $retObj->getVersion()); /*
         * Get the constellation that was just inserted. As of Dec 2015, the inserted and selected
         * constellation won't be identical due to unresolved treatment of place and maintenance data.
         *
         * Mar 4 2016 Now that writeConstellation() returns the $constellationObj with id and version filled
         * in, and now that place, date, language, SCM are all working, things are better. Still, if a partial
         * update is done, then the partial is what is returned by writeConstellation() and that won't match
         * reading the full constellation from the db.
         *
         */ /*
         * Check a couple of db info values for the Constellation. This is the constellation version aka
         * max(version) aka max(version_history.id) for the constellation. This is also
         * version_history.ic_id aka the constellation id (which is not the per-table record id since there
         * is no singular table for a constellation).
         */ /*
         * Optional assertions, depending on if our constellation has function.  This is kind of a
         * weak idea, but until we have a test constellation with all sub-object, this is it.
         *
         * Since this is a function, getVersion() returns the version of this function which may be <= the constellation.
         *
         * Also, this is the per-table record id aka table.id (not the constellation ic_id).
         */ /*
         * Test that an update creates a new version number.
         *
         * How can this test that the constellation was successfully updated? We need more SQL functions to
         * look at parts of the newly updated constellation records in the various tables.
         */ /*
         * printf("\nret: %s cons: %s upd: %s\n",
         *        $retObj->getID(),
         *        $cObj->getID(),
         *        $updatedObj->getID());
         */