Skip to content

Commit

Permalink
chore: add test to check if big int datatype messes with the proxy
Browse files Browse the repository at this point in the history
  • Loading branch information
KDederichs committed Dec 17, 2024
1 parent 1db5ced commit 7d6e3df
Show file tree
Hide file tree
Showing 3 changed files with 93 additions and 0 deletions.
40 changes: 40 additions & 0 deletions tests/Fixture/Entity/BigIntEntity.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?php

namespace Zenstruck\Foundry\Tests\Fixture\Entity;

use Doctrine\ORM\Mapping as ORM;
use Zenstruck\Foundry\Tests\Fixture\Model\Base;

#[ORM\Entity]
class BigIntEntity extends Base
{

#[ORM\Id]
#[ORM\Column]
public ?int $id = 1;

#[ORM\Column(type: 'bigint', nullable: false, options: ['default' => "0"])]
private ?string $bigIntVal = '0';

public function getBigIntVal(): ?string
{
return $this->bigIntVal;
}

public function setBigIntVal(?string $bigIntVal): BigIntEntity
{
$this->bigIntVal = $bigIntVal;
return $this;
}

public function getId(): ?int
{
return $this->id;
}

public function setId(?int $id): BigIntEntity
{
$this->id = $id;
return $this;
}
}
34 changes: 34 additions & 0 deletions tests/Fixture/Factories/BigIntProxyFactory.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?php

/*
* This file is part of the zenstruck/foundry package.
*
* (c) Kevin Bond <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Zenstruck\Foundry\Tests\Fixture\Factories;

use Zenstruck\Foundry\Tests\Fixture\Entity\BigIntEntity;
use Zenstruck\Foundry\Persistence\PersistentProxyObjectFactory;

/**
* @author Kevin Bond <[email protected]>
*
* @extends PersistentProxyObjectFactory<BigIntEntity>
*/
final class BigIntProxyFactory extends PersistentProxyObjectFactory
{
protected function defaults(): array
{
return [
];
}

public static function class(): string
{
return BigIntEntity::class;
}
}
19 changes: 19 additions & 0 deletions tests/Integration/ORM/BigIntProxyTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php

namespace Integration\ORM;

use Zenstruck\Foundry\Tests\Fixture\Factories\BigIntProxyFactory;
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
use Zenstruck\Foundry\Test\Factories;
use Zenstruck\Foundry\Tests\Integration\RequiresORM;

final class BigIntProxyTest extends KernelTestCase
{
use Factories, RequiresORM;

public function testItDoesNotChangeTheEntity(): void
{
$entity = BigIntProxyFactory::createOne();
self::assertEquals(1, $entity->getId());
}
}

0 comments on commit 7d6e3df

Please sign in to comment.