mirror of
https://github.com/shlinkio/shlink.git
synced 2024-11-28 00:38:46 +03:00
Refactored API tests fixtures to avoid using deprecated methods
This commit is contained in:
parent
82091c7951
commit
09f25d78b7
2 changed files with 16 additions and 31 deletions
|
@ -18,18 +18,23 @@ class ShortUrlsFixture extends AbstractFixture implements DependentFixtureInterf
|
||||||
{
|
{
|
||||||
public function getDependencies(): array
|
public function getDependencies(): array
|
||||||
{
|
{
|
||||||
return [ApiKeyFixture::class];
|
return [ApiKeyFixture::class, TagsFixture::class];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function load(ObjectManager $manager): void
|
public function load(ObjectManager $manager): void
|
||||||
{
|
{
|
||||||
|
$relationResolver = new PersistenceShortUrlRelationResolver($manager);
|
||||||
|
|
||||||
/** @var ApiKey $authorApiKey */
|
/** @var ApiKey $authorApiKey */
|
||||||
$authorApiKey = $this->getReference('author_api_key');
|
$authorApiKey = $this->getReference('author_api_key');
|
||||||
|
|
||||||
$abcShortUrl = $this->setShortUrlDate(
|
$abcShortUrl = $this->setShortUrlDate(
|
||||||
ShortUrl::fromMeta(ShortUrlMeta::fromRawData(
|
ShortUrl::fromMeta(ShortUrlMeta::fromRawData([
|
||||||
['customSlug' => 'abc123', 'apiKey' => $authorApiKey, 'longUrl' => 'https://shlink.io'],
|
'customSlug' => 'abc123',
|
||||||
)),
|
'apiKey' => $authorApiKey,
|
||||||
|
'longUrl' => 'https://shlink.io',
|
||||||
|
'tags' => ['foo'],
|
||||||
|
]), $relationResolver),
|
||||||
'2018-05-01',
|
'2018-05-01',
|
||||||
);
|
);
|
||||||
$manager->persist($abcShortUrl);
|
$manager->persist($abcShortUrl);
|
||||||
|
@ -40,7 +45,8 @@ class ShortUrlsFixture extends AbstractFixture implements DependentFixtureInterf
|
||||||
'apiKey' => $authorApiKey,
|
'apiKey' => $authorApiKey,
|
||||||
'longUrl' =>
|
'longUrl' =>
|
||||||
'https://blog.alejandrocelaya.com/2017/12/09/acmailer-7-0-the-most-important-release-in-a-long-time/',
|
'https://blog.alejandrocelaya.com/2017/12/09/acmailer-7-0-the-most-important-release-in-a-long-time/',
|
||||||
])), '2019-01-01 00:00:10');
|
'tags' => ['foo', 'bar'],
|
||||||
|
]), $relationResolver), '2019-01-01 00:00:10');
|
||||||
$manager->persist($defShortUrl);
|
$manager->persist($defShortUrl);
|
||||||
|
|
||||||
$customShortUrl = $this->setShortUrlDate(ShortUrl::fromMeta(ShortUrlMeta::fromRawData(
|
$customShortUrl = $this->setShortUrlDate(ShortUrl::fromMeta(ShortUrlMeta::fromRawData(
|
||||||
|
@ -61,7 +67,8 @@ class ShortUrlsFixture extends AbstractFixture implements DependentFixtureInterf
|
||||||
'customSlug' => 'ghi789',
|
'customSlug' => 'ghi789',
|
||||||
'longUrl' => 'https://blog.alejandrocelaya.com/2019/04/27/considerations-to-properly-use-open-'
|
'longUrl' => 'https://blog.alejandrocelaya.com/2019/04/27/considerations-to-properly-use-open-'
|
||||||
. 'source-software-projects/',
|
. 'source-software-projects/',
|
||||||
]), new PersistenceShortUrlRelationResolver($manager)), '2019-01-01 00:00:30');
|
'tags' => ['foo'],
|
||||||
|
]), $relationResolver), '2019-01-01 00:00:30');
|
||||||
$manager->persist($withDomainDuplicatingShortCode);
|
$manager->persist($withDomainDuplicatingShortCode);
|
||||||
|
|
||||||
$withDomainAndSlugShortUrl = $this->setShortUrlDate(ShortUrl::fromMeta(ShortUrlMeta::fromRawData(
|
$withDomainAndSlugShortUrl = $this->setShortUrlDate(ShortUrl::fromMeta(ShortUrlMeta::fromRawData(
|
||||||
|
|
|
@ -4,40 +4,18 @@ declare(strict_types=1);
|
||||||
|
|
||||||
namespace ShlinkioApiTest\Shlink\Rest\Fixtures;
|
namespace ShlinkioApiTest\Shlink\Rest\Fixtures;
|
||||||
|
|
||||||
use Doctrine\Common\Collections\ArrayCollection;
|
|
||||||
use Doctrine\Common\DataFixtures\AbstractFixture;
|
use Doctrine\Common\DataFixtures\AbstractFixture;
|
||||||
use Doctrine\Common\DataFixtures\DependentFixtureInterface;
|
|
||||||
use Doctrine\Persistence\ObjectManager;
|
use Doctrine\Persistence\ObjectManager;
|
||||||
use Shlinkio\Shlink\Core\Entity\ShortUrl;
|
|
||||||
use Shlinkio\Shlink\Core\Entity\Tag;
|
use Shlinkio\Shlink\Core\Entity\Tag;
|
||||||
|
|
||||||
class TagsFixture extends AbstractFixture implements DependentFixtureInterface
|
class TagsFixture extends AbstractFixture
|
||||||
{
|
{
|
||||||
public function getDependencies(): array
|
|
||||||
{
|
|
||||||
return [ShortUrlsFixture::class];
|
|
||||||
}
|
|
||||||
|
|
||||||
public function load(ObjectManager $manager): void
|
public function load(ObjectManager $manager): void
|
||||||
{
|
{
|
||||||
$fooTag = new Tag('foo');
|
$manager->persist(new Tag('foo'));
|
||||||
$manager->persist($fooTag);
|
$manager->persist(new Tag('bar'));
|
||||||
$barTag = new Tag('bar');
|
|
||||||
$manager->persist($barTag);
|
|
||||||
$manager->persist(new Tag('baz'));
|
$manager->persist(new Tag('baz'));
|
||||||
|
|
||||||
/** @var ShortUrl $abcShortUrl */
|
|
||||||
$abcShortUrl = $this->getReference('abc123_short_url');
|
|
||||||
$abcShortUrl->setTags(new ArrayCollection([$fooTag]));
|
|
||||||
|
|
||||||
/** @var ShortUrl $defShortUrl */
|
|
||||||
$defShortUrl = $this->getReference('def456_short_url');
|
|
||||||
$defShortUrl->setTags(new ArrayCollection([$fooTag, $barTag]));
|
|
||||||
|
|
||||||
/** @var ShortUrl $exampleShortUrl */
|
|
||||||
$exampleShortUrl = $this->getReference('example_short_url');
|
|
||||||
$exampleShortUrl->setTags(new ArrayCollection([$fooTag]));
|
|
||||||
|
|
||||||
$manager->flush();
|
$manager->flush();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue