Skip to content

Commit 28d1169

Browse files
committed
[DoctrineBridge] fix and replace namespace to Uid
1 parent 28129c8 commit 28d1169

File tree

9 files changed

+156
-4
lines changed

9 files changed

+156
-4
lines changed

src/Symfony/Bridge/Doctrine/Id/UlidGenerator.php renamed to src/Symfony/Bridge/Doctrine/IdGenerator/UlidGenerator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
* file that was distributed with this source code.
1010
*/
1111

12-
namespace Symfony\Bridge\Doctrine\Types;
12+
namespace Symfony\Bridge\Doctrine\IdGenerator;
1313

1414
use Doctrine\ORM\EntityManager;
1515
use Doctrine\ORM\Id\AbstractIdGenerator;

src/Symfony/Bridge/Doctrine/Id/UuidV1Generator.php renamed to src/Symfony/Bridge/Doctrine/IdGenerator/UuidV1Generator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
* file that was distributed with this source code.
1010
*/
1111

12-
namespace Symfony\Bridge\Doctrine\Types;
12+
namespace Symfony\Bridge\Doctrine\IdGenerator;
1313

1414
use Doctrine\ORM\EntityManager;
1515
use Doctrine\ORM\Id\AbstractIdGenerator;

src/Symfony/Bridge/Doctrine/Id/UuidV4Generator.php renamed to src/Symfony/Bridge/Doctrine/IdGenerator/UuidV4Generator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
* file that was distributed with this source code.
1010
*/
1111

12-
namespace Symfony\Bridge\Doctrine\Types;
12+
namespace Symfony\Bridge\Doctrine\IdGenerator;
1313

1414
use Doctrine\ORM\EntityManager;
1515
use Doctrine\ORM\Id\AbstractIdGenerator;

src/Symfony/Bridge/Doctrine/Id/UuidV6Generator.php renamed to src/Symfony/Bridge/Doctrine/IdGenerator/UuidV6Generator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
* file that was distributed with this source code.
1010
*/
1111

12-
namespace Symfony\Bridge\Doctrine\Types;
12+
namespace Symfony\Bridge\Doctrine\IdGenerator;
1313

1414
use Doctrine\ORM\EntityManager;
1515
use Doctrine\ORM\Id\AbstractIdGenerator;
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <[email protected]>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Bridge\Doctrine\Tests\IdGenerator;
13+
14+
use Doctrine\ORM\EntityManager as DoctrineEntityManager;
15+
16+
class EntityManager extends DoctrineEntityManager
17+
{
18+
public function __construct()
19+
{
20+
}
21+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <[email protected]>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Bridge\Doctrine\Tests\IdGenerator;
13+
14+
use Doctrine\ORM\Mapping\Entity;
15+
use PHPUnit\Framework\TestCase;
16+
use Symfony\Bridge\Doctrine\IdGenerator\UlidGenerator;
17+
use Symfony\Component\Uid\AbstractUid;
18+
use Symfony\Component\Uid\Ulid;
19+
20+
class UlidGeneratorTest extends TestCase
21+
{
22+
public function testUlidCanBeGenerated()
23+
{
24+
$em = new EntityManager();
25+
$generator = new UlidGenerator();
26+
$ulid = $generator->generate($em, new Entity());
27+
28+
$this->assertInstanceOf(AbstractUid::class, $ulid);
29+
$this->assertInstanceOf(Ulid::class, $ulid);
30+
$this->assertTrue(Ulid::isValid($ulid));
31+
}
32+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <[email protected]>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Bridge\Doctrine\Tests\IdGenerator;
13+
14+
use Doctrine\ORM\Mapping\Entity;
15+
use PHPUnit\Framework\TestCase;
16+
use Symfony\Bridge\Doctrine\IdGenerator\UuidV1Generator;
17+
use Symfony\Component\Uid\AbstractUid;
18+
use Symfony\Component\Uid\UuidV1;
19+
20+
class UuidV1GeneratorTest extends TestCase
21+
{
22+
public function testUuidv1CanBeGenerated()
23+
{
24+
$em = new EntityManager();
25+
$generator = new UuidV1Generator();
26+
27+
$uuid = $generator->generate($em, new Entity());
28+
29+
$this->assertInstanceOf(AbstractUid::class, $uuid);
30+
$this->assertInstanceOf(UuidV1::class, $uuid);
31+
$this->assertTrue(UuidV1::isValid($uuid));
32+
}
33+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <[email protected]>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Bridge\Doctrine\Tests\IdGenerator;
13+
14+
use Doctrine\ORM\Mapping\Entity;
15+
use PHPUnit\Framework\TestCase;
16+
use Symfony\Bridge\Doctrine\IdGenerator\UuidV4Generator;
17+
use Symfony\Component\Uid\AbstractUid;
18+
use Symfony\Component\Uid\UuidV4;
19+
20+
class UuidV4GeneratorTest extends TestCase
21+
{
22+
public function testUuidv4CanBeGenerated()
23+
{
24+
$em = new EntityManager();
25+
$generator = new UuidV4Generator();
26+
27+
$uuid = $generator->generate($em, new Entity());
28+
29+
$this->assertInstanceOf(AbstractUid::class, $uuid);
30+
$this->assertInstanceOf(UuidV4::class, $uuid);
31+
$this->assertTrue(UuidV4::isValid($uuid));
32+
}
33+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <[email protected]>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Bridge\Doctrine\Tests\IdGenerator;
13+
14+
use Doctrine\ORM\Mapping\Entity;
15+
use PHPUnit\Framework\TestCase;
16+
use Symfony\Bridge\Doctrine\IdGenerator\UuidV6Generator;
17+
use Symfony\Component\Uid\AbstractUid;
18+
use Symfony\Component\Uid\UuidV6;
19+
20+
class UuidV6GeneratorTest extends TestCase
21+
{
22+
public function testUuidv6CanBeGenerated()
23+
{
24+
$em = new EntityManager();
25+
$generator = new UuidV6Generator();
26+
27+
$uuid = $generator->generate($em, new Entity());
28+
29+
$this->assertInstanceOf(AbstractUid::class, $uuid);
30+
$this->assertInstanceOf(UuidV6::class, $uuid);
31+
$this->assertTrue(UuidV6::isValid($uuid));
32+
}
33+
}

0 commit comments

Comments
 (0)