Wrap JSON serialization for any kind of visit in Visit entity itself

This commit is contained in:
Alejandro Celaya
2024-03-24 17:06:11 +01:00
parent a327e6c0a7
commit d948543d5c
9 changed files with 71 additions and 135 deletions

View File

@@ -11,7 +11,6 @@ use PHPUnit\Framework\Attributes\Test;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;
use Shlinkio\Shlink\Common\Paginator\Paginator;
use Shlinkio\Shlink\Common\Rest\DataTransformerInterface;
use Shlinkio\Shlink\Core\Exception\ValidationException;
use Shlinkio\Shlink\Core\Visit\Entity\Visit;
use Shlinkio\Shlink\Core\Visit\Model\OrphanVisitsParams;
@@ -26,14 +25,11 @@ class OrphanVisitsActionTest extends TestCase
{
private OrphanVisitsAction $action;
private MockObject & VisitsStatsHelperInterface $visitsHelper;
private MockObject & DataTransformerInterface $orphanVisitTransformer;
protected function setUp(): void
{
$this->visitsHelper = $this->createMock(VisitsStatsHelperInterface::class);
$this->orphanVisitTransformer = $this->createMock(DataTransformerInterface::class);
$this->action = new OrphanVisitsAction($this->visitsHelper, $this->orphanVisitTransformer);
$this->action = new OrphanVisitsAction($this->visitsHelper);
}
#[Test]
@@ -45,9 +41,6 @@ class OrphanVisitsActionTest extends TestCase
$this->isInstanceOf(OrphanVisitsParams::class),
)->willReturn(new Paginator(new ArrayAdapter($visits)));
$visitsAmount = count($visits);
$this->orphanVisitTransformer->expects($this->exactly($visitsAmount))->method('transform')->with(
$this->isInstanceOf(Visit::class),
)->willReturn([]);
/** @var JsonResponse $response */
$response = $this->action->handle(