Created
May 12, 2020 19:39
-
-
Save anvodev/ba781bbb185bd9cd10a8b3746d9c44c5 to your computer and use it in GitHub Desktop.
Test custom ID generator logic
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| //tests/Doctrine/CustomerIdGeneratorTest.php | |
| namespace App\Tests\Doctrine; | |
| use App\Entity\Customer; | |
| use Doctrine\ORM\EntityManagerInterface; | |
| use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase; | |
| class CustomerIdGeneratorTest extends KernelTestCase | |
| { | |
| public function testGenerator() | |
| { | |
| self::bootKernel(); | |
| $customer = new Customer(); | |
| /** @var EntityManagerInterface $em */ | |
| $em = self::$container->get(EntityManagerInterface::class); | |
| $em->persist($customer); | |
| $this->assertRegExp('/[2-8][0-9]{5}/', $customer->getId()); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment