2020-09-10 10:13:52 +02:00
|
|
|
<?php
|
2020-09-21 14:59:34 +02:00
|
|
|
|
2020-09-24 16:54:45 +02:00
|
|
|
declare(strict_types=1);
|
2020-09-10 10:13:52 +02:00
|
|
|
|
|
|
|
namespace SkillDisplay\PHPToolKit\Tests\Unit\Verification;
|
|
|
|
|
|
|
|
use Prophecy\PhpUnit\ProphecyTrait;
|
|
|
|
use SkillDisplay\PHPToolKit\Configuration\Settings;
|
|
|
|
use SkillDisplay\PHPToolKit\Verification\Link;
|
|
|
|
use PHPUnit\Framework\TestCase;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @covers SkillDisplay\PHPToolKit\Verification\Link
|
|
|
|
*/
|
|
|
|
class LinkTest extends TestCase
|
|
|
|
{
|
|
|
|
use ProphecyTrait;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @test
|
|
|
|
*/
|
|
|
|
public function instanceCanBeCreated()
|
|
|
|
{
|
|
|
|
$settings = $this->prophesize(Settings::class);
|
|
|
|
$subject = new Link(
|
|
|
|
$settings->reveal(),
|
|
|
|
10
|
|
|
|
);
|
|
|
|
static::assertInstanceOf(Link::class, $subject);
|
|
|
|
}
|
|
|
|
|
2020-09-10 09:47:22 +02:00
|
|
|
/**
|
|
|
|
* @test
|
|
|
|
*/
|
|
|
|
public function instanceCanBeCreatedWithoutSkillId()
|
|
|
|
{
|
|
|
|
$settings = $this->prophesize(Settings::class);
|
|
|
|
$subject = new Link($settings->reveal());
|
|
|
|
static::assertInstanceOf(Link::class, $subject);
|
|
|
|
}
|
|
|
|
|
2020-09-10 10:13:52 +02:00
|
|
|
/**
|
|
|
|
* @test
|
|
|
|
*/
|
2020-10-08 16:47:44 +02:00
|
|
|
public function canReturnSkillVerificationLinkForEducationalWithCampaign()
|
2020-09-10 10:13:52 +02:00
|
|
|
{
|
|
|
|
$settings = $this->prophesize(Settings::class);
|
|
|
|
$settings->getMySkillDisplayUrl()->willReturn('https://my.example.com/verify');
|
|
|
|
|
|
|
|
$subject = new Link($settings->reveal(), 10);
|
|
|
|
|
|
|
|
static::assertSame(
|
2020-10-08 16:47:44 +02:00
|
|
|
'https://my.example.com/verify/skillup/skill/10/0/2/678',
|
|
|
|
$subject->getVerificationLink('education', null, Link::SKILL, 678)
|
2020-09-10 10:13:52 +02:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @test
|
|
|
|
*/
|
2020-09-22 13:49:08 +02:00
|
|
|
public function canReturnSkillVerificationLinkForBusiness()
|
2020-09-10 10:13:52 +02:00
|
|
|
{
|
|
|
|
$settings = $this->prophesize(Settings::class);
|
|
|
|
$settings->getMySkillDisplayUrl()->willReturn('https://my.example.com/verify');
|
|
|
|
|
|
|
|
$subject = new Link($settings->reveal(), 10);
|
|
|
|
|
|
|
|
static::assertSame(
|
|
|
|
'https://my.example.com/verify/skillup/skill/10/0/4',
|
|
|
|
$subject->getVerificationLink('business')
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @test
|
|
|
|
*/
|
2020-09-22 13:49:08 +02:00
|
|
|
public function canReturnSkillVerificationLinkForCertification()
|
2020-09-10 10:13:52 +02:00
|
|
|
{
|
|
|
|
$settings = $this->prophesize(Settings::class);
|
|
|
|
$settings->getMySkillDisplayUrl()->willReturn('https://my.example.com/verify');
|
|
|
|
|
|
|
|
$subject = new Link($settings->reveal(), 10);
|
|
|
|
|
|
|
|
static::assertSame(
|
|
|
|
'https://my.example.com/verify/skillup/skill/10/0/1',
|
|
|
|
$subject->getVerificationLink('certification')
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @test
|
|
|
|
*/
|
2020-09-22 13:49:08 +02:00
|
|
|
public function canReturnSkillVerificationLinkForSelf()
|
2020-09-10 10:13:52 +02:00
|
|
|
{
|
|
|
|
$settings = $this->prophesize(Settings::class);
|
|
|
|
$settings->getMySkillDisplayUrl()->willReturn('https://my.example.com/verify');
|
|
|
|
|
|
|
|
$subject = new Link($settings->reveal(), 10);
|
|
|
|
|
|
|
|
static::assertSame(
|
|
|
|
'https://my.example.com/verify/skillup/skill/10/0/3',
|
|
|
|
$subject->getVerificationLink('self')
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2020-09-22 13:49:08 +02:00
|
|
|
/**
|
|
|
|
* @test
|
|
|
|
*/
|
|
|
|
public function canReturnSkillSetVerificationLinkForEducational()
|
|
|
|
{
|
|
|
|
$settings = $this->prophesize(Settings::class);
|
|
|
|
$settings->getMySkillDisplayUrl()->willReturn('https://my.example.com/verify');
|
|
|
|
|
|
|
|
$subject = new Link($settings->reveal(), 10);
|
|
|
|
|
|
|
|
static::assertSame(
|
2020-10-19 11:48:02 +02:00
|
|
|
'https://my.example.com/verify/skillup/skillset/0/10/2',
|
2020-09-22 13:49:08 +02:00
|
|
|
$subject->getVerificationLink('education', null, Link::SKILL_SET)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @test
|
|
|
|
*/
|
|
|
|
public function canReturnSkillSetVerificationLinkForBusiness()
|
|
|
|
{
|
|
|
|
$settings = $this->prophesize(Settings::class);
|
|
|
|
$settings->getMySkillDisplayUrl()->willReturn('https://my.example.com/verify');
|
|
|
|
|
|
|
|
$subject = new Link($settings->reveal(), 10);
|
|
|
|
|
|
|
|
static::assertSame(
|
2020-10-19 11:48:02 +02:00
|
|
|
'https://my.example.com/verify/skillup/skillset/0/10/4',
|
2020-09-22 13:49:08 +02:00
|
|
|
$subject->getVerificationLink('business', null, Link::SKILL_SET)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @test
|
|
|
|
*/
|
|
|
|
public function canReturnSkillSetVerificationLinkForCertification()
|
|
|
|
{
|
|
|
|
$settings = $this->prophesize(Settings::class);
|
|
|
|
$settings->getMySkillDisplayUrl()->willReturn('https://my.example.com/verify');
|
|
|
|
|
|
|
|
$subject = new Link($settings->reveal(), 10);
|
|
|
|
|
|
|
|
static::assertSame(
|
2020-10-19 11:48:02 +02:00
|
|
|
'https://my.example.com/verify/skillup/skillset/0/10/1',
|
2020-09-22 13:49:08 +02:00
|
|
|
$subject->getVerificationLink('certification', null, Link::SKILL_SET)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @test
|
|
|
|
*/
|
|
|
|
public function canReturnSkillSetVerificationLinkForSelf()
|
|
|
|
{
|
|
|
|
$settings = $this->prophesize(Settings::class);
|
|
|
|
$settings->getMySkillDisplayUrl()->willReturn('https://my.example.com/verify');
|
|
|
|
|
|
|
|
$subject = new Link($settings->reveal(), 10);
|
|
|
|
|
|
|
|
static::assertSame(
|
2020-10-19 11:48:02 +02:00
|
|
|
'https://my.example.com/verify/skillup/skillset/0/10/3',
|
2020-09-22 13:49:08 +02:00
|
|
|
$subject->getVerificationLink('self', null, Link::SKILL_SET)
|
|
|
|
);
|
|
|
|
}
|
2023-07-06 13:53:06 +02:00
|
|
|
|
2020-09-22 11:16:59 +02:00
|
|
|
/**
|
|
|
|
* @test
|
|
|
|
*/
|
|
|
|
public function throwsExceptionIfNoSkillIdIsProvided()
|
|
|
|
{
|
|
|
|
$settings = $this->prophesize(Settings::class);
|
|
|
|
$settings->getMySkillDisplayUrl()->willReturn('https://my.example.com/verify');
|
|
|
|
|
|
|
|
$subject = new Link($settings->reveal());
|
|
|
|
|
2020-09-22 13:49:08 +02:00
|
|
|
$this->expectExceptionMessage('No ID provided.');
|
2020-09-22 11:16:59 +02:00
|
|
|
$this->expectExceptionCode(1599723825);
|
|
|
|
$subject->getVerificationLink('education');
|
|
|
|
}
|
2020-09-22 13:49:08 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @test
|
|
|
|
*/
|
|
|
|
public function throwsExceptionIfInvalidTypeIsProvided()
|
|
|
|
{
|
|
|
|
$settings = $this->prophesize(Settings::class);
|
|
|
|
$settings->getMySkillDisplayUrl()->willReturn('https://my.example.com/verify');
|
|
|
|
|
|
|
|
$subject = new Link($settings->reveal());
|
|
|
|
|
|
|
|
$this->expectExceptionMessage('$type has to be "skill" or "skillset" but "invalid" given.');
|
|
|
|
$this->expectExceptionCode(1600774955);
|
|
|
|
|
|
|
|
$subject->getVerificationLink('education', null, 'invalid');
|
|
|
|
}
|
2020-09-10 10:13:52 +02:00
|
|
|
}
|