mirror of
https://github.com/shlinkio/shlink.git
synced 2024-11-28 09:03:07 +03:00
Merge pull request #553 from acelaya-forks/feature/doctrine-2.7
Updated to latest doctrine versions, solving deprecations
This commit is contained in:
commit
a7d308c585
10 changed files with 30 additions and 38 deletions
|
@ -19,10 +19,10 @@
|
|||
"akrabat/ip-address-middleware": "^1.0",
|
||||
"cakephp/chronos": "^1.2",
|
||||
"cocur/slugify": "^3.0",
|
||||
"doctrine/cache": "^1.6",
|
||||
"doctrine/dbal": "^2.9",
|
||||
"doctrine/migrations": "^2.0",
|
||||
"doctrine/orm": "^2.5",
|
||||
"doctrine/cache": "^1.9",
|
||||
"doctrine/dbal": "^2.10",
|
||||
"doctrine/migrations": "^2.2",
|
||||
"doctrine/orm": "^2.7",
|
||||
"endroid/qr-code": "^3.6",
|
||||
"firebase/php-jwt": "^4.0",
|
||||
"geoip2/geoip2": "^2.9",
|
||||
|
|
|
@ -82,6 +82,6 @@ class LocateShortUrlVisit
|
|||
}
|
||||
|
||||
$visit->locate(new VisitLocation($location));
|
||||
$this->em->flush($visit);
|
||||
$this->em->flush();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -64,9 +64,7 @@ class ShortUrlService implements ShortUrlServiceInterface
|
|||
$shortUrl = $this->findByShortCode($this->em, $shortCode);
|
||||
$shortUrl->updateMeta($shortUrlMeta);
|
||||
|
||||
/** @var ORM\EntityManager $em */
|
||||
$em = $this->em;
|
||||
$em->flush($shortUrl);
|
||||
$this->em->flush();
|
||||
|
||||
return $shortUrl;
|
||||
}
|
||||
|
|
|
@ -77,9 +77,7 @@ class TagService implements TagServiceInterface
|
|||
|
||||
$tag->rename($newName);
|
||||
|
||||
/** @var ORM\EntityManager $em */
|
||||
$em = $this->em;
|
||||
$em->flush($tag);
|
||||
$this->em->flush();
|
||||
|
||||
return $tag;
|
||||
}
|
||||
|
|
|
@ -43,10 +43,8 @@ class VisitsTracker implements VisitsTrackerInterface
|
|||
|
||||
$visit = new Visit($shortUrl, $visitor);
|
||||
|
||||
/** @var ORM\EntityManager $em */
|
||||
$em = $this->em;
|
||||
$em->persist($visit);
|
||||
$em->flush($visit);
|
||||
$this->em->persist($visit);
|
||||
$this->em->flush();
|
||||
|
||||
$this->eventDispatcher->dispatch(new ShortUrlVisited($visit->getId()));
|
||||
}
|
||||
|
|
|
@ -61,7 +61,7 @@ class LocateShortUrlVisitTest extends TestCase
|
|||
($this->locateVisit)($event);
|
||||
|
||||
$findVisit->shouldHaveBeenCalledOnce();
|
||||
$this->em->flush(Argument::cetera())->shouldNotHaveBeenCalled();
|
||||
$this->em->flush()->shouldNotHaveBeenCalled();
|
||||
$this->ipLocationResolver->resolveIpLocation(Argument::cetera())->shouldNotHaveBeenCalled();
|
||||
$logWarning->shouldHaveBeenCalled();
|
||||
}
|
||||
|
@ -86,7 +86,7 @@ class LocateShortUrlVisitTest extends TestCase
|
|||
$findVisit->shouldHaveBeenCalledOnce();
|
||||
$resolveLocation->shouldHaveBeenCalledOnce();
|
||||
$logWarning->shouldHaveBeenCalled();
|
||||
$this->em->flush(Argument::cetera())->shouldNotHaveBeenCalled();
|
||||
$this->em->flush()->shouldNotHaveBeenCalled();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -97,7 +97,7 @@ class LocateShortUrlVisitTest extends TestCase
|
|||
{
|
||||
$event = new ShortUrlVisited('123');
|
||||
$findVisit = $this->em->find(Visit::class, '123')->willReturn($visit);
|
||||
$flush = $this->em->flush($visit)->will(function () {
|
||||
$flush = $this->em->flush()->will(function () {
|
||||
});
|
||||
$resolveIp = $this->ipLocationResolver->resolveIpLocation(Argument::any());
|
||||
|
||||
|
@ -128,7 +128,7 @@ class LocateShortUrlVisitTest extends TestCase
|
|||
$event = new ShortUrlVisited('123');
|
||||
|
||||
$findVisit = $this->em->find(Visit::class, '123')->willReturn($visit);
|
||||
$flush = $this->em->flush($visit)->will(function () {
|
||||
$flush = $this->em->flush()->will(function () {
|
||||
});
|
||||
$resolveIp = $this->ipLocationResolver->resolveIpLocation($ipAddr)->willReturn($location);
|
||||
|
||||
|
@ -151,7 +151,7 @@ class LocateShortUrlVisitTest extends TestCase
|
|||
$event = new ShortUrlVisited('123');
|
||||
|
||||
$findVisit = $this->em->find(Visit::class, '123')->willReturn($visit);
|
||||
$flush = $this->em->flush($visit)->will(function () {
|
||||
$flush = $this->em->flush()->will(function () {
|
||||
});
|
||||
$resolveIp = $this->ipLocationResolver->resolveIpLocation($ipAddr)->willReturn($location);
|
||||
$checkUpdateDb = $this->dbUpdater->checkDbUpdate(Argument::cetera())->willThrow($e);
|
||||
|
@ -179,7 +179,7 @@ class LocateShortUrlVisitTest extends TestCase
|
|||
$event = new ShortUrlVisited('123');
|
||||
|
||||
$findVisit = $this->em->find(Visit::class, '123')->willReturn($visit);
|
||||
$flush = $this->em->flush($visit)->will(function () {
|
||||
$flush = $this->em->flush()->will(function () {
|
||||
});
|
||||
$resolveIp = $this->ipLocationResolver->resolveIpLocation($ipAddr)->willReturn($location);
|
||||
$checkUpdateDb = $this->dbUpdater->checkDbUpdate(Argument::cetera())->willThrow($e);
|
||||
|
|
|
@ -35,7 +35,7 @@ class ShortUrlServiceTest extends TestCase
|
|||
}
|
||||
|
||||
/** @test */
|
||||
public function listedUrlsAreReturnedFromEntityManager()
|
||||
public function listedUrlsAreReturnedFromEntityManager(): void
|
||||
{
|
||||
$list = [
|
||||
new ShortUrl(''),
|
||||
|
@ -54,7 +54,7 @@ class ShortUrlServiceTest extends TestCase
|
|||
}
|
||||
|
||||
/** @test */
|
||||
public function exceptionIsThrownWhenSettingTagsOnInvalidShortcode()
|
||||
public function exceptionIsThrownWhenSettingTagsOnInvalidShortcode(): void
|
||||
{
|
||||
$shortCode = 'abc123';
|
||||
$repo = $this->prophesize(ShortUrlRepository::class);
|
||||
|
@ -67,7 +67,7 @@ class ShortUrlServiceTest extends TestCase
|
|||
}
|
||||
|
||||
/** @test */
|
||||
public function providedTagsAreGetFromRepoAndSetToTheShortUrl()
|
||||
public function providedTagsAreGetFromRepoAndSetToTheShortUrl(): void
|
||||
{
|
||||
$shortUrl = $this->prophesize(ShortUrl::class);
|
||||
$shortUrl->setTags(Argument::any())->shouldBeCalledOnce();
|
||||
|
@ -86,14 +86,14 @@ class ShortUrlServiceTest extends TestCase
|
|||
}
|
||||
|
||||
/** @test */
|
||||
public function updateMetadataByShortCodeUpdatesProvidedData()
|
||||
public function updateMetadataByShortCodeUpdatesProvidedData(): void
|
||||
{
|
||||
$shortUrl = new ShortUrl('');
|
||||
|
||||
$repo = $this->prophesize(ShortUrlRepository::class);
|
||||
$findShortUrl = $repo->findOneBy(['shortCode' => 'abc123'])->willReturn($shortUrl);
|
||||
$getRepo = $this->em->getRepository(ShortUrl::class)->willReturn($repo->reveal());
|
||||
$flush = $this->em->flush($shortUrl)->willReturn(null);
|
||||
$flush = $this->em->flush()->willReturn(null);
|
||||
|
||||
$result = $this->service->updateMetadataByShortCode('abc123', ShortUrlMeta::createFromParams(
|
||||
Chronos::parse('2017-01-01 00:00:00')->toAtomString(),
|
||||
|
|
|
@ -28,7 +28,7 @@ class TagServiceTest extends TestCase
|
|||
}
|
||||
|
||||
/** @test */
|
||||
public function listTagsDelegatesOnRepository()
|
||||
public function listTagsDelegatesOnRepository(): void
|
||||
{
|
||||
$expected = [new Tag('foo'), new Tag('bar')];
|
||||
|
||||
|
@ -44,7 +44,7 @@ class TagServiceTest extends TestCase
|
|||
}
|
||||
|
||||
/** @test */
|
||||
public function deleteTagsDelegatesOnRepository()
|
||||
public function deleteTagsDelegatesOnRepository(): void
|
||||
{
|
||||
$repo = $this->prophesize(TagRepository::class);
|
||||
$delete = $repo->deleteByName(['foo', 'bar'])->willReturn(4);
|
||||
|
@ -57,7 +57,7 @@ class TagServiceTest extends TestCase
|
|||
}
|
||||
|
||||
/** @test */
|
||||
public function createTagsPersistsEntities()
|
||||
public function createTagsPersistsEntities(): void
|
||||
{
|
||||
$repo = $this->prophesize(TagRepository::class);
|
||||
$find = $repo->findOneBy(Argument::cetera())->willReturn(new Tag('foo'));
|
||||
|
@ -75,7 +75,7 @@ class TagServiceTest extends TestCase
|
|||
}
|
||||
|
||||
/** @test */
|
||||
public function renameInvalidTagThrowsException()
|
||||
public function renameInvalidTagThrowsException(): void
|
||||
{
|
||||
$repo = $this->prophesize(TagRepository::class);
|
||||
$find = $repo->findOneBy(Argument::cetera())->willReturn(null);
|
||||
|
@ -89,14 +89,14 @@ class TagServiceTest extends TestCase
|
|||
}
|
||||
|
||||
/** @test */
|
||||
public function renameValidTagChangesItsName()
|
||||
public function renameValidTagChangesItsName(): void
|
||||
{
|
||||
$expected = new Tag('foo');
|
||||
|
||||
$repo = $this->prophesize(TagRepository::class);
|
||||
$find = $repo->findOneBy(Argument::cetera())->willReturn($expected);
|
||||
$getRepo = $this->em->getRepository(Tag::class)->willReturn($repo->reveal());
|
||||
$flush = $this->em->flush($expected)->willReturn(null);
|
||||
$flush = $this->em->flush()->willReturn(null);
|
||||
|
||||
$tag = $this->service->renameTag('foo', 'bar');
|
||||
|
||||
|
|
|
@ -46,11 +46,11 @@ class VisitsTrackerTest extends TestCase
|
|||
$repo->findOneBy(['shortCode' => $shortCode])->willReturn(new ShortUrl(''));
|
||||
|
||||
$this->em->getRepository(ShortUrl::class)->willReturn($repo->reveal())->shouldBeCalledOnce();
|
||||
$this->em->persist(Argument::any())->shouldBeCalledOnce();
|
||||
$this->em->flush(Argument::that(function (Visit $visit) {
|
||||
$this->em->persist(Argument::that(function (Visit $visit) {
|
||||
$visit->setId('1');
|
||||
return $visit;
|
||||
}))->shouldBeCalledOnce();
|
||||
$this->em->flush()->shouldBeCalledOnce();
|
||||
|
||||
$this->visitsTracker->track($shortCode, Visitor::emptyInstance());
|
||||
|
||||
|
@ -69,11 +69,10 @@ class VisitsTrackerTest extends TestCase
|
|||
/** @var Visit $visit */
|
||||
$visit = $args[0];
|
||||
Assert::assertEquals('4.3.2.0', $visit->getRemoteAddr());
|
||||
})->shouldBeCalledOnce();
|
||||
$this->em->flush(Argument::that(function (Visit $visit) {
|
||||
$visit->setId('1');
|
||||
return $visit;
|
||||
}))->shouldBeCalledOnce();
|
||||
})->shouldBeCalledOnce();
|
||||
$this->em->flush()->shouldBeCalledOnce();
|
||||
|
||||
$this->visitsTracker->track($shortCode, new Visitor('', '', '4.3.2.1'));
|
||||
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
parameters:
|
||||
ignoreErrors:
|
||||
- '#is not subtype of Throwable#'
|
||||
- '#ObjectManager::flush()#'
|
||||
- '#Undefined variable: \$metadata#'
|
||||
- '#AbstractQuery::setParameters()#'
|
||||
- '#mustRun()#'
|
||||
|
|
Loading…
Reference in a new issue