Commit 06925ad7 authored by Emiliano Balbuena's avatar Emiliano Balbuena

(test): pro spec tests

1 merge request!308WIP: (feat): Minds Pro
Pipeline #81442706 failed with stages
in 4 minutes and 13 seconds
......@@ -62,10 +62,12 @@ class Domain
* @return string
* @throws Exception
*/
public function getIcon(Settings $settings)
public function getIcon(Settings $settings, User $owner = null)
{
$owner = new User();
$owner->guid = $settings->getUserGuid();
if (!$owner) {
$owner = new User();
$owner->guid = $settings->getUserGuid();
}
return $owner->getIconURL('large');
}
......
<?php
namespace Spec\Minds\Core\Pro;
use Minds\Common\Repository\Response;
use Minds\Core\Config;
use Minds\Core\Pro\Domain;
use Minds\Core\Pro\Repository;
use Minds\Core\Pro\Settings;
use Minds\Entities\User;
use PhpSpec\ObjectBehavior;
use Prophecy\Argument;
class DomainSpec extends ObjectBehavior
{
/** @var Config */
protected $config;
/** @var Repository */
protected $repository;
function let(
Config $config,
Repository $repository
)
{
$this->config = $config;
$this->repository = $repository;
$this->beConstructedWith($config, $repository);
}
function it_is_initializable()
{
$this->shouldHaveType(Domain::class);
}
function it_should_lookup_for_a_domain(
Response $repositoryResponse,
Settings $settings
)
{
$this->config->get('root_domains')
->shouldBeCalled()
->willReturn(['minds.com']);
$this->repository->getList([
'domain' => 'minds.test',
])
->shouldBeCalled()
->willReturn($repositoryResponse);
$repositoryResponse->first()
->shouldBeCalled()
->willReturn($settings);
$this
->lookup('minds.test')
->shouldReturn($settings);
}
function it_should_get_an_icon(
Settings $settings,
User $user
)
{
$user->getIconURL('large')
->shouldBeCalled()
->willReturn('/1000/large');
$this->getIcon($settings, $user)
->shouldReturn('/1000/large');
}
}
<?php
namespace Spec\Minds\Core\Pro;
use Minds\Core\Pro\Settings;
use PhpSpec\ObjectBehavior;
use Prophecy\Argument;
class SettingsSpec extends ObjectBehavior
{
function it_is_initializable()
{
$this->shouldHaveType(Settings::class);
}
function it_should_get_one_line_headline_from_single_line_value()
{
$this->setHeadline('This is a headline');
$this
->getOneLineHeadline()
->shouldReturn('This is a headline');
}
function it_should_get_one_line_headline_from_multi_line_value()
{
$this->setHeadline("This is a headline.\nOther line");
$this
->getOneLineHeadline()
->shouldReturn('This is a headline. Other line');
}
function it_should_export()
{
$this
->export()
->shouldBeArray();
}
function it_should_build_styles()
{
$this
->buildStyles()
->shouldBeArray();
}
function it_should_calc_tile_ratio_percentage()
{
$this
->setTileRatio('1:1');
$this
->calcTileRatioPercentage()
->shouldReturn(100.0);
$this
->setTileRatio('4:3');
$this
->calcTileRatioPercentage()
->shouldReturn(75.0);
$this
->setTileRatio('16:10');
$this
->calcTileRatioPercentage()
->shouldReturn(62.5);
$this
->setTileRatio('16:9');
$this
->calcTileRatioPercentage()
->shouldReturn(56.25);
$this
->setTileRatio('');
$this
->calcTileRatioPercentage()
->shouldReturn(56.25);
}
}
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