Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added failing test for refresh with eager fetching #409

Merged
merged 1 commit into from Jul 29, 2012
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
33 changes: 33 additions & 0 deletions tests/Doctrine/Tests/ORM/Functional/OneToOneEagerLoadingTest.php
Expand Up @@ -21,6 +21,7 @@ protected function setUp()
$this->_em->getClassMetadata('Doctrine\Tests\ORM\Functional\TrainDriver'),
$this->_em->getClassMetadata('Doctrine\Tests\ORM\Functional\TrainOwner'),
$this->_em->getClassMetadata('Doctrine\Tests\ORM\Functional\Waggon'),
$this->_em->getClassMetadata('Doctrine\Tests\ORM\Functional\TrainOrder'),
));
} catch(\Exception $e) {}
}
Expand Down Expand Up @@ -181,6 +182,21 @@ public function testEagerLoadWithNonNullableColumnsGeneratesLeftJoinOnNonOwningS
$this->_sqlLoggerStack->queries[$this->_sqlLoggerStack->currentQuery]['sql']
);
}

public function testEagerLoadingDoesNotBreakRefresh()
{
$train = new Train(new TrainOwner('Johannes'));
$order = new TrainOrder($train);
$this->_em->persist($train);
$this->_em->persist($order);
$this->_em->flush();

$this->_em->getConnection()->exec("UPDATE TrainOrder SET train_id = NULL");

$this->assertSame($train, $order->train);
$this->_em->refresh($order);
$this->assertNull($order->train);
}
}

/**
Expand Down Expand Up @@ -305,3 +321,20 @@ public function setTrain($train)
$this->train = $train;
}
}

/**
* @Entity
*/
class TrainOrder
{
/** @id @generatedValue @column(type="integer") */
public $id;

/** @OneToOne(targetEntity = "Train", fetch = "EAGER") */
public $train;

public function __construct(Train $train)
{
$this->train = $train;
}
}