mirror of
https://github.com/shlinkio/shlink.git
synced 2025-03-29 04:52:54 +03:00
Hardcoded different creation dates for fixture short URLs to avoid random API test failures
This commit is contained in:
parent
4334ea295d
commit
75b91dc26b
2 changed files with 10 additions and 10 deletions
|
@ -46,7 +46,7 @@ class ListShortUrlsTest extends ApiTestCase
|
||||||
'longUrl' =>
|
'longUrl' =>
|
||||||
'https://blog.alejandrocelaya.com/2017/12/09'
|
'https://blog.alejandrocelaya.com/2017/12/09'
|
||||||
. '/acmailer-7-0-the-most-important-release-in-a-long-time/',
|
. '/acmailer-7-0-the-most-important-release-in-a-long-time/',
|
||||||
'dateCreated' => '2019-01-01T00:00:00+00:00',
|
'dateCreated' => '2019-01-01T00:00:10+00:00',
|
||||||
'visitsCount' => 2,
|
'visitsCount' => 2,
|
||||||
'tags' => ['bar', 'foo'],
|
'tags' => ['bar', 'foo'],
|
||||||
'meta' => [
|
'meta' => [
|
||||||
|
@ -62,7 +62,7 @@ class ListShortUrlsTest extends ApiTestCase
|
||||||
'shortCode' => 'custom',
|
'shortCode' => 'custom',
|
||||||
'shortUrl' => 'http://doma.in/custom',
|
'shortUrl' => 'http://doma.in/custom',
|
||||||
'longUrl' => 'https://shlink.io',
|
'longUrl' => 'https://shlink.io',
|
||||||
'dateCreated' => '2019-01-01T00:00:00+00:00',
|
'dateCreated' => '2019-01-01T00:00:20+00:00',
|
||||||
'visitsCount' => 0,
|
'visitsCount' => 0,
|
||||||
'tags' => [],
|
'tags' => [],
|
||||||
'meta' => [
|
'meta' => [
|
||||||
|
@ -78,7 +78,7 @@ class ListShortUrlsTest extends ApiTestCase
|
||||||
'longUrl' =>
|
'longUrl' =>
|
||||||
'https://blog.alejandrocelaya.com/2019/04/27'
|
'https://blog.alejandrocelaya.com/2019/04/27'
|
||||||
. '/considerations-to-properly-use-open-source-software-projects/',
|
. '/considerations-to-properly-use-open-source-software-projects/',
|
||||||
'dateCreated' => '2019-01-01T00:00:00+00:00',
|
'dateCreated' => '2019-01-01T00:00:30+00:00',
|
||||||
'visitsCount' => 0,
|
'visitsCount' => 0,
|
||||||
'tags' => [],
|
'tags' => [],
|
||||||
'meta' => [
|
'meta' => [
|
||||||
|
|
|
@ -22,32 +22,32 @@ class ShortUrlsFixture extends AbstractFixture
|
||||||
{
|
{
|
||||||
$abcShortUrl = $this->setShortUrlDate(
|
$abcShortUrl = $this->setShortUrlDate(
|
||||||
new ShortUrl('https://shlink.io', ShortUrlMeta::createFromRawData(['customSlug' => 'abc123'])),
|
new ShortUrl('https://shlink.io', ShortUrlMeta::createFromRawData(['customSlug' => 'abc123'])),
|
||||||
Chronos::parse('2018-05-01')
|
'2018-05-01'
|
||||||
);
|
);
|
||||||
$manager->persist($abcShortUrl);
|
$manager->persist($abcShortUrl);
|
||||||
|
|
||||||
$defShortUrl = $this->setShortUrlDate(new ShortUrl(
|
$defShortUrl = $this->setShortUrlDate(new ShortUrl(
|
||||||
'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/',
|
||||||
ShortUrlMeta::createFromParams(Chronos::parse('2020-05-01'), null, 'def456')
|
ShortUrlMeta::createFromParams(Chronos::parse('2020-05-01'), null, 'def456')
|
||||||
));
|
), '2019-01-01 00:00:10');
|
||||||
$manager->persist($defShortUrl);
|
$manager->persist($defShortUrl);
|
||||||
|
|
||||||
$customShortUrl = $this->setShortUrlDate(new ShortUrl(
|
$customShortUrl = $this->setShortUrlDate(new ShortUrl(
|
||||||
'https://shlink.io',
|
'https://shlink.io',
|
||||||
ShortUrlMeta::createFromParams(null, null, 'custom', 2)
|
ShortUrlMeta::createFromParams(null, null, 'custom', 2)
|
||||||
));
|
), '2019-01-01 00:00:20');
|
||||||
$manager->persist($customShortUrl);
|
$manager->persist($customShortUrl);
|
||||||
|
|
||||||
$withDomainShortUrl = $this->setShortUrlDate(new ShortUrl(
|
$withDomainShortUrl = $this->setShortUrlDate(new ShortUrl(
|
||||||
'https://blog.alejandrocelaya.com/2019/04/27/considerations-to-properly-use-open-source-software-projects/',
|
'https://blog.alejandrocelaya.com/2019/04/27/considerations-to-properly-use-open-source-software-projects/',
|
||||||
ShortUrlMeta::createFromRawData(['domain' => 'example.com', 'customSlug' => 'ghi789'])
|
ShortUrlMeta::createFromRawData(['domain' => 'example.com', 'customSlug' => 'ghi789'])
|
||||||
));
|
), '2019-01-01 00:00:30');
|
||||||
$manager->persist($withDomainShortUrl);
|
$manager->persist($withDomainShortUrl);
|
||||||
|
|
||||||
$withDomainAndSlugShortUrl = $this->setShortUrlDate(new ShortUrl(
|
$withDomainAndSlugShortUrl = $this->setShortUrlDate(new ShortUrl(
|
||||||
'https://google.com',
|
'https://google.com',
|
||||||
ShortUrlMeta::createFromRawData(['domain' => 'some-domain.com', 'customSlug' => 'custom-with-domain'])
|
ShortUrlMeta::createFromRawData(['domain' => 'some-domain.com', 'customSlug' => 'custom-with-domain'])
|
||||||
), Chronos::parse('2018-10-20'));
|
), '2018-10-20');
|
||||||
$manager->persist($withDomainAndSlugShortUrl);
|
$manager->persist($withDomainAndSlugShortUrl);
|
||||||
|
|
||||||
$manager->flush();
|
$manager->flush();
|
||||||
|
@ -56,12 +56,12 @@ class ShortUrlsFixture extends AbstractFixture
|
||||||
$this->addReference('def456_short_url', $defShortUrl);
|
$this->addReference('def456_short_url', $defShortUrl);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function setShortUrlDate(ShortUrl $shortUrl, ?Chronos $date = null): ShortUrl
|
private function setShortUrlDate(ShortUrl $shortUrl, string $date): ShortUrl
|
||||||
{
|
{
|
||||||
$ref = new ReflectionObject($shortUrl);
|
$ref = new ReflectionObject($shortUrl);
|
||||||
$dateProp = $ref->getProperty('dateCreated');
|
$dateProp = $ref->getProperty('dateCreated');
|
||||||
$dateProp->setAccessible(true);
|
$dateProp->setAccessible(true);
|
||||||
$dateProp->setValue($shortUrl, $date ?? Chronos::parse('2019-01-01'));
|
$dateProp->setValue($shortUrl, Chronos::parse($date));
|
||||||
|
|
||||||
return $shortUrl;
|
return $shortUrl;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue