|
@@ -2,18 +2,17 @@
|
|
|
|
|
|
|
|
declare(strict_types=1);
|
|
declare(strict_types=1);
|
|
|
|
|
|
|
|
-namespace App\Tests\Doctrine\Core;
|
|
|
|
|
|
|
+namespace App\Tests\Unit\Doctrine\Core;
|
|
|
|
|
|
|
|
use App\Doctrine\Core\AllowedAddressPostalExtension;
|
|
use App\Doctrine\Core\AllowedAddressPostalExtension;
|
|
|
use App\Entity\Access\Access;
|
|
use App\Entity\Access\Access;
|
|
|
use App\Entity\Core\AddressPostal;
|
|
use App\Entity\Core\AddressPostal;
|
|
|
-use App\Tests\Unit\DoctrineExtension\AbstractExtensionTest;
|
|
|
|
|
-use Doctrine\ORM\QueryBuilder;
|
|
|
|
|
|
|
+use App\Tests\Unit\Doctrine\ExtensionTestCase;
|
|
|
use Symfony\Component\Security\Core\User\UserInterface;
|
|
use Symfony\Component\Security\Core\User\UserInterface;
|
|
|
|
|
|
|
|
-class AllowedAddressPostalExtensionTest extends AbstractExtensionTest
|
|
|
|
|
|
|
+class AllowedAddressPostalExtensionTest extends ExtensionTestCase
|
|
|
{
|
|
{
|
|
|
- private $extension;
|
|
|
|
|
|
|
+ private AllowedAddressPostalExtension $extension;
|
|
|
|
|
|
|
|
protected function setUp(): void
|
|
protected function setUp(): void
|
|
|
{
|
|
{
|
|
@@ -21,12 +20,12 @@ class AllowedAddressPostalExtensionTest extends AbstractExtensionTest
|
|
|
$this->extension = new AllowedAddressPostalExtension($this->security);
|
|
$this->extension = new AllowedAddressPostalExtension($this->security);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- public function testSupportsReturnsTrueForAddressPostalClass()
|
|
|
|
|
|
|
+ public function testSupportsReturnsTrueForAddressPostalClass(): void
|
|
|
{
|
|
{
|
|
|
$this->assertTrue($this->extension->supports(AddressPostal::class, null));
|
|
$this->assertTrue($this->extension->supports(AddressPostal::class, null));
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- public function testSupportsReturnsFalseForOtherClasses()
|
|
|
|
|
|
|
+ public function testSupportsReturnsFalseForOtherClasses(): void
|
|
|
{
|
|
{
|
|
|
$classes = ['OtherClass', UserInterface::class, Access::class];
|
|
$classes = ['OtherClass', UserInterface::class, Access::class];
|
|
|
|
|
|
|
@@ -35,7 +34,7 @@ class AllowedAddressPostalExtensionTest extends AbstractExtensionTest
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- public function testAddWhere()
|
|
|
|
|
|
|
+ public function testAddWhere(): void
|
|
|
{
|
|
{
|
|
|
$this->user->method('getOrganization')->willReturn($this->organization);
|
|
$this->user->method('getOrganization')->willReturn($this->organization);
|
|
|
$this->security->method('getUser')->willReturn($this->user);
|
|
$this->security->method('getUser')->willReturn($this->user);
|
|
@@ -59,7 +58,7 @@ class AllowedAddressPostalExtensionTest extends AbstractExtensionTest
|
|
|
$this->invokeAddWhere($this->extension, $this->queryBuilder, AddressPostal::class, null);
|
|
$this->invokeAddWhere($this->extension, $this->queryBuilder, AddressPostal::class, null);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- public function testAddWhereWithNullUser()
|
|
|
|
|
|
|
+ public function testAddWhereWithNullUser(): void
|
|
|
{
|
|
{
|
|
|
$this->security->method('getUser')->willReturn(null);
|
|
$this->security->method('getUser')->willReturn(null);
|
|
|
|
|
|
|
@@ -76,7 +75,7 @@ class AllowedAddressPostalExtensionTest extends AbstractExtensionTest
|
|
|
$this->invokeAddWhere($this->extension, $this->queryBuilder, AddressPostal::class, null);
|
|
$this->invokeAddWhere($this->extension, $this->queryBuilder, AddressPostal::class, null);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- public function testAddWhereWithNullOrganization()
|
|
|
|
|
|
|
+ public function testAddWhereWithNullOrganization(): void
|
|
|
{
|
|
{
|
|
|
$this->user->method('getOrganization')->willReturn(null);
|
|
$this->user->method('getOrganization')->willReturn(null);
|
|
|
$this->security->method('getUser')->willReturn($this->user);
|
|
$this->security->method('getUser')->willReturn($this->user);
|
|
@@ -94,13 +93,16 @@ class AllowedAddressPostalExtensionTest extends AbstractExtensionTest
|
|
|
$this->invokeAddWhere($this->extension, $this->queryBuilder, AddressPostal::class, null);
|
|
$this->invokeAddWhere($this->extension, $this->queryBuilder, AddressPostal::class, null);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- // public function testAddWhereWithNoRootAlias()
|
|
|
|
|
- // {
|
|
|
|
|
- // $this->queryBuilder->method('getRootAliases')->willReturn([]);
|
|
|
|
|
|
|
+ public function testAddWhereWithNoRootAlias(): void
|
|
|
|
|
+ {
|
|
|
|
|
+ $this->user->method('getOrganization')->willReturn($this->organization);
|
|
|
|
|
+ $this->security->method('getUser')->willReturn($this->user);
|
|
|
|
|
|
|
|
- // $this->expectException(\LogicException::class);
|
|
|
|
|
- // $this->expectExceptionMessage('No root alias defined.');
|
|
|
|
|
|
|
+ $this->queryBuilder->method('getRootAliases')->willReturn([]);
|
|
|
|
|
|
|
|
- // $this->invokeAddWhere($this->extension, $this->queryBuilder, AddressPostal::class, null);
|
|
|
|
|
- // }
|
|
|
|
|
|
|
+ $this->expectException(\LogicException::class);
|
|
|
|
|
+ $this->expectExceptionMessage('No root alias defined.');
|
|
|
|
|
+
|
|
|
|
|
+ $this->invokeAddWhere($this->extension, $this->queryBuilder, AddressPostal::class, null);
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|