Commit 6b58cdb9 authored by Emiliano Balbuena's avatar Emiliano Balbuena

(test): Fix spec tests

-subdomain=boost-campaigns
No related merge requests found
Pipeline #68539009 failed with stages
in 12 minutes and 15 seconds
......@@ -15,7 +15,9 @@ use Minds\Traits\MagicAttributes;
* @method Boost setEntiyGuid()
* @method Boost setEntity()
* @method Entity getEntity()
* @method string getBid()
* @method Boost setBid()
* @method string getBidType()
* @method Boost setBidType()
* @method Booot setImpressions()
* @method int getImpressions()
......@@ -23,13 +25,20 @@ use Minds\Traits\MagicAttributes;
* @method long getOwnerGuid()
* @method Boost setOwner()
* @method User getOwner()
*
* @method bool isPriority()
* @method int getRating()
* @method int getImpressionsMet()
* @method Boost setRejectedReason(int $reason)
* @method int getRejectedReason()
* @method int getCompletedTimestamp()
* @method Boost setCompletedTimestamp(int $ts)
* @method int getReviewedTimestamp()
* @method Boost setReviewedTimestamp(int $ts)
* @method int getRejectedTimestamp()
* @method Boost setRejectedTimestamp(int $ts)
* @method int getCreatedTimestamp()
* @method Boost setCreatedTimestamp(int $ts)
* @method int getRevokedTimestamp()
* @method Boost setRevokedTimestamp(int $ts)
* @method array getTags()
* @method Boost setTags(array $value)
......
......@@ -4,18 +4,20 @@ namespace Spec\Minds\Core\Boost\Network;
use Minds\Core\Boost\Network\ElasticRepository;
use Minds\Core\Boost\Network\Boost;
use Minds\Core\Boost\Raw\ElasticRepository as RawElasticRepository;
use Minds\Core\Boost\Raw\RawBoost;
use Minds\Core\Data\ElasticSearch\Client as Elastic;
use PhpSpec\ObjectBehavior;
use Prophecy\Argument;
class ElasticRepositorySpec extends ObjectBehavior
{
private $es;
private $rawElasticRepository;
function let(Elastic $es)
function let(RawElasticRepository $rawElasticRepository)
{
$this->beConstructedWith($es);
$this->es = $es;
$this->beConstructedWith($rawElasticRepository);
$this->rawElasticRepository = $rawElasticRepository;
}
function it_is_initializable()
......@@ -23,42 +25,11 @@ class ElasticRepositorySpec extends ObjectBehavior
$this->shouldHaveType(ElasticRepository::class);
}
function it_should_add()
function it_should_add(Boost $boost)
{
$boost = (new Boost())
->setCreatedTimestamp(time() * 1000)
->setCompletedTimestamp(time() * 1000)
->setReviewedTimestamp(time() * 1000)
->setRevokedTimestamp(time() * 1000)
->setRejectedTimestamp(time() * 1000)
->setBid(10 * (10**18))
->setBidType('tokens')
->setEntityGuid(123)
->setImpressions(10000)
->setImpressionsMet(10)
->setOwnerGuid(456)
->setRating(1)
->setType('newsfeed')
->setPriority(false);
// TODO: Improve test case prophecies
$this->es->request(Argument::that(function($prepared) {
$body = $prepared->build()['body'];
return round($body['doc']['@timestamp'], -5) === round(time() * 1000, -5)
&& round($body['doc']['@completed'], -5) === round(time() * 1000, -5)
&& round($body['doc']['@reviewed'], -5) === round(time() * 1000, -5)
&& round($body['doc']['@revoked'], -5) === round(time() * 1000, -5)
&& round($body['doc']['@rejected'], -5) === round(time() * 1000, -5)
&& $body['doc']['bid'] == 10
&& $body['doc']['bid_type'] === 'tokens'
&& $body['doc']['token_method'] === 'offchain'
&& $body['doc']['entity_guid'] === 123
&& $body['doc']['impressions'] === 10000
&& $body['doc']['impressions_met'] === 10
&& $body['doc']['owner_guid'] === 456
&& $body['doc']['type'] === 'newsfeed'
&& $body['doc']['priority'] === false;
}))
$this->rawElasticRepository->add(Argument::type(RawBoost::class))
->shouldBeCalled()
->willReturn(true);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment