Changeset 997

Show
Ignore:
Timestamp:
10/28/07 13:25:51 (1 year ago)
Author:
mikey
Message:

return hint whether an update or an insert was processed

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/src/main/php/net/stubbles/rdbms/persistence/serializer/stubDatabaseSerializer.php

    r951 r997  
    3535     */ 
    3636    protected $connection; 
     37    /** 
     38     * data has been inserted 
     39     */ 
     40    const INSERT                = 'insert'; 
     41    /** 
     42     * data has been updated 
     43     */ 
     44    const UPDATE                = 'update'; 
    3745 
    3846    /** 
     
    8088     * 
    8189     * @param   stubObject                       $entity 
     90     * @return  string 
    8291     * @throws  stubDatabaseSerializerException 
    8392     * @throws  stubPersistenceException 
     
    144153            throw new stubDatabaseSerializerException('Can not persist ' . $entityClass->getFullQualifiedClassName() . ': a database error occured.', $dbe); 
    145154        } 
     155         
     156        return (($tableRow->hasCriterion() === true) ? (self::UPDATE) : (self::INSERT)); 
    146157    } 
    147158 
  • trunk/src/test/php/net/stubbles/rdbms/persistence/serializer/stubDatabaseSerializerTestCase.php

    r951 r997  
    124124        $this->mockConnection->expectCallcount('exec', 1); 
    125125        $this->mockQueryBuilder->setInsertQueries(array('foo' => 'foo')); 
    126         $this->dbSerializer->serialize($singlePrimaryKeyEntity); 
     126        $this->assertEqual($this->dbSerializer->serialize($singlePrimaryKeyEntity), stubDatabaseSerializer::INSERT); 
    127127        $this->assertEqual($this->mockQueryBuilder->getCallCount('createInsert'), 1); 
    128128        $this->assertEqual($this->mockQueryBuilder->getCallCount('createUpdate'), 0); 
     
    146146        $this->mockConnection->expectCallcount('exec', 1); 
    147147        $this->mockQueryBuilder->setUpdateQueries(array('foo' => 'foo')); 
    148         $this->dbSerializer->serialize($singlePrimaryKeyEntity); 
     148        $this->assertEqual($this->dbSerializer->serialize($singlePrimaryKeyEntity), stubDatabaseSerializer::UPDATE); 
    149149        $this->assertEqual($this->mockQueryBuilder->getCallCount('createInsert'), 0); 
    150150        $this->assertEqual($this->mockQueryBuilder->getCallCount('createUpdate'), 1);