public function testVerifyPeersWhenWhenTargetDoesNotExistAndIsToBeCreated()
 {
     $this->source->expects($this->once())->method('getDatabase')->willReturn('test_source_database');
     $this->source->expects($this->once())->method('getDatabaseInfo')->willReturn(array('db_name' => 'test_source_database', 'instance_start_time' => '123', 'update_seq' => '456'));
     $this->target->expects($this->exactly(3))->method('getDatabase')->willReturn('test_target_database');
     $this->response->status = 404;
     $this->target->expects($this->exactly(2))->method('getDatabaseInfo')->will($this->onConsecutiveCalls($this->throwException(HTTPException::fromResponse('path', $this->response)), array('db_name' => 'test_target_database', 'instance_start_time' => '123', 'update_seq' => '456')));
     $this->target->expects($this->once())->method('createDatabase')->willReturn('');
     $task = new ReplicationTask();
     $task->setCreateTarget(true);
     $replication = new Replication($this->source, $this->target, $task);
     $response = $replication->verifyPeers();
     $this->assertEquals(\count($response), 2, 'Source and target info not correctly returned.');
 }
use Relaxed\Replicator\Replicator;
$sourceClient = CouchDBClient::create(array('dbname' => 'sourcedb'));
$targetClient = CouchDBClient::create(array('dbname' => 'targetdb1'));
// Add docs to the source db.
$id = 'id';
$docs = array(array('_id' => $id . '1', 'foo' => 'bar1', '_rev' => '1-abc'), array('_id' => $id . '2', 'foo' => 'bar2', '_rev' => '1-bcd'), array('_id' => $id . '3', 'foo' => 'bar3', '_rev' => '1-cde'));
$updater = $sourceClient->createBulkUpdater();
$updater->updateDocuments($docs);
// Set newedits to false to use the supplied _rev instead of assigning
// new ones.
$updater->setNewEdits(false);
$response = $updater->execute();
// Create the replication task.
$task = new ReplicationTask();
// Enable target creation.
$task->setCreateTarget(true);
// Create the replicator.
$replicator = new Replicator($sourceClient, $targetClient, $task);
// Get the replication report as an array.
var_dump($replicator->startReplication(false, true));
/*
* array(3) {
 ["multipartResponse"]=>
 array(0) {
 }
 ["bulkResponse"]=>
 array(3) {
   ["id1"]=>
   array(1) {
     [0]=>
     int(201)