public function testFailedCapture() { $capture = new Capture(); $capture->success = false; $action = new CaptureResponseAction(); $action->execute($capture); $job = $this->jobQueue->pop(); $this->assertNull($job, 'Should not have queued a job'); }
public function testFailedAuth() { $auth = new Authorisation(); $auth->success = false; $auth->correlationId = 'adyen-' . mt_rand(); $auth->merchantAccountCode = 'WikimediaTest'; $auth->merchantReference = mt_rand(); $action = new PaymentCaptureAction(); $action->execute($auth); $job = $this->jobQueue->pop(); $this->assertEquals('SmashPig\\Core\\Jobs\\DeletePendingJob', $job['php-message-class']); $this->assertEquals($auth->merchantReference, $job['order_id']); $this->assertEquals('adyen', $job['gateway']); }
public function testKeepRunningOnDamage() { $messages = array(); for ($i = 0; $i < 5; $i++) { $message = array('gateway' => 'test', 'date' => time(), 'order_id' => mt_rand(), 'box' => 'thing' . $i, 'creepiness' => mt_rand()); $messages[] = $message; $this->queue->push($message); } $consumer = new TestingQueueConsumer('test', 0, 3); $consumer->exception = new Exception('Kaboom!'); $count = 0; try { $count = $consumer->dequeueMessages(); } catch (Exception $ex) { $this->fail('Exception should not have bubbled up: ' . $ex->getMessage()); } $this->assertEquals(3, $count, 'dequeueMessages returned wrong count'); $this->assertEquals(3, count($consumer->processed), 'Called callback wrong number of times'); for ($i = 0; $i < 3; $i++) { $this->assertEquals($messages[$i], $consumer->processed[$i], 'Message mutated'); $damaged = $this->getDamagedQueueMessage($messages[$i]); $this->assertEquals($messages[$i], $damaged, 'Should move message to damaged queue when exception is thrown'); } $this->assertEquals($messages[3], $this->queue->pop(), 'message 4 should be at the head of the queue'); }
public function testReportAvailable() { $filename = 'settlement_detail_report_2016_10_13.csv'; $account = 'WikimediaTest'; $url = "https://example.com/reports/download/MerchantAccount/{$account}/{$filename}"; $reportAvailable = new ReportAvailable(); $reportAvailable->correlationId = 'adyen-' . mt_rand(); $reportAvailable->merchantAccountCode = $account; $reportAvailable->merchantReference = mt_rand(); $reportAvailable->pspReference = $filename; $reportAvailable->reason = $url; $reportAvailable->eventDate = '2016-10-14T12:06:20.496+02:00'; $reportAvailable->runActionChain(); $job = $this->jobQueue->pop(); $now = UtcDate::getUtcTimestamp(); $diff = abs($job['source_enqueued_time']) - $now; $this->assertTrue($diff < 60, 'Odd enqueued time'); $unsetFields = array('source_enqueued_time', 'source_host', 'source_run_id', 'source_version', 'propertiesExcludedFromExport', 'propertiesExportedAsKeys'); foreach ($unsetFields as $fieldName) { unset($job[$fieldName]); } $expected = array('php-message-class' => 'SmashPig\\PaymentProviders\\Adyen\\Jobs\\DownloadReportJob', 'reportUrl' => $url, 'account' => $account, 'source_name' => 'SmashPig', 'source_type' => 'listener', 'correlationId' => '', 'gateway' => 'adyen'); $this->assertEquals($expected, $job); }