public function testOrchestrationRunWithEmails()
 {
     // create orchestration
     $orchestration = $this->client->createOrchestration(sprintf('%s %s', self::TESTING_ORCHESTRATION_NAME, uniqid()));
     $this->assertArrayHasKey('id', $orchestration, "Result of API command 'createOrchestration' should contain new created orchestration ID");
     $this->assertArrayHasKey('crontabRecord', $orchestration, "Result of API command 'createOrchestration' should return orchestration info");
     // update tasks
     $url = 'https://syrup.keboola.com/timeout/asynchronous';
     $sapiTask = new OrchestrationTask();
     $sapiTask->setActive(true)->setContinueOnFailure(false)->setComponent(null)->setComponentUrl($url);
     $tasks = $this->client->updateTasks($orchestration['id'], array($sapiTask));
     $this->assertCount(1, $tasks, sprintf("Result of API command 'updateTasks' should return %i tasks", 1));
     $notifications = array(FUNCTIONAL_ERROR_NOTIFICATION_EMAIL);
     // new run
     $job = $this->client->runOrchestration($orchestration['id'], $notifications);
     $this->assertArrayHasKey('id', $job);
     $this->assertArrayHasKey('orchestrationId', $job);
     $this->assertArrayHasKey('notificationsEmails', $job);
     $this->assertArrayHasKey('status', $job);
     $this->assertArrayHasKey('isFinished', $job);
     $this->assertEquals('waiting', $job['status']);
     $this->assertEquals($orchestration['id'], $job['orchestrationId']);
     $this->assertEquals($notifications, $job['notificationsEmails']);
     // wait for processing job
     while (!$job['isFinished']) {
         sleep(5);
         $job = $this->client->getJob($job['id']);
         $this->assertArrayHasKey('isFinished', $job);
     }
     // BC old run
     $job = $this->client->createJob($orchestration['id'], $notifications);
     $this->assertArrayHasKey('id', $job);
     $this->assertArrayHasKey('orchestrationId', $job);
     $this->assertArrayHasKey('notificationsEmails', $job);
     $this->assertArrayHasKey('status', $job);
     $this->assertArrayHasKey('isFinished', $job);
     $this->assertEquals('waiting', $job['status']);
     $this->assertEquals($orchestration['id'], $job['orchestrationId']);
     $this->assertEquals($notifications, $job['notificationsEmails']);
     // wait for processing job
     while (!$job['isFinished']) {
         sleep(5);
         $job = $this->client->getJob($job['id']);
         $this->assertArrayHasKey('isFinished', $job);
     }
 }