Skip to content
Commits on Source (2)
...@@ -2,8 +2,18 @@ ...@@ -2,8 +2,18 @@
namespace Minds\Core\Boost\Campaigns; namespace Minds\Core\Boost\Campaigns;
use Elasticsearch\Client;
class Stats class Stats
{ {
/** @var Client */
protected $esClient;
public function __construct(Client $esClient)
{
}
/** /**
* @param Campaign $campaign * @param Campaign $campaign
* @return array * @return array
......
...@@ -63,8 +63,7 @@ class ManagerSpec extends ObjectBehavior ...@@ -63,8 +63,7 @@ class ManagerSpec extends ObjectBehavior
NormalizeHashtagsDelegate $normalizeHashtagsDelegate, NormalizeHashtagsDelegate $normalizeHashtagsDelegate,
PaymentsDelegate $paymentsDelegate, PaymentsDelegate $paymentsDelegate,
User $user User $user
) ) {
{
$this->beConstructedWith( $this->beConstructedWith(
$repository, $repository,
$elasticRepository, $elasticRepository,
...@@ -394,8 +393,24 @@ class ManagerSpec extends ObjectBehavior ...@@ -394,8 +393,24 @@ class ManagerSpec extends ObjectBehavior
$this->completeCampaign($campaignRef)->shouldReturn($campaign); $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); $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);
} }
} }