Changeset 4364 for trunk/tests/Orm

Show
Ignore:
Timestamp:
05/13/08 22:20:34 (8 months ago)
Author:
romanb
Message:

Doctrine_Record renamed. Hydration refactored. Other refactorings.

Location:
trunk/tests/Orm
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • trunk/tests/Orm/Hydration/BasicHydrationTest.php

    r4342 r4364  
    55class Orm_Hydration_BasicHydrationTest extends Doctrine_OrmTestCase 
    66{ 
     7    private $_em; 
     8     
    79    protected function setUp() 
    810    { 
    911        parent::setUp(); 
     12        $this->_em = $this->sharedFixture['connection']; 
    1013    } 
    1114     
     
    1922    } 
    2023     
     24    /** Helper method */ 
     25    private function _createParserResult($stmt, $queryComponents, $tableToClassAliasMap, 
     26            $hydrationMode, $isMixedQuery = false) 
     27    { 
     28        $parserResult = new Doctrine_Query_ParserResultDummy(); 
     29        $parserResult->setDatabaseStatement($stmt); 
     30        $parserResult->setHydrationMode($hydrationMode); 
     31        $parserResult->setQueryComponents($queryComponents); 
     32        $parserResult->setTableToClassAliasMap($tableToClassAliasMap); 
     33        $parserResult->setMixedQuery($isMixedQuery); 
     34        return $parserResult; 
     35    } 
     36     
    2137    /** 
    2238     * Select u.id, u.name from CmsUser u 
     
    2541     */ 
    2642    public function testNewHydrationSimpleEntityQuery($hydrationMode) 
    27     { 
     43    {         
    2844        // Faked query components 
    2945        $queryComponents = array( 
     
    5672             
    5773        $stmt = new Doctrine_HydratorMockStatement($resultSet); 
    58         $hydrator = new Doctrine_HydratorNew(); 
    59         $hydrator->setQueryComponents($queryComponents); 
    60          
    61         $result = $hydrator->hydrateResultSet($stmt, $tableAliasMap, $hydrationMode);         
     74        $hydrator = new Doctrine_HydratorNew($this->_em); 
     75         
     76        $result = $hydrator->hydrateResultSet($this->_createParserResult( 
     77                $stmt, $queryComponents, $tableAliasMap, $hydrationMode));         
    6278         
    6379        $this->assertEquals(2, count($result)); 
     
    6985        if ($hydrationMode == Doctrine::HYDRATE_RECORD) { 
    7086            $this->assertTrue($result instanceof Doctrine_Collection); 
    71             $this->assertTrue($result[0] instanceof Doctrine_Record); 
    72             $this->assertTrue($result[1] instanceof Doctrine_Record); 
     87            $this->assertTrue($result[0] instanceof Doctrine_Entity); 
     88            $this->assertTrue($result[1] instanceof Doctrine_Entity); 
    7389        } else { 
    7490            $this->assertTrue(is_array($result)); 
     
    136152             
    137153        $stmt = new Doctrine_HydratorMockStatement($resultSet); 
    138         $hydrator = new Doctrine_HydratorNew(); 
    139         $hydrator->setQueryComponents($queryComponents); 
    140          
    141         $hydrator->setResultMixed(true); 
    142          
    143         $result = $hydrator->hydrateResultSet($stmt, $tableAliasMap, $hydrationMode); 
     154        $hydrator = new Doctrine_HydratorNew($this->_em); 
     155         
     156        $result = $hydrator->hydrateResultSet($this->_createParserResult( 
     157                $stmt, $queryComponents, $tableAliasMap, $hydrationMode, true)); 
    144158        //var_dump($result); 
    145159         
     
    162176         
    163177        if ($hydrationMode == Doctrine::HYDRATE_RECORD) { 
    164             $this->assertTrue($result[0][0] instanceof Doctrine_Record); 
     178            $this->assertTrue($result[0][0] instanceof Doctrine_Entity); 
    165179            $this->assertTrue($result[0][0]['phonenumbers'] instanceof Doctrine_Collection); 
    166             $this->assertTrue($result[0][0]['phonenumbers'][0] instanceof Doctrine_Record); 
    167             $this->assertTrue($result[0][0]['phonenumbers'][1] instanceof Doctrine_Record); 
    168             $this->assertTrue($result[1][0] instanceof Doctrine_Record); 
     180            $this->assertTrue($result[0][0]['phonenumbers'][0] instanceof Doctrine_Entity); 
     181            $this->assertTrue($result[0][0]['phonenumbers'][1] instanceof Doctrine_Entity); 
     182            $this->assertTrue($result[1][0] instanceof Doctrine_Entity); 
    169183            $this->assertTrue($result[1][0]['phonenumbers'] instanceof Doctrine_Collection); 
    170184        }  
     
    224238             
    225239        $stmt = new Doctrine_HydratorMockStatement($resultSet); 
    226         $hydrator = new Doctrine_HydratorNew(); 
    227         $hydrator->setQueryComponents($queryComponents); 
    228          
    229         $hydrator->setResultMixed(true); 
    230          
    231         $result = $hydrator->hydrateResultSet($stmt, $tableAliasMap, $hydrationMode); 
     240        $hydrator = new Doctrine_HydratorNew($this->_em); 
     241         
     242        $result = $hydrator->hydrateResultSet($this->_createParserResult( 
     243                $stmt, $queryComponents, $tableAliasMap, $hydrationMode, true)); 
    232244        //var_dump($result); 
    233245         
     
    243255         
    244256        if ($hydrationMode == Doctrine::HYDRATE_RECORD) { 
    245             $this->assertTrue($result[0][0] instanceof Doctrine_Record); 
    246             $this->assertTrue($result[1][0] instanceof Doctrine_Record); 
     257            $this->assertTrue($result[0][0] instanceof Doctrine_Entity); 
     258            $this->assertTrue($result[1][0] instanceof Doctrine_Entity); 
    247259        } 
    248260    } 
     
    309321             
    310322        $stmt = new Doctrine_HydratorMockStatement($resultSet); 
    311         $hydrator = new Doctrine_HydratorNew(); 
    312         $hydrator->setQueryComponents($queryComponents); 
    313          
    314         // give the hydrator an artificial hint 
    315         $hydrator->setResultMixed(true); 
    316          
    317         $result = $hydrator->hydrateResultSet($stmt, $tableAliasMap, $hydrationMode); 
     323        $hydrator = new Doctrine_HydratorNew($this->_em); 
     324         
     325        $result = $hydrator->hydrateResultSet($this->_createParserResult( 
     326                $stmt, $queryComponents, $tableAliasMap, $hydrationMode, true)); 
    318327        if ($hydrationMode == Doctrine::HYDRATE_ARRAY) { 
    319328            //var_dump($result); 
     
    341350         
    342351        if ($hydrationMode == Doctrine::HYDRATE_RECORD) { 
    343             $this->assertTrue($result[0]['1'] instanceof Doctrine_Record); 
    344             $this->assertTrue($result[1]['2'] instanceof Doctrine_Record); 
     352            $this->assertTrue($result[0]['1'] instanceof Doctrine_Entity); 
     353            $this->assertTrue($result[1]['2'] instanceof Doctrine_Entity); 
    345354            $this->assertTrue($result[0]['1']['phonenumbers'] instanceof Doctrine_Collection); 
    346355            $this->assertEquals(2, count($result[0]['1']['phonenumbers'])); 
     
    451460             
    452461        $stmt = new Doctrine_HydratorMockStatement($resultSet); 
    453         $hydrator = new Doctrine_HydratorNew(); 
    454         $hydrator->setQueryComponents($queryComponents); 
    455          
    456         $hydrator->setResultMixed(true); 
    457          
    458         $result = $hydrator->hydrateResultSet($stmt, $tableAliasMap, $hydrationMode); 
     462        $hydrator = new Doctrine_HydratorNew($this->_em); 
     463         
     464        $result = $hydrator->hydrateResultSet($this->_createParserResult( 
     465                $stmt, $queryComponents, $tableAliasMap, $hydrationMode, true)); 
    459466        if ($hydrationMode == Doctrine::HYDRATE_ARRAY) { 
    460467            //var_dump($result); 
     
    485492         
    486493        if ($hydrationMode == Doctrine::HYDRATE_RECORD) { 
    487             $this->assertTrue($result[0][0] instanceof Doctrine_Record); 
     494            $this->assertTrue($result[0][0] instanceof Doctrine_Entity); 
    488495            $this->assertTrue($result[0][0]['phonenumbers'] instanceof Doctrine_Collection); 
    489             $this->assertTrue($result[0][0]['phonenumbers'][0] instanceof Doctrine_Record); 
    490             $this->assertTrue($result[0][0]['phonenumbers'][1] instanceof Doctrine_Record); 
     496            $this->assertTrue($result[0][0]['phonenumbers'][0] instanceof Doctrine_Entity); 
     497            $this->assertTrue($result[0][0]['phonenumbers'][1] instanceof Doctrine_Entity); 
    491498            $this->assertTrue($result[0][0]['articles'] instanceof Doctrine_Collection); 
    492             $this->assertTrue($result[0][0]['articles'][0] instanceof Doctrine_Record); 
    493             $this->assertTrue($result[0][0]['articles'][1] instanceof Doctrine_Record); 
    494             $this->assertTrue($result[1][0] instanceof Doctrine_Record); 
     499            $this->assertTrue($result[0][0]['articles'][0] instanceof Doctrine_Entity); 
     500            $this->assertTrue($result[0][0]['articles'][1] instanceof Doctrine_Entity); 
     501            $this->assertTrue($result[1][0] instanceof Doctrine_Entity); 
    495502            $this->assertTrue($result[1][0]['phonenumbers'] instanceof Doctrine_Collection); 
    496             $this->assertTrue($result[1][0]['phonenumbers'][0] instanceof Doctrine_Record); 
    497             $this->assertTrue($result[1][0]['articles'][0] instanceof Doctrine_Record); 
    498             $this->assertTrue($result[1][0]['articles'][1] instanceof Doctrine_Record); 
     503            $this->assertTrue($result[1][0]['phonenumbers'][0] instanceof Doctrine_Entity); 
     504            $this->assertTrue($result[1][0]['articles'][0] instanceof Doctrine_Entity); 
     505            $this->assertTrue($result[1][0]['articles'][1] instanceof Doctrine_Entity); 
    499506        } 
    500507    } 
     
    626633             
    627634        $stmt = new Doctrine_HydratorMockStatement($resultSet); 
    628         $hydrator = new Doctrine_HydratorNew(); 
    629         $hydrator->setQueryComponents($queryComponents); 
    630          
    631         $hydrator->setResultMixed(true); 
    632          
    633         $result = $hydrator->hydrateResultSet($stmt, $tableAliasMap, $hydrationMode); 
     635        $hydrator = new Doctrine_HydratorNew($this->_em); 
     636         
     637        $result = $hydrator->hydrateResultSet($this->_createParserResult( 
     638                $stmt, $queryComponents, $tableAliasMap, $hydrationMode, true)); 
    634639        if ($hydrationMode == Doctrine::HYDRATE_ARRAY) { 
    635640            //var_dump($result); 
     
    668673         
    669674        if ($hydrationMode == Doctrine::HYDRATE_RECORD) { 
    670             $this->assertTrue($result[0][0] instanceof Doctrine_Record); 
    671             $this->assertTrue($result[1][0] instanceof Doctrine_Record); 
     675            $this->assertTrue($result[0][0] instanceof Doctrine_Entity); 
     676            $this->assertTrue($result[1][0] instanceof Doctrine_Entity); 
    672677            // phonenumbers 
    673678            $this->assertTrue($result[0][0]['phonenumbers'] instanceof Doctrine_Collection); 
    674             $this->assertTrue($result[0][0]['phonenumbers'][0] instanceof Doctrine_Record); 
    675             $this->assertTrue($result[0][0]['phonenumbers'][1] instanceof Doctrine_Record); 
     679            $this->assertTrue($result[0][0]['phonenumbers'][0] instanceof Doctrine_Entity); 
     680            $this->assertTrue($result[0][0]['phonenumbers'][1] instanceof Doctrine_Entity); 
    676681            $this->assertTrue($result[1][0]['phonenumbers'] instanceof Doctrine_Collection); 
    677             $this->assertTrue($result[1][0]['phonenumbers'][0] instanceof Doctrine_Record); 
     682            $this->assertTrue($result[1][0]['phonenumbers'][0] instanceof Doctrine_Entity); 
    678683            // articles 
    679684            $this->assertTrue($result[0][0]['articles'] instanceof Doctrine_Collection); 
    680             $this->assertTrue($result[0][0]['articles'][0] instanceof Doctrine_Record); 
    681             $this->assertTrue($result[0][0]['articles'][1] instanceof Doctrine_Record); 
    682             $this->assertTrue($result[1][0]['articles'][0] instanceof Doctrine_Record); 
    683             $this->assertTrue($result[1][0]['articles'][1] instanceof Doctrine_Record); 
     685            $this->assertTrue($result[0][0]['articles'][0] instanceof Doctrine_Entity); 
     686            $this->assertTrue($result[0][0]['articles'][1] instanceof Doctrine_Entity); 
     687            $this->assertTrue($result[1][0]['articles'][0] instanceof Doctrine_Entity); 
     688            $this->assertTrue($result[1][0]['articles'][1] instanceof Doctrine_Entity); 
    684689            // article comments 
    685690            $this->assertTrue($result[0][0]['articles'][0]['comments'] instanceof Doctrine_Collection); 
    686             $this->assertTrue($result[0][0]['articles'][0]['comments'][0] instanceof Doctrine_Record); 
     691            $this->assertTrue($result[0][0]['articles'][0]['comments'][0] instanceof Doctrine_Entity); 
    687692        } 
    688693    } 
     
    773778             
    774779        $stmt = new Doctrine_HydratorMockStatement($resultSet); 
    775         $hydrator = new Doctrine_HydratorNew(); 
    776         $hydrator->setQueryComponents($queryComponents); 
    777          
    778         //$hydrator->setResultMixed(true); 
    779          
    780         $result = $hydrator->hydrateResultSet($stmt, $tableAliasMap, $hydrationMode); 
     780        $hydrator = new Doctrine_HydratorNew($this->_em); 
     781         
     782        $result = $hydrator->hydrateResultSet($this->_createParserResult( 
     783                $stmt, $queryComponents, $tableAliasMap, $hydrationMode)); 
    781784        if ($hydrationMode == Doctrine::HYDRATE_ARRAY) { 
    782785            //var_dump($result); 
     
    795798        } else { 
    796799            $this->assertTrue($result instanceof Doctrine_Collection); 
    797             $this->assertTrue($result[0] instanceof Doctrine_Record); 
    798             $this->assertTrue($result[1] instanceof Doctrine_Record); 
     800            $this->assertTrue($result[0] instanceof Doctrine_Entity); 
     801            $this->assertTrue($result[1] instanceof Doctrine_Entity); 
    799802        }      
    800803 
  • trunk/tests/Orm/UnitOfWorkTestCase.php

    r4338 r4364  
    3232        $this->_user->username = 'romanb'; 
    3333        $this->_user->id = 1; 
    34         $this->assertEquals(Doctrine_Record::STATE_TDIRTY, $this->_user->state()); 
     34        $this->assertEquals(Doctrine_Entity::STATE_TDIRTY, $this->_user->state()); 
    3535        $this->assertFalse($this->_unitOfWork->contains($this->_user)); 
    3636        $this->_unitOfWork->registerDirty($this->_user);