Exemplo n.º 1
0
 /**
  * A basic functional test example.
  *
  * @return void
  */
 public function test_provisioning_returns_successful_message()
 {
     $mock = new MockHandler([new Response(200, [], file_get_contents('tests/xml/provisioning_success.xml'))]);
     $handler = HandlerStack::create($mock);
     $client = new Client(['handler' => $handler]);
     $api = new XtractaApi(['client' => $client]);
     $response = $api->provisionUser('apikey', '1', 'customer1');
     $this->assertEquals(1234, $response->group_id);
     $this->assertEquals('Test', $response->group_name);
     $this->assertEquals('xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx', $response->api_key);
     // Check workflows
     $this->assertEquals(1, count($response->workflows));
     $workflow = $response->workflows[0];
     $this->assertEquals(1111, $workflow->id);
     $this->assertEquals('Accounts Payable', $workflow->name);
     $this->assertEquals('*****@*****.**', $workflow->email);
     $this->assertEquals('test:test@akl.xtracta.com', $workflow->file_transfer_url);
     $this->assertEquals(1112, $workflow->source_id);
     // Check First Database
     $this->assertEquals(1, count($response->databases));
     $database = $response->databases[0];
     $this->assertEquals(1234, $database->id);
     $this->assertEquals('Suppliers (WF 1111)', $database->name);
     // Check columns
     $this->assertEquals(2, count($database->columns));
 }
Exemplo n.º 2
0
 public function test_delete_group()
 {
     $mock = new MockHandler([new Response(200, [], file_get_contents('tests/xml/documents_with_rejection.xml'))]);
     $handler = HandlerStack::create($mock);
     $client = new Client(['handler' => $handler]);
     $api = new XtractaApi(['client' => $client]);
     $response = $api->deleteGroup('apikey', '1');
     $this->assertTrue($response);
 }
Exemplo n.º 3
0
 public function test_provisioning_returns_successful_message()
 {
     $mock = new MockHandler([new Response(200, [], file_get_contents('tests/xml/update_data_success.xml'))]);
     $handler = HandlerStack::create($mock);
     $client = new Client(['handler' => $handler]);
     $api = new XtractaApi(['client' => $client]);
     $suppliers = array();
     $suppliers[1] = array('Name' => 'Hello', 'Reference' => 123);
     $response = $api->updateData('apikey', '1', $suppliers);
     // Check rows
     $this->assertEquals(2, $response->rows_affected);
 }
Exemplo n.º 4
0
 public function test_list_documents_returns_documents_with_a_rejection_reason()
 {
     $mock = new MockHandler([new Response(200, [], file_get_contents('tests/xml/documents_with_rejection.xml'))]);
     $handler = HandlerStack::create($mock);
     $client = new Client(['handler' => $handler]);
     $api = new XtractaApi(['client' => $client]);
     $response = $api->getDocuments('apikey', '1', null, 'active', true);
     // Check rows
     $this->assertEquals(1, count($response->documents));
     foreach ($response->documents as $document) {
         $this->assertEquals('reject', $document->status);
         $this->assertEquals(1, count($document->rejections));
         foreach ($document->rejections as $rejection) {
             $this->assertEquals('The Order Number could not be found in the list of orders', $rejection->message);
         }
     }
 }
Exemplo n.º 5
0
 public function test_provisioning_returns_successful_message_when_adding_multiple_rows()
 {
     $mock = new MockHandler([new Response(200, [], file_get_contents('tests/xml/add_data_success_multiple_rows.xml'))]);
     $handler = HandlerStack::create($mock);
     $client = new Client(['handler' => $handler]);
     $api = new XtractaApi(['client' => $client]);
     $suppliers = array();
     $suppliers[] = array('Name' => 'Hello', 'Reference' => 123);
     $suppliers[] = array('Name' => 'Hello 2', 'Reference' => 124);
     $response = $api->addData('apikey', '1', $suppliers);
     // Check rows
     $this->assertEquals(2, count($response->rows));
     $row = $response->rows[0];
     $this->assertEquals(1, $row->id);
     $row = $response->rows[1];
     $this->assertEquals(2, $row->id);
 }
Exemplo n.º 6
0
 public function test_get_response()
 {
     $mock = new MockHandler([new Response(200, [], file_get_contents('tests/xml/document_tracking_response.xml'))]);
     $handler = HandlerStack::create($mock);
     $client = new Client(['handler' => $handler]);
     $api = new XtractaApi(['client' => $client]);
     $response = $api->getDocumentTracking('apikey', '1');
     $this->assertEquals(12345, $response->id);
     $this->assertEquals('email', $response->type);
     $this->assertEquals('2016-05-31T12:52:41+12:00', $response->received);
     $this->assertEquals('OK', $response->status);
     $this->assertEquals('Test Person <*****@*****.**>', $response->from);
     $this->assertEquals('other files', $response->subject);
     $this->assertEquals(3, count($response->files));
     $file = $response->files[0];
     $this->assertEquals(1111, $file->id);
     $this->assertEquals('File1.pdf', $file->name);
     $this->assertEquals('https://web1-akl.xtracta.com/datasource/1/60/f1/aaaaa.pdf', $file->url);
     $this->assertEquals('Done', $file->status);
     // Check activities
     $this->assertEquals(2, count($file->activities));
     $activity = $file->activities[0];
     $this->assertEquals('Processing', $activity->description);
     $this->assertEquals('System', $activity->username);
     $this->assertEquals('2016-05-31T12:52:59+12:00', $activity->date);
     $activity = $file->activities[1];
     $this->assertEquals('Awaiting rejection review', $activity->description);
     $this->assertEquals('System', $activity->username);
     $this->assertEquals('2016-05-31T12:53:49+12:00', $activity->date);
     // End Activity Check
     $file = $response->files[1];
     $this->assertEquals(1112, $file->id);
     $this->assertEquals('File2.pdf', $file->name);
     $this->assertEquals('https://web1-akl.xtracta.com/datasource/1/dd/ad/bbbbb.pdf', $file->url);
     $this->assertEquals('Done', $file->status);
     $file = $response->files[2];
     $this->assertEquals(1113, $file->id);
     $this->assertEquals('File3.pdf', $file->name);
     $this->assertEquals('https://web1-akl.xtracta.com/datasource/1/a9/de/ccccc.pdf', $file->url);
     $this->assertEquals('Done', $file->status);
 }