test/snac/server/database/DBUtilTest.php
/**
     * Update contributor
     *
     * Modify a contributor without any changes happening to the nameEntry the contributor refers to.
     */
Update contributor
Modify a contributor without any changes happening to the nameEntry the contributor refers to.
Update contributor Modify a contributor without any changes happening to the nameEntry the contributor refers to .
public function testUpdateContrib()
    {
        $this->logger->addDebug("Starting: " . __METHOD__);
        $eParser = new \snac\util\EACCPFParser();
        $eParser->setConstellationOperation(\snac\data\AbstractData::$OPERATION_INSERT);
        $cObj = $eParser->parseFile("test/snac/server/database/test_record.xml");
        $firstJSON = $cObj->toJSON();
        $retObj = $this->dbu->writeConstellation($this->user,
                                                 $cObj,
                                                 'bulk ingest of merged',
                                                 'ingest cpf');
        $this->dbu->writeConstellationStatus($this->user, $retObj->getID(), 'published', 'change status to published');
        if (0)
        {
            $cbObj = $retObj->getNameEntries()[0];
            printf("\ndbutiltest post write name operation: %s\n", $cbObj->getOperation());
            $op = call_user_func(array($cbObj, 'getOperation'));
            $cbObj->setOperation(\snac\data\AbstractData::$OPERATION_UPDATE);
            printf("\ndbutiltest after callback setOperation op: %s operation: %s\n", $op, $cbObj->getOperation());
        }
        $origContribName = $retObj->getNameEntries()[0]->getContributors()[0]->getName();
        $nameVersion = $retObj->getNameEntries()[0]->getVersion();
        $contribVersion = $retObj->getNameEntries()[0]->getContributors()[0]->getVersion();
        $newRetObj = $this->dbu->readConstellation($retObj->getID(), $retObj->getVersion());
        unset($retObj);
        $newRetObj->getNameEntries()[0]->getContributors()[0]->setOperation(\snac\data\AbstractData::$OPERATION_UPDATE);
        $modNameID = $newRetObj->getNameEntries()[0]->getContributors()[0]->getID();
        $newRetObj->getNameEntries()[0]->getContributors()[0]->setName("TestName");
        $postWriteObj = $this->dbu->writeConstellation($this->user,
                                                       $newRetObj,
                                                       'change contributor name',
                                                       'ingest cpf');
        $this->dbu->writeConstellationStatus($this->user, $postWriteObj->getID(), 'published', 'probably already published, but setting again');
        $newObj = $this->dbu->readConstellation($postWriteObj->getID(),
                                                $postWriteObj->getVersion());
        $newContribName = $newObj->getNameEntries()[0]->getContributors()[0]->getName();
        $newNameVersion = $newObj->getNameEntries()[0]->getVersion();
        $newContribVersion = $newObj->getNameEntries()[0]->getContributors()[0]->getVersion();
        $this->assertEquals("TestName", $newContribName);
        $this->assertEquals($nameVersion, $newNameVersion);
        $this->assertTrue($newContribVersion > $contribVersion);
        $this->logger->addDebug("Ending: " . __METHOD__);
    }
public function testUpdateContrib ( ) { $ this -> logger -> addDebug ( " Starting:  " . __METHOD__ ) ; $ eParser = new \ snac \ util \ EACCPFParser ( ) ; $ eParser -> setConstellationOperation ( \ snac \ data \ AbstractData :: $ OPERATION_INSERT ) ; $ cObj = $ eParser -> parseFile ( " test/snac/server/database/test_record.xml " ) ; $ firstJSON = $ cObj -> toJSON ( ) ; $ retObj = $ this -> dbu -> writeConstellation ( $ this -> user , $ cObj , 'bulk ingest of merged' , 'ingest cpf' ) ; $ this -> dbu -> writeConstellationStatus ( $ this -> user , $ retObj -> getID ( ) , 'published' , 'change status to published' ) ; if ( 0 ) { $ cbObj = $ retObj -> getNameEntries ( ) [ 0 ] ; printf ( " \n dbutiltest post write name operation: %s \n " , $ cbObj -> getOperation ( ) ) ; $ op = call_user_func ( array ( $ cbObj , 'getOperation' ) ) ; $ cbObj -> setOperation ( \ snac \ data \ AbstractData :: $ OPERATION_UPDATE ) ; printf ( " \n dbutiltest after callback setOperation op: %s operation: %s \n " , $ op , $ cbObj -> getOperation ( ) ) ; } $ origContribName = $ retObj -> getNameEntries ( ) [ 0 ] -> getContributors ( ) [ 0 ] -> getName ( ) ; $ nameVersion = $ retObj -> getNameEntries ( ) [ 0 ] -> getVersion ( ) ; $ contribVersion = $ retObj -> getNameEntries ( ) [ 0 ] -> getContributors ( ) [ 0 ] -> getVersion ( ) ; $ newRetObj = $ this -> dbu -> readConstellation ( $ retObj -> getID ( ) , $ retObj -> getVersion ( ) ) ; unset ( $ retObj ) ; $ newRetObj -> getNameEntries ( ) [ 0 ] -> getContributors ( ) [ 0 ] -> setOperation ( \ snac \ data \ AbstractData :: $ OPERATION_UPDATE ) ; $ modNameID = $ newRetObj -> getNameEntries ( ) [ 0 ] -> getContributors ( ) [ 0 ] -> getID ( ) ; $ newRetObj -> getNameEntries ( ) [ 0 ] -> getContributors ( ) [ 0 ] -> setName ( " TestName " ) ; $ postWriteObj = $ this -> dbu -> writeConstellation ( $ this -> user , $ newRetObj , 'change contributor name' , 'ingest cpf' ) ; $ this -> dbu -> writeConstellationStatus ( $ this -> user , $ postWriteObj -> getID ( ) , 'published' , 'probably already published, but setting again' ) ; $ newObj = $ this -> dbu -> readConstellation ( $ postWriteObj -> getID ( ) , $ postWriteObj -> getVersion ( ) ) ; $ newContribName = $ newObj -> getNameEntries ( ) [ 0 ] -> getContributors ( ) [ 0 ] -> getName ( ) ; $ newNameVersion = $ newObj -> getNameEntries ( ) [ 0 ] -> getVersion ( ) ; $ newContribVersion = $ newObj -> getNameEntries ( ) [ 0 ] -> getContributors ( ) [ 0 ] -> getVersion ( ) ; $ this -> assertEquals ( " TestName " , $ newContribName ) ; $ this -> assertEquals ( $ nameVersion , $ newNameVersion ) ; $ this -> assertTrue ( $ newContribVersion > $ contribVersion ) ; $ this -> logger -> addDebug ( " Ending:  " . __METHOD__ ) ; }
Update contributor
 Modify a contributor without any changes happening to the nameEntry the contributor refers to.
Update contributor Modify a contributor without any changes happening to the nameEntry the contributor refers to .
// call_user_func_array(array($cbObj, 'setOperation'), array('foo')); /*
         * All the operations are set for $retObj, and there is no way to clear them. Read the constellation
         * from disk to get a new constellation with no operations. Then modify the new copy of the constellation as planned.
         */