function testSaveLoadAggrigatedObjectByGetter() { $place = new GeoCoordinate(); $place->setLatitude($latitude = 'latitude'); $place->setLongitude($longitude = 'longitude'); $photo = new PhotoForTest(); $photo->setPlace($place); $photo->save(); $photo2 = lmbActiveRecord::findById('PhotoForTest', $photo->getId()); $this->assertIsA($photo2->getPlace(), 'GeoCoordinate'); $this->assertEqual($photo2->getPlace()->getLatitude(), $latitude); $this->assertEqual($photo2->getPlace()->getLongitude(), $longitude); }
function testDoNotSettingARPrimaryKeyOnAggregatedObjects() { $image = new ImageForAggregateTest(); $image->setExtension($extension = 'jpg'); $photo = new PhotoForTest(); $photo->setImage($image); $photo->save(); $this->assertNotEqual($photo->getImage()->getPhotoId(), $photo->getId()); $photo2 = lmbActiveRecord::findById('PhotoForTest', $photo->getId()); $this->assertEqual($photo2->getImage()->getPhotoId(), $photo2->getId()); $photo2->getImage()->setExtension($other_extension = 'png'); $photo2->getImage()->setPhotoId($other_photo_id = $photo2->getId() + 10); // we try set AR primary key $photo2->save(); $photo3 = lmbActiveRecord::findById('PhotoForTest', $photo2->getId()); $this->assertEqual($photo3->getImage()->getExtension(), $other_extension); $this->assertNotEqual($photo3->getImage()->getPhotoId(), $other_photo_id); // affect setting AR primary key $this->assertEqual($photo3->getImage()->getPhotoId(), $photo3->getId()); // AR primary key not updated }