Skip to content
Commits on Source (2)
......@@ -2,8 +2,18 @@
namespace Minds\Core\Boost\Campaigns;
use Elasticsearch\Client;
class Stats
{
/** @var Client */
protected $esClient;
public function __construct(Client $esClient)
{
}
/**
* @param Campaign $campaign
* @return array
......
......@@ -63,8 +63,7 @@ class ManagerSpec extends ObjectBehavior
NormalizeHashtagsDelegate $normalizeHashtagsDelegate,
PaymentsDelegate $paymentsDelegate,
User $user
)
{
) {
$this->beConstructedWith(
$repository,
$elasticRepository,
......@@ -394,8 +393,24 @@ class ManagerSpec extends ObjectBehavior
$this->completeCampaign($campaignRef)->shouldReturn($campaign);
}
public function it_should_perform_actions_on_payment_success(Payment $payment)
public function it_should_perform_actions_on_payment_success(Payment $payment, Campaign $campaign, Response $response)
{
$payment->getCampaignGuid()->shouldBeCalled()->willReturn(1234);
$this->repository->getCampaignByGuid(Argument::type('array'))->shouldBeCalled()->willReturn($response);
$response->map(Argument::type('Callable'))->willReturn($response);
$response->toArray()->shouldBeCalled()->willReturn([
$campaign
]);
$this->paymentsDelegate->onConfirm($campaign, $payment)->shouldBeCalled()->willReturn($campaign);
$this->repository->putCampaign($campaign)->shouldBeCalled();
$this->elasticRepository->putCampaign($campaign)->shouldBeCalled();
$this->queueClient->setQueue('BoostCampaignDispatcher')->shouldBeCalled()->willReturn($this->queueClient);
$this->queueClient->send(Argument::type('array'))->shouldBeCalled();
$this->onPaymentSuccess($payment);
}
}