@@ -46,8 +46,8 @@ |
||
| 46 | 46 | { |
| 47 | 47 | $events = $this->prophesize(EventManagerInterface::class); |
| 48 | 48 | $events->attach(AbstractWorkerEvent::EVENT_PROCESS_IDLE, [$this->target, 'onIdle'], 1) |
| 49 | - ->willReturn('handle') |
|
| 50 | - ->shouldBeCalled(); |
|
| 49 | + ->willReturn('handle') |
|
| 50 | + ->shouldBeCalled(); |
|
| 51 | 51 | |
| 52 | 52 | $this->target->attach($events->reveal()); |
| 53 | 53 | |
@@ -152,12 +152,12 @@ discard block |
||
| 152 | 152 | 'delay' => 100, |
| 153 | 153 | ]; |
| 154 | 154 | $resultMock = $this->getMockBuilder(\MongoDB\InsertOneResult::class)->disableOriginalConstructor() |
| 155 | - ->setMethods(['getInsertedId'])->getMock(); |
|
| 155 | + ->setMethods(['getInsertedId'])->getMock(); |
|
| 156 | 156 | $resultMock->expects($this->once())->method('getInsertedId')->willReturn('ID'); |
| 157 | 157 | $this->mongoCollectionMock->expects($this->once())->method('insertOne') |
| 158 | - ->with($this->callback(function($value) use ($options) { |
|
| 158 | + ->with($this->callback(function($value) use ($options) { |
|
| 159 | 159 | |
| 160 | - return isset($value['queue']) && $value['queue'] == $this->queueName |
|
| 160 | + return isset($value['queue']) && $value['queue'] == $this->queueName |
|
| 161 | 161 | && isset($value['status']) && $value['status'] == MongoQueue::STATUS_PENDING |
| 162 | 162 | && !isset($value['tried']) |
| 163 | 163 | && !isset($value['message']) && !isset($value['trace']) |
@@ -166,9 +166,9 @@ discard block |
||
| 166 | 166 | && $value['created'] instanceOf \MongoDB\BSON\UTCDateTime |
| 167 | 167 | && (int) ((string) $value['scheduled']) - (int) ((string)$value['created']) == $options['delay'] * 1000 |
| 168 | 168 | && isset($value['priority']) && $value['priority'] == $options['priority'] |
| 169 | - ; |
|
| 170 | - })) |
|
| 171 | - ->willReturn($resultMock); |
|
| 169 | + ; |
|
| 170 | + })) |
|
| 171 | + ->willReturn($resultMock); |
|
| 172 | 172 | |
| 173 | 173 | $this->target->push($job, $options); |
| 174 | 174 | |
@@ -184,17 +184,17 @@ discard block |
||
| 184 | 184 | |
| 185 | 185 | |
| 186 | 186 | $this->mongoCollectionMock->expects($this->once())->method('findOneAndUpdate') |
| 187 | - ->with( |
|
| 188 | - $this->equalTo(['_id' => new \MongoDB\BSON\ObjectID($job->getId())]), |
|
| 189 | - $this->callback(function($value) { |
|
| 190 | - if (!array_key_exists('$set', $value)) { return false;} |
|
| 191 | - $value = $value['$set']; |
|
| 187 | + ->with( |
|
| 188 | + $this->equalTo(['_id' => new \MongoDB\BSON\ObjectID($job->getId())]), |
|
| 189 | + $this->callback(function($value) { |
|
| 190 | + if (!array_key_exists('$set', $value)) { return false;} |
|
| 191 | + $value = $value['$set']; |
|
| 192 | 192 | return isset($value['tried']) && $value['tried'] == 10 |
| 193 | 193 | && !array_key_exists('created', $value) |
| 194 | 194 | ; |
| 195 | - } |
|
| 196 | - )) |
|
| 197 | - ->willReturn(null); |
|
| 195 | + } |
|
| 196 | + )) |
|
| 197 | + ->willReturn(null); |
|
| 198 | 198 | |
| 199 | 199 | $this->target->retry($job); |
| 200 | 200 | } |
@@ -211,31 +211,31 @@ discard block |
||
| 211 | 211 | |
| 212 | 212 | $this->jobManagerMock->expects($this->once())->method('get')->with(get_class($job))->willReturn(new $this->testJobClass()); |
| 213 | 213 | $this->mongoCollectionMock->expects($this->once())->method('findOneAndUpdate') |
| 214 | - ->with( |
|
| 215 | - $this->callback(function($value) { |
|
| 216 | - return |
|
| 214 | + ->with( |
|
| 215 | + $this->callback(function($value) { |
|
| 216 | + return |
|
| 217 | 217 | isset($value['queue']) && $value['queue'] == $this->queueName |
| 218 | 218 | && isset($value['status']) && $value['status'] == MongoQueue::STATUS_PENDING |
| 219 | 219 | && isset($value['scheduled']['$lte']) && $value['scheduled']['$lte'] instanceOf \MongoDB\BSON\UTCDateTime |
| 220 | - ; |
|
| 221 | - }), |
|
| 220 | + ; |
|
| 221 | + }), |
|
| 222 | 222 | |
| 223 | - $this->callback(function($value) { |
|
| 224 | - if (!array_key_exists('$set', $value)) { return false;} |
|
| 225 | - $value = $value['$set']; |
|
| 226 | - return isset($value['status']) && $value['status'] == MongoQueue::STATUS_RUNNING |
|
| 223 | + $this->callback(function($value) { |
|
| 224 | + if (!array_key_exists('$set', $value)) { return false;} |
|
| 225 | + $value = $value['$set']; |
|
| 226 | + return isset($value['status']) && $value['status'] == MongoQueue::STATUS_RUNNING |
|
| 227 | 227 | && array_key_exists('executed', $value) |
| 228 | - ; |
|
| 229 | - } |
|
| 230 | - ), |
|
| 228 | + ; |
|
| 229 | + } |
|
| 230 | + ), |
|
| 231 | 231 | |
| 232 | - $this->callback(function($value) { |
|
| 233 | - return |
|
| 232 | + $this->callback(function($value) { |
|
| 233 | + return |
|
| 234 | 234 | isset($value['sort']) && $value['sort'] == ['priority' => 1, 'scheduled' => 1] |
| 235 | 235 | && isset($value['returnDocument'])&&$value['returnDocument'] = \MongoDB\Operation\FindOneAndUpdate::RETURN_DOCUMENT_AFTER |
| 236 | - ; |
|
| 237 | - })) |
|
| 238 | - ->willReturn($envelope); |
|
| 236 | + ; |
|
| 237 | + })) |
|
| 238 | + ->willReturn($envelope); |
|
| 239 | 239 | |
| 240 | 240 | $actualJob = $this->target->pop(); |
| 241 | 241 | |
@@ -245,7 +245,7 @@ discard block |
||
| 245 | 245 | public function testPopEmptyQueue() |
| 246 | 246 | { |
| 247 | 247 | $this->mongoCollectionMock->expects($this->once())->method('findOneAndUpdate') |
| 248 | - ->willReturn(null); |
|
| 248 | + ->willReturn(null); |
|
| 249 | 249 | |
| 250 | 250 | $actualJob = $this->target->pop(); |
| 251 | 251 | |
@@ -319,8 +319,8 @@ discard block |
||
| 319 | 319 | }; |
| 320 | 320 | |
| 321 | 321 | $this->mongoCollectionMock->expects($this->once())->method('find') |
| 322 | - ->with($filter, $opt) |
|
| 323 | - ->willReturn($cursor); |
|
| 322 | + ->with($filter, $opt) |
|
| 323 | + ->willReturn($cursor); |
|
| 324 | 324 | |
| 325 | 325 | $this->target->listing($options); |
| 326 | 326 | |
@@ -334,19 +334,19 @@ discard block |
||
| 334 | 334 | $job->setId(new \MongoDB\BSON\ObjectID()); |
| 335 | 335 | $options = ['message' => 'test failure message']; |
| 336 | 336 | $this->mongoCollectionMock->expects($this->once())->method('findOneAndUpdate') |
| 337 | - ->with( |
|
| 338 | - $this->equalTo(['_id' => new \MongoDB\BSON\ObjectID($job->getId())]), |
|
| 339 | - $this->callback(function($value) use ($options) { |
|
| 340 | - if (!array_key_exists('$set', $value)) { return false;} |
|
| 341 | - $value = $value['$set']; |
|
| 342 | - return isset($value['status']) && $value['status'] == MongoQueue::STATUS_FAILED |
|
| 337 | + ->with( |
|
| 338 | + $this->equalTo(['_id' => new \MongoDB\BSON\ObjectID($job->getId())]), |
|
| 339 | + $this->callback(function($value) use ($options) { |
|
| 340 | + if (!array_key_exists('$set', $value)) { return false;} |
|
| 341 | + $value = $value['$set']; |
|
| 342 | + return isset($value['status']) && $value['status'] == MongoQueue::STATUS_FAILED |
|
| 343 | 343 | && !array_key_exists('created', $value) |
| 344 | 344 | && !array_key_exists('scheduled', $value) |
| 345 | 345 | && isset($value['message']) && $value['message'] == $options['message'] |
| 346 | - ; |
|
| 347 | - } |
|
| 348 | - )) |
|
| 349 | - ->willReturn(null); |
|
| 346 | + ; |
|
| 347 | + } |
|
| 348 | + )) |
|
| 349 | + ->willReturn(null); |
|
| 350 | 350 | |
| 351 | 351 | $this->target->fail($job, $options); |
| 352 | 352 | } |
@@ -71,7 +71,7 @@ discard block |
||
| 71 | 71 | |
| 72 | 72 | public function testDoesDeleteJobIfProcessedSuccessfully() |
| 73 | 73 | { |
| 74 | - /* @var AbstractJob $jobMock */ |
|
| 74 | + /* @var AbstractJob $jobMock */ |
|
| 75 | 75 | $job = $this->prophesize(AbstractJob::class); |
| 76 | 76 | $job->execute()->willReturn(ProcessJobEvent::JOB_STATUS_SUCCESS); |
| 77 | 77 | $jobMock = $job->reveal(); |
@@ -90,7 +90,7 @@ discard block |
||
| 90 | 90 | { |
| 91 | 91 | $options = ['delay' => 10]; |
| 92 | 92 | |
| 93 | - /* @var AbstractJob $jobMock */ |
|
| 93 | + /* @var AbstractJob $jobMock */ |
|
| 94 | 94 | $job = $this->prophesize(AbstractJob::class); |
| 95 | 95 | $job->execute()->willThrow(new RecoverableJobException('test recoverable', $options)); |
| 96 | 96 | $jobMock = $job->reveal(); |
@@ -111,7 +111,7 @@ discard block |
||
| 111 | 111 | { |
| 112 | 112 | $queueName = 'test'; |
| 113 | 113 | $queue = $this->getMockBuilder(MongoQueue::class)->disableOriginalConstructor() |
| 114 | - ->setMethods(['listing'])->getMock(); |
|
| 114 | + ->setMethods(['listing'])->getMock(); |
|
| 115 | 115 | $this->queueManager->expects($this->once())->method('get')->with($queueName)->willReturn($queue); |
| 116 | 116 | $params = $this->setupParamsMock([ |
| 117 | 117 | ['queue', null, $queueName], |
@@ -135,13 +135,13 @@ discard block |
||
| 135 | 135 | $date = new \DateTime(); |
| 136 | 136 | $date->setTimezone(new \DateTimeZone('UTC')); |
| 137 | 137 | $jobs = [ |
| 138 | - [ |
|
| 139 | - 'job' => $job, |
|
| 140 | - 'created' => new \MongoDb\BSON\UTCDateTime($date->getTimestamp() * 1000), |
|
| 141 | - 'executed' => new \MongoDb\BSON\UTCDateTime($date->getTimestamp() * 1000), |
|
| 142 | - 'scheduled' => new \MongoDb\BSON\UTCDateTime($date->getTimestamp() * 1000), |
|
| 143 | - 'tried' => 10, |
|
| 144 | - ], |
|
| 138 | + [ |
|
| 139 | + 'job' => $job, |
|
| 140 | + 'created' => new \MongoDb\BSON\UTCDateTime($date->getTimestamp() * 1000), |
|
| 141 | + 'executed' => new \MongoDb\BSON\UTCDateTime($date->getTimestamp() * 1000), |
|
| 142 | + 'scheduled' => new \MongoDb\BSON\UTCDateTime($date->getTimestamp() * 1000), |
|
| 143 | + 'tried' => 10, |
|
| 144 | + ], |
|
| 145 | 145 | ]; |
| 146 | 146 | |
| 147 | 147 | $queue->expects($this->once())->method('listing')->with(['limit' => 10, 'status' => 1])->willReturn($jobs); |
@@ -76,25 +76,25 @@ |
||
| 76 | 76 | 'log' => array( |
| 77 | 77 | 'Core/Log' => array( |
| 78 | 78 | 'writers' => array( |
| 79 | - array( |
|
| 80 | - 'name' => 'stream', |
|
| 79 | + array( |
|
| 80 | + 'name' => 'stream', |
|
| 81 | 81 | 'priority' => 1000, |
| 82 | 82 | 'options' => array( |
| 83 | - 'stream' => getcwd().'/var/log/yawik.log', |
|
| 83 | + 'stream' => getcwd().'/var/log/yawik.log', |
|
| 84 | + ), |
|
| 84 | 85 | ), |
| 85 | - ), |
|
| 86 | 86 | ), |
| 87 | 87 | ), |
| 88 | 88 | 'Log/Core/Mail' => array( |
| 89 | 89 | 'writers' => array( |
| 90 | - array( |
|
| 91 | - 'name' => 'stream', |
|
| 90 | + array( |
|
| 91 | + 'name' => 'stream', |
|
| 92 | 92 | 'priority' => 1000, |
| 93 | 93 | 'options' => array( |
| 94 | - 'stream' => getcwd().'/var/log/mails.log', |
|
| 94 | + 'stream' => getcwd().'/var/log/mails.log', |
|
| 95 | 95 | ), |
| 96 | 96 | |
| 97 | - ), |
|
| 97 | + ), |
|
| 98 | 98 | ), |
| 99 | 99 | ), |
| 100 | 100 | 'Log/Core/Queue' => array( |