/**
     * @test
     */
    public function sets_RID_and_registers_inserted_document_with_UnitOfWork()
    {
        $c = new Contact();
        $oid = spl_object_hash($c);
        $uow = $this->prophesize(UnitOfWork::class);
        $uow->getDocumentInsertions()->willReturn([$oid => $c]);
        $uow->getDocumentChangeSet(Arg::is($c))->willReturn(['name' => ['old', 'new']]);
        $uow->getDocumentUpdates()->willReturn([]);
        $uow->getCollectionUpdates()->willReturn([]);
        $uow->getCollectionDeletions()->willReturn([]);
        $uow->getDocumentDeletions()->willReturn([]);
        $uow->getDocumentActualData(Arg::is($c))->willReturn([]);
        $uow->registerManaged($c, '#1:0', [])->shouldBeCalled();
        $uow->raisePostPersist(Arg::any(), $c)->shouldBeCalled();
        $res = json_decode(<<<JSON
{
    "result":[{
        "n0":"#1:0"
    }]
}
JSON
, true);
        $b = $this->prophesize(BindingInterface::class);
        $b->sqlBatch(Arg::any())->willReturn($res);
        $p = new SQLBatchPersister($this->metadataFactory, $b->reveal());
        $p->process($uow->reveal());
    }
 /**
  * @test
  */
 public function orderByType_returns_array_in_correct_order()
 {
     $set = SQLBatchPersister::prepareCommitOrderArray(self::$order);
     $docs = [new Doc1(), new Doc3(), new Doc4(), new Doc2(), new Doc2(), new Doc1(), new Doc3(), new Doc4()];
     foreach ($docs as $k => $d) {
         $docs[spl_object_hash($d)] = $d;
         unset($docs[$k]);
     }
     $actual = SQLBatchPersister::orderByType($docs, $set);
     $this->assertCount(4, $actual);
     $this->assertArrayHasKey(Doc1::class, $actual);
     $this->assertArrayHasKey(Doc2::class, $actual);
     $this->assertArrayHasKey(Doc3::class, $actual);
     $this->assertArrayHasKey(Doc4::class, $actual);
     $keys = array_keys($actual);
     $this->assertEquals(self::$order, $keys);
 }