|
|
@@ -8,7 +8,10 @@ use App\Entity\Billing\ResidenceArea;
|
|
|
use App\Entity\Education\EducationTiming;
|
|
|
use App\Entity\Organization\Organization;
|
|
|
use App\Service\Utils\EntityUtils;
|
|
|
+use Doctrine\ORM\EntityManagerInterface;
|
|
|
+use PHPUnit\Framework\MockObject\MockObject;
|
|
|
use PHPUnit\Framework\TestCase;
|
|
|
+use Symfony\Component\Mercure\HubInterface;
|
|
|
|
|
|
class TestableEntityUtils extends EntityUtils
|
|
|
{
|
|
|
@@ -25,14 +28,26 @@ class TestableEntityUtils extends EntityUtils
|
|
|
|
|
|
class EntityUtilsTest extends TestCase
|
|
|
{
|
|
|
+ private EntityManagerInterface $entityManager;
|
|
|
+
|
|
|
+ public function setUp(): void {
|
|
|
+ $this->entityManager = $this->getMockBuilder(EntityManagerInterface::class)->disableOriginalConstructor()->getMock();
|
|
|
+ }
|
|
|
+
|
|
|
+ protected function getEntityUtilsMockFor(string $method): MockObject | TestableEntityUtils
|
|
|
+ {
|
|
|
+ return $this->getMockBuilder(TestableEntityUtils::class)
|
|
|
+ ->setConstructorArgs([$this->entityManager])
|
|
|
+ ->setMethodsExcept([$method])
|
|
|
+ ->getMock();
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* @see EntityUtils::defaultValueSettersByAccess()
|
|
|
*/
|
|
|
public function testDefaultValueSettersByAccess(): void
|
|
|
{
|
|
|
- $utils = $this->getMockBuilder(TestableEntityUtils::class)
|
|
|
- ->setMethodsExcept(['defaultValueSettersByAccess'])
|
|
|
- ->getMock();
|
|
|
+ $utils = $this->getEntityUtilsMockFor('defaultValueSettersByAccess');
|
|
|
|
|
|
$entity = $this->getMockBuilder(Organization::class)->getMock();
|
|
|
$access = $this->getMockBuilder(Access::class)->getMock();
|
|
|
@@ -48,9 +63,7 @@ class EntityUtilsTest extends TestCase
|
|
|
*/
|
|
|
public function testOrganizationDefaultValue(): void
|
|
|
{
|
|
|
- $utils = $this->getMockBuilder(TestableEntityUtils::class)
|
|
|
- ->setMethodsExcept(['organizationDefaultValue'])
|
|
|
- ->getMock();
|
|
|
+ $utils = $this->getEntityUtilsMockFor('organizationDefaultValue');
|
|
|
|
|
|
$organization = $this->getMockBuilder(Organization::class)->getMock();
|
|
|
|
|
|
@@ -69,9 +82,7 @@ class EntityUtilsTest extends TestCase
|
|
|
*/
|
|
|
public function testBillingSettingDefaultValueDefaultValue(): void
|
|
|
{
|
|
|
- $utils = $this->getMockBuilder(TestableEntityUtils::class)
|
|
|
- ->setMethodsExcept(['billingSettingDefaultValueDefaultValue'])
|
|
|
- ->getMock();
|
|
|
+ $utils = $this->getEntityUtilsMockFor('billingSettingDefaultValueDefaultValue');
|
|
|
|
|
|
$entity = new ResidenceArea(); // Can't test this method with a mocked entity...
|
|
|
|