Ejemplo n.º 1
0
 private function updateItems(ConfigCollection $collection)
 {
     foreach ($collection->getItems() as $item => $value) {
         $this->executeSql('
             UPDATE config_items
                SET value = :value
              WHERE config_collection_uuid = :config_collection_uuid AND name = :name
         ', ['config_collection_uuid' => $collection->getUuid()->getBytes(), 'name' => $item, 'value' => json_encode($value)]);
     }
 }
Ejemplo n.º 2
0
 public function it_will_rollBack_on_error_during_update(ConfigCollection $collection, \PDOStatement $itemStatement1)
 {
     $uuid = Uuid::uuid4();
     $items = ['k1' => 'v1', 'k2' => 'v2'];
     $collection->getUuid()->willReturn($uuid);
     $collection->getItems()->willReturn($items);
     $this->pdo->beginTransaction()->shouldBeCalled();
     $this->pdo->prepare(new Argument\Token\StringContainsToken('UPDATE config_items'))->willReturn($itemStatement1, false);
     $itemStatement1->execute(['config_collection_uuid' => $uuid->getBytes(), 'name' => 'k1', 'value' => json_encode('v1')])->willThrow(new \RuntimeException());
     $this->pdo->rollBack()->shouldBeCalled();
     $this->shouldThrow(\RuntimeException::class)->duringUpdate($collection);
 }