0
통합 테스트를하고 있으며 엔티티에 ID를 직접 설정할 수 없습니다. 내가 필요로하는 것은 어떻게 든 Doctrine에게 ID를 1로 재설정하도록 지시합니다.Doctrine 2 재설정 ID
나는 플러시를 호출 할 때 ID 20, 21, 22,23을 얻습니다.
테이블을 삭제하려고 시도했으나 신원을 재설정하거나이 thread은 도움이되지 않습니다.
내 코드 : 사전에
public function testFindingAllOrderedByDefault()
{
/** @var $bundles Bundle[] */
$bundles = $this->repository->findAll();
$this->assertCount(2, $bundles);
$this->assertSame(1, $bundles[0]->getId());
$this->assertSame(2, $bundles[1]->getId());
}
protected function prepareDatabase(EntityManager $entityManager, Connection $connection)
{
$connection->executeQuery('TRUNCATE bundle CASCADE');
$entityManager->persist(
(new Bundle())
->setPrice(1200)
->setPriceVat(5000)
->setDiscount(1000)
->setCurrency('czk')
);
$entityManager->persist(
(new Bundle())
->setPrice(1300)
->setPriceVat(4000)
->setDiscount(500)
->setCurrency('eur')
);
$entityManager->flush();
}
감사합니다.
고마워, 저는 Postgres를 사용하고 있으므로 $ connection-> executeQuery ('ALTER SEQUENCE bund le_id_seq RESTART WITH 1 '); –