Skip to content
This repository has been archived by the owner on Jul 2, 2024. It is now read-only.

Commit

Permalink
Merge pull request #23 from juriansluiman/id
Browse files Browse the repository at this point in the history
Fix id
  • Loading branch information
bakura10 committed Oct 9, 2014
2 parents bc42792 + f6a6d4a commit 07b44f5
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 11 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# 0.4.0-beta3

- [BC] Due to changes in SlmQueue ([changelog](https://github.com/juriansluiman/SlmQueue/blob/master/CHANGELOG.md))
existing jobs won't be able to be executed correctly.


# 0.4.0-beta2

- Update dependency to SlmQueue 0.4.0-beta2
Expand Down
10 changes: 5 additions & 5 deletions src/SlmQueueSqs/Queue/SqsQueue.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ public function push(JobInterface $job, array $options = array())
$result = $this->sqsClient->sendMessage(array_filter($parameters));

$job->setMetadata(array(
'id' => $result['MessageId'],
'md5' => $result['MD5OfMessageBody']
'__id__' => $result['MessageId'],
'md5' => $result['MD5OfMessageBody']
));
}

Expand Down Expand Up @@ -160,8 +160,8 @@ public function batchPush(array $jobs, array $options = array())
foreach ($messages as $message) {
$batchId = $message['Id'];
$jobs[$batchId]->setMetadata(array(
'id' => $message['MessageId'],
'md5' => $message['MD5OfMessageBody']
'__id__' => $message['MessageId'],
'md5' => $message['MD5OfMessageBody']
));
}
}
Expand Down Expand Up @@ -201,7 +201,7 @@ public function batchPop(array $options = array())
$jobs[] = $this->unserializeJob(
$message['Body'],
array(
'id' => $message['MessageId'],
'__id__' => $message['MessageId'],
'receiptHandle' => $message['ReceiptHandle'],
'md5' => $message['MD5OfBody']
)
Expand Down
12 changes: 6 additions & 6 deletions tests/SlmQueueSqsTest/Queue/SqsQueueTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public function testSetMetadataWhenJobIsPushed()
$this->sqsQueue->push($job);

$this->assertEquals(1, $job->getId());
$this->assertEquals(1, $job->getMetadata('id'));
$this->assertEquals(1, $job->getMetadata('__id__'));
$this->assertEquals(md5('baz'), $job->getMetadata('md5'));
}

Expand Down Expand Up @@ -144,11 +144,11 @@ public function testSetMetadataWhenMultipleJobsArePushed()
$this->assertCount(2, $jobs);

$this->assertEquals(1, $jobs[0]->getId());
$this->assertEquals(1, $jobs[0]->getMetadata('id'));
$this->assertEquals(1, $jobs[0]->getMetadata('__id__'));
$this->assertEquals(md5('bar'), $jobs[0]->getMetadata('md5'));

$this->assertEquals(2, $jobs[1]->getId());
$this->assertEquals(2, $jobs[1]->getMetadata('id'));
$this->assertEquals(2, $jobs[1]->getMetadata('__id__'));
$this->assertEquals(md5('baz'), $jobs[1]->getMetadata('md5'));
}

Expand Down Expand Up @@ -286,9 +286,8 @@ public function testMetadataIsPopped()
'Messages' => array(
array(
'Body' => json_encode(array(
'name' => 'MyClass',
'content' => serialize('aa'),
'metadata' => array('foo' => 'bar')
'metadata' => array('__name__' => 'MyClass', 'foo' => 'bar')
)),
'MessageId' => 'id_123',
'ReceiptHandle' => 'receipt_123',
Expand All @@ -307,7 +306,8 @@ public function testMetadataIsPopped()
$this->assertInstanceOf('SlmQueueSqsTest\Asset\SimpleJob', $job);
$this->assertEquals('aa', $job->getContent());
$this->assertEquals(array(
'id' => 'id_123',
'__id__' => 'id_123',
'__name__' => 'MyClass',
'receiptHandle' => 'receipt_123',
'md5' => 'funny',
'foo' => 'bar'
Expand Down

0 comments on commit 07b44f5

Please sign in to comment.