Commit 2042213a authored by Juan Manuel Solaro's avatar Juan Manuel Solaro

(test) add specs for scheduled manager and repository

1 merge request!294WIP: epic/post-scheduler
Pipeline #77654334 passed with stages
in 9 minutes and 42 seconds
<?php
namespace Spec\Minds\Core\Feeds\Scheduled;
use Minds\Core\EntitiesBuilder;
use Minds\Core\Feeds\Scheduled\Manager;
use Minds\Core\Feeds\Scheduled\Repository;
use Minds\Core\Search\Search;
use PhpSpec\ObjectBehavior;
class ManagerSpec extends ObjectBehavior
{
/** @var Repository */
protected $repository;
/** @var EntitiesBuilder */
protected $entitiesBuilder;
/** @var Search */
protected $search;
function let(
Repository $repository
)
{
$this->repository = $repository;
$this->beConstructedWith($repository);
}
function it_is_initializable()
{
$this->shouldHaveType(Manager::class);
}
public function it_should_get_scheduled_count()
{
$argument = ['container_guid' => 9999, 'type' => 'activity'];
$this->repository->getScheduledCount($argument)
->shouldBeCalled()
->willReturn(1);
$this->getScheduledCount($argument);
}
}
<?php
namespace Spec\Minds\Core\Feeds\Scheduled;
use Minds\Core\Config;
use Minds\Core\Data\ElasticSearch\Client;
use Minds\Core\Data\ElasticSearch\Prepared\Count;
use Minds\Core\Feeds\Scheduled\Repository;
use PhpSpec\ObjectBehavior;
use Prophecy\Argument;
class RepositorySpec extends ObjectBehavior
{
/** @var Client */
protected $client;
/** @var Config */
protected $config;
function let(Client $client, Config $config)
{
$this->client = $client;
$this->config = $config;
$config->get('elasticsearch')
->shouldBeCalled()
->willReturn(['index' => 'minds']);
$this->beConstructedWith($client, $config);
}
function it_is_initializable()
{
$this->shouldHaveType(Repository::class);
}
function it_should_count_scheduled_activities()
{
$opts = ['container_guid' => 9999, 'type' => 'activity'];
$this->client->request(Argument::type(Count::class))
->shouldBeCalled()
->willReturn([
"count" => 1,
"_shards" => [
"total" => 5,
"successful" => 5,
"skipped" => 0,
"failed" => 0
]
]);
$this->getScheduledCount($opts);
}
}
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