Example #1
0
 public function testInsertWithSequenceName()
 {
     $sequence = Entity\Car::definition()['fields']['id']['sequence'];
     /** @var Connection|\PHPUnit_Framework_MockObject_MockObject $connection */
     $connection = $this->getMockBuilder(Connection::class)->disableOriginalConstructor()->setMethodsExcept(['mapper'])->getMock();
     $connection->expects($this->any())->method('getDatabasePlatform')->willReturn(new \Doctrine\DBAL\Platforms\SqlitePlatform());
     $connection->expects($this->once())->method('lastInsertId')->with($sequence);
     $mapper = $connection->mapper(Entity\Car::class);
     $entity = $mapper->entity(['name' => 'DMC-12', 'manufacturer_id' => 1]);
     $mapper->insert($entity);
 }