/**
  * Push a new job onto the queue after a delay.
  *
  * @param  int    $delay
  * @param  string $job
  * @param  mixed  $data
  * @param  string $queue
  *
  * @return void
  */
 public function later($delay, $job, $data = '', $queue = null)
 {
     $payload = $this->createPayload($job, $data);
     $options = new CreateMessageOptions();
     $options->setVisibilityTimeoutInSeconds($delay);
     $this->azure->createMessage($this->getQueue($queue), $payload, $options);
 }
 /**
  * @covers WindowsAzure\Queue\Models\CreateMessageOptions::setVisibilityTimeoutInSeconds
  */
 public function testSetVisibilityTimeoutInSeconds()
 {
     // Setup
     $createMessageOptions = new CreateMessageOptions();
     $expected = 1000;
     // Test
     $createMessageOptions->setVisibilityTimeoutInSeconds($expected);
     // Assert
     $actual = $createMessageOptions->getVisibilityTimeoutInSeconds();
     $this->assertEquals($expected, $actual);
 }
 /**
  * @covers WindowsAzure\Queue\QueueRestProxy::clearMessages
  * @covers WindowsAzure\Queue\QueueRestProxy::createMessage
  * @covers WindowsAzure\Queue\QueueRestProxy::listMessages
  */
 public function testCreateMessage()
 {
     $interestingTimes = array(null, -1, 0, QueueServiceFunctionalTestData::INTERESTING_TTL, 1000);
     foreach ($interestingTimes as $timeToLiveInSeconds) {
         foreach ($interestingTimes as $visibilityTimeoutInSeconds) {
             $timeout = null;
             $options = new CreateMessageOptions();
             $options->setTimeout($timeout);
             $options->setTimeToLiveInSeconds($timeToLiveInSeconds);
             $options->setVisibilityTimeoutInSeconds($visibilityTimeoutInSeconds . '');
             $this->createMessageWorker(QueueServiceFunctionalTestData::getSimpleMessageText(), $options);
         }
     }
     foreach ($interestingTimes as $timeout) {
         $timeToLiveInSeconds = 1000;
         $visibilityTimeoutInSeconds = QueueServiceFunctionalTestData::INTERESTING_TTL;
         $options = new CreateMessageOptions();
         $options->setTimeout($timeout);
         $options->setTimeToLiveInSeconds($timeToLiveInSeconds . '');
         $options->setVisibilityTimeoutInSeconds($visibilityTimeoutInSeconds);
         $this->createMessageWorker(QueueServiceFunctionalTestData::getSimpleMessageText(), $options);
     }
 }
 public static function getSimpleCreateMessageOptions()
 {
     $ret = new CreateMessageOptions();
     $ret->setTimeout(4);
     $ret->setTimeToLiveInSeconds(1000);
     $ret->setVisibilityTimeoutInSeconds(self::INTERESTING_TTL);
     return $ret;
 }
 public function testCheckCreateMessageOptions()
 {
     $options = new CreateMessageOptions();
     $this->assertNull($options->getTimeout(), 'Default CreateMessageOptions->getTimeout');
     $this->assertNull($options->getTimeToLiveInSeconds(), 'Default CreateMessageOptions->getTimeToLiveInSeconds');
     $this->assertNull($options->getVisibilityTimeoutInSeconds(), 'Default CreateMessageOptions->getVisibilityTimeoutInSeconds');
     $options->setTimeout(self::INT_MAX_VALUE);
     $options->setTimeToLiveInSeconds(0);
     $options->setVisibilityTimeoutInSeconds(self::INT_MIN_VALUE);
     $this->assertEquals(self::INT_MAX_VALUE, $options->getTimeout(), 'Set CreateMessageOptions->getTimeout');
     $this->assertEquals(0, $options->getTimeToLiveInSeconds(), 'Set CreateMessageOptions->getTimeToLiveInSeconds');
     $this->assertEquals(self::INT_MIN_VALUE, $options->getVisibilityTimeoutInSeconds(), 'Set CreateMessageOptions->getVisibilityTimeoutInSeconds');
 }
 public function testCheckCreateMessageOptions()
 {
     $options = new CreateMessageOptions();
     // TODO: Uncomment when fixed.
     // https://github.com/WindowsAzure/azure-sdk-for-php/issues/59
     // $this->assertNull($options->getTimeout(), 'Default CreateMessageOptions->getTimeout');
     $this->assertNull($options->getTimeToLiveInSeconds(), 'Default CreateMessageOptions->getTimeToLiveInSeconds');
     $this->assertNull($options->getVisibilityTimeoutInSeconds(), 'Default CreateMessageOptions->getVisibilityTimeoutInSeconds');
     // TODO: Uncomment when fixed.
     // https://github.com/WindowsAzure/azure-sdk-for-php/issues/59
     // $options->setTimeout(self::IntegerMAX_VALUE);
     $options->setTimeToLiveInSeconds(0);
     $options->setVisibilityTimeoutInSeconds(self::IntegerMIN_VALUE);
     // TODO: Uncomment when fixed.
     // https://github.com/WindowsAzure/azure-sdk-for-php/issues/59
     // $this->assertEquals(self::IntegerMAX_VALUE, $options->getTimeout(), 'Set CreateMessageOptions->getTimeout');
     $this->assertEquals(0, $options->getTimeToLiveInSeconds(), 'Set CreateMessageOptions->getTimeToLiveInSeconds');
     $this->assertEquals(self::IntegerMIN_VALUE, $options->getVisibilityTimeoutInSeconds(), 'Set CreateMessageOptions->getVisibilityTimeoutInSeconds');
 }
 public static function getSimpleCreateMessageOptions()
 {
     $ret = new CreateMessageOptions();
     // Uncomment when fixed
     // https://github.com/WindowsAzure/azure-sdk-for-php/issues/59
     //        $ret->setTimeout(4);
     // Revert when fixed
     // https://github.com/WindowsAzure/azure-sdk-for-php/issues/69
     //        $ret->setTimeToLiveInSeconds(1000);
     //        $ret->setVisibilityTimeoutInSeconds(self::INTERESTING_TTL);
     $ret->setTimeToLiveInSeconds('1000');
     $ret->setVisibilityTimeoutInSeconds(self::INTERESTING_TTL . '');
     return $ret;
 }