Changeset 4364 for trunk/tests/Orm
- Timestamp:
- 05/13/08 22:20:34 (8 months ago)
- Location:
- trunk/tests/Orm
- Files:
-
- 2 modified
-
Hydration/BasicHydrationTest.php (modified) (17 diffs)
-
UnitOfWorkTestCase.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/Orm/Hydration/BasicHydrationTest.php
r4342 r4364 5 5 class Orm_Hydration_BasicHydrationTest extends Doctrine_OrmTestCase 6 6 { 7 private $_em; 8 7 9 protected function setUp() 8 10 { 9 11 parent::setUp(); 12 $this->_em = $this->sharedFixture['connection']; 10 13 } 11 14 … … 19 22 } 20 23 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 21 37 /** 22 38 * Select u.id, u.name from CmsUser u … … 25 41 */ 26 42 public function testNewHydrationSimpleEntityQuery($hydrationMode) 27 { 43 { 28 44 // Faked query components 29 45 $queryComponents = array( … … 56 72 57 73 $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)); 62 78 63 79 $this->assertEquals(2, count($result)); … … 69 85 if ($hydrationMode == Doctrine::HYDRATE_RECORD) { 70 86 $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); 73 89 } else { 74 90 $this->assertTrue(is_array($result)); … … 136 152 137 153 $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)); 144 158 //var_dump($result); 145 159 … … 162 176 163 177 if ($hydrationMode == Doctrine::HYDRATE_RECORD) { 164 $this->assertTrue($result[0][0] instanceof Doctrine_ Record);178 $this->assertTrue($result[0][0] instanceof Doctrine_Entity); 165 179 $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); 169 183 $this->assertTrue($result[1][0]['phonenumbers'] instanceof Doctrine_Collection); 170 184 } … … 224 238 225 239 $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)); 232 244 //var_dump($result); 233 245 … … 243 255 244 256 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); 247 259 } 248 260 } … … 309 321 310 322 $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)); 318 327 if ($hydrationMode == Doctrine::HYDRATE_ARRAY) { 319 328 //var_dump($result); … … 341 350 342 351 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); 345 354 $this->assertTrue($result[0]['1']['phonenumbers'] instanceof Doctrine_Collection); 346 355 $this->assertEquals(2, count($result[0]['1']['phonenumbers'])); … … 451 460 452 461 $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)); 459 466 if ($hydrationMode == Doctrine::HYDRATE_ARRAY) { 460 467 //var_dump($result); … … 485 492 486 493 if ($hydrationMode == Doctrine::HYDRATE_RECORD) { 487 $this->assertTrue($result[0][0] instanceof Doctrine_ Record);494 $this->assertTrue($result[0][0] instanceof Doctrine_Entity); 488 495 $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); 491 498 $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); 495 502 $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); 499 506 } 500 507 } … … 626 633 627 634 $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)); 634 639 if ($hydrationMode == Doctrine::HYDRATE_ARRAY) { 635 640 //var_dump($result); … … 668 673 669 674 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); 672 677 // phonenumbers 673 678 $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); 676 681 $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); 678 683 // articles 679 684 $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); 684 689 // article comments 685 690 $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); 687 692 } 688 693 } … … 773 778 774 779 $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)); 781 784 if ($hydrationMode == Doctrine::HYDRATE_ARRAY) { 782 785 //var_dump($result); … … 795 798 } else { 796 799 $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); 799 802 } 800 803 -
trunk/tests/Orm/UnitOfWorkTestCase.php
r4338 r4364 32 32 $this->_user->username = 'romanb'; 33 33 $this->_user->id = 1; 34 $this->assertEquals(Doctrine_ Record::STATE_TDIRTY, $this->_user->state());34 $this->assertEquals(Doctrine_Entity::STATE_TDIRTY, $this->_user->state()); 35 35 $this->assertFalse($this->_unitOfWork->contains($this->_user)); 36 36 $this->_unitOfWork->registerDirty($this->_user);