Esempio n. 1
0
 /**
  * Set the resource and start the builder.
  *
  * @param  \Algorit\Synchronizer\Request\Contracts\ResourceInterface $resource
  * @param  mixed $callback
  * @return \Algorit\Synchronizer\Loader
  */
 public function start(ResourceInterface $resource, $callback = false)
 {
     // Set config
     $this->request->setConfig($this->config->setup($this->system, $resource));
     // Set system resource
     $this->request->setResource($resource);
     // Set logger
     $this->builder->setLogger($this->logger);
     // Start the Builder
     $this->builder->start($this->request, $resource);
     if ($callback instanceof Closure) {
         return $callback($this);
         // return?
     }
     return $this;
 }
Esempio n. 2
0
 public function testFailedSync()
 {
     $receiver = Mockery::mock('Algorit\\Synchronizer\\Receiver');
     $receiver->shouldReceive('fromErp')->once()->andReturn(array());
     $sender = Mockery::mock('Algorit\\Synchronizer\\Sender');
     // We will throw an exception here
     // it will be cought on process method.
     // $sender->shouldReceive('toDatabase')
     // 	   ->once()
     // 	   ->andThrow(new Exception('An error ocurred!'));
     $repository = Mockery::mock('Algorit\\Synchronizer\\Storage\\SyncRepositoryInterface');
     $repository->shouldReceive('create')->once()->andReturn(false);
     $repository->shouldReceive('setCurrentSync')->once()->andReturn($repository);
     $repository->shouldReceive('getLastSync')->once()->andReturn(false);
     $repository->shouldReceive('touchCurrentSync')->once()->andReturn(false);
     $repository->shouldReceive('updateFailedSync')->once()->andReturn(false);
     $builder = new Builder($sender, $receiver, $repository);
     $builder->setLogger($this->logger);
     $builder->start($this->request, $this->resource);
     $assert = $builder->fromErpToDatabase(false);
     $this->assertFalse($assert);
 }