|
@@ -6,65 +6,35 @@ use App\Entity\Organization\Organization;
|
|
|
use App\Enum\Cotisation\AlertStateEnum;
|
|
use App\Enum\Cotisation\AlertStateEnum;
|
|
|
use App\Repository\Cotisation\CotisationApiResourcesRepository;
|
|
use App\Repository\Cotisation\CotisationApiResourcesRepository;
|
|
|
use App\Repository\Network\NetworkOrganizationRepository;
|
|
use App\Repository\Network\NetworkOrganizationRepository;
|
|
|
-use App\Service\Cotisation\Utils;
|
|
|
|
|
|
|
+use App\Service\Cotisation\Utils as CotisationUtils;
|
|
|
use App\Service\Organization\Utils as OrganizationUtils;
|
|
use App\Service\Organization\Utils as OrganizationUtils;
|
|
|
|
|
+use PHPUnit\Framework\MockObject\MockObject;
|
|
|
use PHPUnit\Framework\TestCase;
|
|
use PHPUnit\Framework\TestCase;
|
|
|
use \App\Service\Network\Utils as NetworkUtils;
|
|
use \App\Service\Network\Utils as NetworkUtils;
|
|
|
|
|
|
|
|
class UtilsTest extends TestCase
|
|
class UtilsTest extends TestCase
|
|
|
{
|
|
{
|
|
|
- const MEMBERSHIP_WAITING = 495; // Affiliation in progress
|
|
|
|
|
- const MEMBERSHIP_NOPAYMENT = 517; // Waiting paiement
|
|
|
|
|
- const SUBMIT_IN_PROGRESS = 540; // Affiliation in progress
|
|
|
|
|
|
|
+ private const MEMBERSHIP_WAITING = 495; // Affiliation in progress
|
|
|
|
|
+ private const MEMBERSHIP_NOPAYMENT = 517; // Waiting paiement
|
|
|
|
|
+ private const SUBMIT_IN_PROGRESS = 540; // Affiliation in progress
|
|
|
|
|
|
|
|
- private NetworkOrganizationRepository $networkOrganizationRepositoryMock;
|
|
|
|
|
- private NetworkUtils $networkUtilsMock;
|
|
|
|
|
- private OrganizationUtils $organizationUtilsMock;
|
|
|
|
|
-
|
|
|
|
|
- public function getOrganizationMock(): Organization{
|
|
|
|
|
- $organizationMock = $this->getMockBuilder(Organization::class)
|
|
|
|
|
- ->disableOriginalConstructor()
|
|
|
|
|
- ->getMock();
|
|
|
|
|
- $organizationMock
|
|
|
|
|
- ->method('getId')
|
|
|
|
|
- ->willReturn(1);
|
|
|
|
|
- return $organizationMock;
|
|
|
|
|
-
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- public function getUtilsInstance(){
|
|
|
|
|
- return new Utils(
|
|
|
|
|
- $this->networkUtilsMock,
|
|
|
|
|
- $this->organizationUtilsMock,
|
|
|
|
|
- $this->networkOrganizationRepositoryMock,
|
|
|
|
|
- $this->cotisationApiResourcesRepositoryMock
|
|
|
|
|
- );
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ private MockObject | NetworkOrganizationRepository $networkOrganizationRepository;
|
|
|
|
|
+ private MockObject | NetworkUtils $networkUtils;
|
|
|
|
|
+ private MockObject | OrganizationUtils $organizationUtils;
|
|
|
|
|
+ private MockObject | CotisationApiResourcesRepository $cotisationApiResourcesRepository;
|
|
|
|
|
|
|
|
public function setUp(): void
|
|
public function setUp(): void
|
|
|
{
|
|
{
|
|
|
- $this->networkOrganizationRepositoryMock =
|
|
|
|
|
- $this
|
|
|
|
|
- ->getMockBuilder(NetworkOrganizationRepository::class)
|
|
|
|
|
|
|
+ $this->networkOrganizationRepository = $this->getMockBuilder(NetworkOrganizationRepository::class)
|
|
|
->disableOriginalConstructor()
|
|
->disableOriginalConstructor()
|
|
|
->getMock();
|
|
->getMock();
|
|
|
|
|
|
|
|
- $this->networkUtilsMock =
|
|
|
|
|
- $this
|
|
|
|
|
- ->getMockBuilder(NetworkUtils::class)
|
|
|
|
|
- ->disableOriginalConstructor()
|
|
|
|
|
- ->getMock();
|
|
|
|
|
-
|
|
|
|
|
- $this->organizationUtilsMock =
|
|
|
|
|
- $this
|
|
|
|
|
- ->getMockBuilder(OrganizationUtils::class)
|
|
|
|
|
- ->getMock();
|
|
|
|
|
|
|
+ $this->networkUtils = $this->getMockBuilder(NetworkUtils::class)->disableOriginalConstructor()->getMock();
|
|
|
|
|
+ $this->organizationUtils = $this->getMockBuilder(OrganizationUtils::class)->getMock();
|
|
|
|
|
|
|
|
- $this->cotisationApiResourcesRepositoryMock =
|
|
|
|
|
- $this
|
|
|
|
|
- ->getMockBuilder(CotisationApiResourcesRepository::class)
|
|
|
|
|
- ->disableOriginalConstructor()
|
|
|
|
|
- ->getMock();
|
|
|
|
|
|
|
+ $this->cotisationApiResourcesRepository = $this->getMockBuilder(CotisationApiResourcesRepository::class)
|
|
|
|
|
+ ->disableOriginalConstructor()
|
|
|
|
|
+ ->getMock();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -72,43 +42,38 @@ class UtilsTest extends TestCase
|
|
|
*/
|
|
*/
|
|
|
public function testIsLastParentAndCMF(): void
|
|
public function testIsLastParentAndCMF(): void
|
|
|
{
|
|
{
|
|
|
- $organizationMock = $this->getOrganizationMock();
|
|
|
|
|
|
|
+ $cotisationUtils = $this->getMockBuilder(CotisationUtils::class)
|
|
|
|
|
+ ->setConstructorArgs([$this->networkUtils, $this->organizationUtils, $this->networkOrganizationRepository, $this->cotisationApiResourcesRepository])
|
|
|
|
|
+ ->setMethodsExcept(['isLastParentAndCMF'])
|
|
|
|
|
+ ->getMock();
|
|
|
|
|
|
|
|
- $this->networkOrganizationRepositoryMock
|
|
|
|
|
- ->expects($this->once())
|
|
|
|
|
- ->method('isLastParent')
|
|
|
|
|
- ->with($organizationMock)
|
|
|
|
|
- ->willReturn(true);
|
|
|
|
|
|
|
+ $organization1 = $this->getMockBuilder(Organization::class)->getMock();
|
|
|
|
|
+ $organization2 = $this->getMockBuilder(Organization::class)->getMock();
|
|
|
|
|
+ $organization3 = $this->getMockBuilder(Organization::class)->getMock();
|
|
|
|
|
+ $organization4 = $this->getMockBuilder(Organization::class)->getMock();
|
|
|
|
|
|
|
|
- $this->networkUtilsMock
|
|
|
|
|
- ->expects($this->once())
|
|
|
|
|
|
|
+ $this->networkOrganizationRepository
|
|
|
|
|
+ ->method('isLastParent')
|
|
|
|
|
+ ->willReturnMap([
|
|
|
|
|
+ [$organization1, true],
|
|
|
|
|
+ [$organization2, true],
|
|
|
|
|
+ [$organization3, false],
|
|
|
|
|
+ [$organization4, false],
|
|
|
|
|
+ ]);
|
|
|
|
|
+
|
|
|
|
|
+ $this->networkUtils
|
|
|
->method('isCMF')
|
|
->method('isCMF')
|
|
|
- ->with($organizationMock)
|
|
|
|
|
- ->willReturn(true);
|
|
|
|
|
-
|
|
|
|
|
- $utils = $this->getUtilsInstance();
|
|
|
|
|
- $this->assertTrue($utils->isLastParentAndCMF($organizationMock));
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- /**
|
|
|
|
|
- * @see Utils::isLastParentAndCMF()
|
|
|
|
|
- */
|
|
|
|
|
- public function testIsNotLastParentAndCMF(): void
|
|
|
|
|
- {
|
|
|
|
|
- $organizationMock = $this->getOrganizationMock();
|
|
|
|
|
-
|
|
|
|
|
- $this->networkOrganizationRepositoryMock
|
|
|
|
|
- ->expects($this->once())
|
|
|
|
|
- ->method('isLastParent')
|
|
|
|
|
- ->with($organizationMock)
|
|
|
|
|
- ->willReturn(false);
|
|
|
|
|
-
|
|
|
|
|
- $this->networkUtilsMock
|
|
|
|
|
- ->expects($this->never())
|
|
|
|
|
- ->method('isCMF');
|
|
|
|
|
-
|
|
|
|
|
- $utils = $this->getUtilsInstance();
|
|
|
|
|
- $this->assertFalse($utils->isLastParentAndCMF($organizationMock));
|
|
|
|
|
|
|
+ ->willReturnMap([
|
|
|
|
|
+ [$organization1, true],
|
|
|
|
|
+ [$organization2, false],
|
|
|
|
|
+ [$organization3, true],
|
|
|
|
|
+ [$organization4, false],
|
|
|
|
|
+ ]);
|
|
|
|
|
+
|
|
|
|
|
+ $this->assertTrue($cotisationUtils->isLastParentAndCMF($organization1));
|
|
|
|
|
+ $this->assertFalse($cotisationUtils->isLastParentAndCMF($organization2));
|
|
|
|
|
+ $this->assertFalse($cotisationUtils->isLastParentAndCMF($organization3));
|
|
|
|
|
+ $this->assertFalse($cotisationUtils->isLastParentAndCMF($organization4));
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -116,43 +81,39 @@ class UtilsTest extends TestCase
|
|
|
*/
|
|
*/
|
|
|
public function testIsStructureAndCMF(): void
|
|
public function testIsStructureAndCMF(): void
|
|
|
{
|
|
{
|
|
|
- $organizationMock = $this->getMockBuilder(Organization::class)->getMock();
|
|
|
|
|
-
|
|
|
|
|
- $this->organizationUtilsMock
|
|
|
|
|
- ->expects($this->once())
|
|
|
|
|
- ->method('isStructure')
|
|
|
|
|
- ->with($organizationMock)
|
|
|
|
|
- ->willReturn(true);
|
|
|
|
|
-
|
|
|
|
|
- $this->networkUtilsMock
|
|
|
|
|
- ->expects($this->once())
|
|
|
|
|
- ->method('isCMF')
|
|
|
|
|
- ->with($organizationMock)
|
|
|
|
|
- ->willReturn(true);
|
|
|
|
|
|
|
+ $cotisationUtils = $this->getMockBuilder(CotisationUtils::class)
|
|
|
|
|
+ ->setConstructorArgs([$this->networkUtils, $this->organizationUtils, $this->networkOrganizationRepository, $this->cotisationApiResourcesRepository])
|
|
|
|
|
+ ->setMethodsExcept(['isStructureAndCMF'])
|
|
|
|
|
+ ->getMock();
|
|
|
|
|
|
|
|
- $utils = $this->getUtilsInstance();
|
|
|
|
|
- $this->assertTrue($utils->isStructureAndCMF($organizationMock));
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ $organization1 = $this->getMockBuilder(Organization::class)->getMock();
|
|
|
|
|
+ $organization2 = $this->getMockBuilder(Organization::class)->getMock();
|
|
|
|
|
+ $organization3 = $this->getMockBuilder(Organization::class)->getMock();
|
|
|
|
|
+ $organization4 = $this->getMockBuilder(Organization::class)->getMock();
|
|
|
|
|
|
|
|
- /**
|
|
|
|
|
- * @see Utils::isStructureAndCMF()
|
|
|
|
|
- */
|
|
|
|
|
- public function testIsNotStructureAndCMF(): void
|
|
|
|
|
- {
|
|
|
|
|
- $organizationMock = $this->getMockBuilder(Organization::class)->getMock();
|
|
|
|
|
-
|
|
|
|
|
- $this->organizationUtilsMock
|
|
|
|
|
- ->expects($this->once())
|
|
|
|
|
|
|
+ $this->organizationUtils
|
|
|
->method('isStructure')
|
|
->method('isStructure')
|
|
|
- ->with($organizationMock)
|
|
|
|
|
- ->willReturn(false);
|
|
|
|
|
-
|
|
|
|
|
- $this->networkUtilsMock
|
|
|
|
|
- ->expects($this->never())
|
|
|
|
|
- ->method('isCMF');
|
|
|
|
|
-
|
|
|
|
|
- $utils = $this->getUtilsInstance();
|
|
|
|
|
- $this->assertFalse($utils->isStructureAndCMF($organizationMock));
|
|
|
|
|
|
|
+ ->willReturnMap([
|
|
|
|
|
+ [$organization1, true],
|
|
|
|
|
+ [$organization2, false],
|
|
|
|
|
+ [$organization3, true],
|
|
|
|
|
+ [$organization4, false],
|
|
|
|
|
+ ]);
|
|
|
|
|
+
|
|
|
|
|
+ $this->networkUtils
|
|
|
|
|
+ ->method('isCMF')
|
|
|
|
|
+ ->with($organization1)
|
|
|
|
|
+ ->willReturnMap([
|
|
|
|
|
+ [$organization1, true],
|
|
|
|
|
+ [$organization2, false],
|
|
|
|
|
+ [$organization3, false],
|
|
|
|
|
+ [$organization4, true],
|
|
|
|
|
+ ]);
|
|
|
|
|
+
|
|
|
|
|
+ $this->assertTrue($cotisationUtils->isStructureAndCMF($organization1));
|
|
|
|
|
+ $this->assertFalse($cotisationUtils->isStructureAndCMF($organization2));
|
|
|
|
|
+ $this->assertFalse($cotisationUtils->isStructureAndCMF($organization3));
|
|
|
|
|
+ $this->assertFalse($cotisationUtils->isStructureAndCMF($organization4));
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -160,43 +121,77 @@ class UtilsTest extends TestCase
|
|
|
*/
|
|
*/
|
|
|
public function testIsManagerAndCMF(): void
|
|
public function testIsManagerAndCMF(): void
|
|
|
{
|
|
{
|
|
|
- $organizationMock = $this->getMockBuilder(Organization::class)->getMock();
|
|
|
|
|
|
|
+ $cotisationUtils = $this->getMockBuilder(CotisationUtils::class)
|
|
|
|
|
+ ->setConstructorArgs([$this->networkUtils, $this->organizationUtils, $this->networkOrganizationRepository, $this->cotisationApiResourcesRepository])
|
|
|
|
|
+ ->setMethodsExcept(['isManagerAndCMF'])
|
|
|
|
|
+ ->getMock();
|
|
|
|
|
|
|
|
- $this->organizationUtilsMock
|
|
|
|
|
- ->expects($this->once())
|
|
|
|
|
- ->method('isManager')
|
|
|
|
|
- ->with($organizationMock)
|
|
|
|
|
- ->willReturn(true);
|
|
|
|
|
|
|
+ $organization1 = $this->getMockBuilder(Organization::class)->getMock();
|
|
|
|
|
+ $organization2 = $this->getMockBuilder(Organization::class)->getMock();
|
|
|
|
|
+ $organization3 = $this->getMockBuilder(Organization::class)->getMock();
|
|
|
|
|
+ $organization4 = $this->getMockBuilder(Organization::class)->getMock();
|
|
|
|
|
|
|
|
- $this->networkUtilsMock
|
|
|
|
|
- ->expects($this->once())
|
|
|
|
|
|
|
+ $this->organizationUtils
|
|
|
|
|
+ ->method('isManager')
|
|
|
|
|
+ ->willReturnMap([
|
|
|
|
|
+ [$organization1, true],
|
|
|
|
|
+ [$organization2, false],
|
|
|
|
|
+ [$organization3, true],
|
|
|
|
|
+ [$organization4, false],
|
|
|
|
|
+ ]);
|
|
|
|
|
+
|
|
|
|
|
+ $this->networkUtils
|
|
|
->method('isCMF')
|
|
->method('isCMF')
|
|
|
- ->with($organizationMock)
|
|
|
|
|
- ->willReturn(true);
|
|
|
|
|
-
|
|
|
|
|
- $utils = $this->getUtilsInstance();
|
|
|
|
|
- $this->assertTrue($utils->isManagerAndCMF($organizationMock));
|
|
|
|
|
|
|
+ ->willReturnMap([
|
|
|
|
|
+ [$organization1, true],
|
|
|
|
|
+ [$organization2, false],
|
|
|
|
|
+ [$organization3, false],
|
|
|
|
|
+ [$organization4, true],
|
|
|
|
|
+ ]);
|
|
|
|
|
+
|
|
|
|
|
+ $this->assertTrue($cotisationUtils->isManagerAndCMF($organization1));
|
|
|
|
|
+ $this->assertFalse($cotisationUtils->isManagerAndCMF($organization2));
|
|
|
|
|
+ $this->assertFalse($cotisationUtils->isManagerAndCMF($organization3));
|
|
|
|
|
+ $this->assertFalse($cotisationUtils->isManagerAndCMF($organization4));
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
- * @see Utils::isManagerAndCMF()
|
|
|
|
|
|
|
+ * @see Utils::isManagerAndNotLastParentAndCMF()
|
|
|
*/
|
|
*/
|
|
|
- public function testIsNotManagerAndCMF(): void
|
|
|
|
|
|
|
+ public function testIsManagerAndLastParentAndCMF(): void
|
|
|
{
|
|
{
|
|
|
- $organizationMock = $this->getMockBuilder(Organization::class)->getMock();
|
|
|
|
|
-
|
|
|
|
|
- $this->organizationUtilsMock
|
|
|
|
|
- ->expects($this->once())
|
|
|
|
|
- ->method('isManager')
|
|
|
|
|
- ->with($organizationMock)
|
|
|
|
|
- ->willReturn(false);
|
|
|
|
|
|
|
+ $cotisationUtils = $this->getMockBuilder(CotisationUtils::class)
|
|
|
|
|
+ ->setConstructorArgs([$this->networkUtils, $this->organizationUtils, $this->networkOrganizationRepository, $this->cotisationApiResourcesRepository])
|
|
|
|
|
+ ->setMethodsExcept(['isManagerAndLastParentAndCMF'])
|
|
|
|
|
+ ->getMock();
|
|
|
|
|
|
|
|
- $this->networkUtilsMock
|
|
|
|
|
- ->expects($this->never())
|
|
|
|
|
- ->method('isCMF');
|
|
|
|
|
|
|
+ $organization1 = $this->getMockBuilder(Organization::class)->getMock();
|
|
|
|
|
+ $organization2 = $this->getMockBuilder(Organization::class)->getMock();
|
|
|
|
|
+ $organization3 = $this->getMockBuilder(Organization::class)->getMock();
|
|
|
|
|
+ $organization4 = $this->getMockBuilder(Organization::class)->getMock();
|
|
|
|
|
|
|
|
- $utils = $this->getUtilsInstance();
|
|
|
|
|
- $this->assertFalse($utils->isManagerAndCMF($organizationMock));
|
|
|
|
|
|
|
+ $this->organizationUtils
|
|
|
|
|
+ ->method('isManager')
|
|
|
|
|
+ ->willReturnMap([
|
|
|
|
|
+ [$organization1, true],
|
|
|
|
|
+ [$organization2, false],
|
|
|
|
|
+ [$organization3, true],
|
|
|
|
|
+ [$organization4, false],
|
|
|
|
|
+ ]);
|
|
|
|
|
+
|
|
|
|
|
+ $cotisationUtils
|
|
|
|
|
+ ->method('isLastParentAndCMF')
|
|
|
|
|
+ ->willReturnMap([
|
|
|
|
|
+ [$organization1, true],
|
|
|
|
|
+ [$organization2, false],
|
|
|
|
|
+ [$organization3, false],
|
|
|
|
|
+ [$organization4, true],
|
|
|
|
|
+ ]);
|
|
|
|
|
+
|
|
|
|
|
+ $this->assertTrue($cotisationUtils->isManagerAndLastParentAndCMF($organization1));
|
|
|
|
|
+ $this->assertFalse($cotisationUtils->isManagerAndLastParentAndCMF($organization2));
|
|
|
|
|
+ $this->assertFalse($cotisationUtils->isManagerAndLastParentAndCMF($organization3));
|
|
|
|
|
+ $this->assertFalse($cotisationUtils->isManagerAndLastParentAndCMF($organization4));
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -204,100 +199,75 @@ class UtilsTest extends TestCase
|
|
|
*/
|
|
*/
|
|
|
public function testIsManagerAndNotLastParentAndCMF(): void
|
|
public function testIsManagerAndNotLastParentAndCMF(): void
|
|
|
{
|
|
{
|
|
|
- $organizationMock = $this->getOrganizationMock();
|
|
|
|
|
-
|
|
|
|
|
- $this->organizationUtilsMock
|
|
|
|
|
- ->expects($this->once())
|
|
|
|
|
- ->method('isManager')
|
|
|
|
|
- ->with($organizationMock)
|
|
|
|
|
- ->willReturn(true);
|
|
|
|
|
-
|
|
|
|
|
- $this->networkOrganizationRepositoryMock
|
|
|
|
|
- ->expects($this->once())
|
|
|
|
|
- ->method('isLastParent')
|
|
|
|
|
- ->with($organizationMock)
|
|
|
|
|
- ->willReturn(false);
|
|
|
|
|
-
|
|
|
|
|
- $this->networkUtilsMock
|
|
|
|
|
- ->expects($this->never())
|
|
|
|
|
- ->method('isCMF');
|
|
|
|
|
-
|
|
|
|
|
- $utils = $this->getUtilsInstance();
|
|
|
|
|
- $this->assertTrue($utils->isManagerAndNotLastParentAndCMF($organizationMock));
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ $cotisationUtils = $this->getMockBuilder(CotisationUtils::class)
|
|
|
|
|
+ ->setConstructorArgs([$this->networkUtils, $this->organizationUtils, $this->networkOrganizationRepository, $this->cotisationApiResourcesRepository])
|
|
|
|
|
+ ->setMethodsExcept(['isManagerAndNotLastParentAndCMF'])
|
|
|
|
|
+ ->getMock();
|
|
|
|
|
|
|
|
- /**
|
|
|
|
|
- * @see Utils::isManagerAndLastParentAndCMF()
|
|
|
|
|
- */
|
|
|
|
|
- public function testIsManagerAndLastParentAndCMF(): void
|
|
|
|
|
- {
|
|
|
|
|
- $organizationMock = $this->getOrganizationMock();
|
|
|
|
|
|
|
+ $organization1 = $this->getMockBuilder(Organization::class)->getMock();
|
|
|
|
|
+ $organization2 = $this->getMockBuilder(Organization::class)->getMock();
|
|
|
|
|
+ $organization3 = $this->getMockBuilder(Organization::class)->getMock();
|
|
|
|
|
+ $organization4 = $this->getMockBuilder(Organization::class)->getMock();
|
|
|
|
|
|
|
|
- $this->organizationUtilsMock
|
|
|
|
|
- ->expects($this->once())
|
|
|
|
|
|
|
+ $this->organizationUtils
|
|
|
->method('isManager')
|
|
->method('isManager')
|
|
|
- ->with($organizationMock)
|
|
|
|
|
- ->willReturn(true);
|
|
|
|
|
-
|
|
|
|
|
- $this->networkOrganizationRepositoryMock
|
|
|
|
|
- ->expects($this->once())
|
|
|
|
|
|
|
+ ->willReturnMap([
|
|
|
|
|
+ [$organization1, true],
|
|
|
|
|
+ [$organization2, false],
|
|
|
|
|
+ [$organization3, true],
|
|
|
|
|
+ [$organization4, true],
|
|
|
|
|
+ ]);
|
|
|
|
|
+
|
|
|
|
|
+ $this->networkOrganizationRepository
|
|
|
->method('isLastParent')
|
|
->method('isLastParent')
|
|
|
- ->with($organizationMock)
|
|
|
|
|
- ->willReturn(true);
|
|
|
|
|
-
|
|
|
|
|
- $this->networkUtilsMock
|
|
|
|
|
- ->expects($this->once())
|
|
|
|
|
|
|
+ ->willReturnMap([
|
|
|
|
|
+ [$organization1, false],
|
|
|
|
|
+ [$organization2, false],
|
|
|
|
|
+ [$organization3, true],
|
|
|
|
|
+ [$organization4, false],
|
|
|
|
|
+ ]);
|
|
|
|
|
+
|
|
|
|
|
+ $this->networkUtils
|
|
|
->method('isCMF')
|
|
->method('isCMF')
|
|
|
- ->willReturn(true);
|
|
|
|
|
-
|
|
|
|
|
- $utils = $this->getUtilsInstance();
|
|
|
|
|
- $this->assertTrue($utils->isManagerAndLastParentAndCMF($organizationMock));
|
|
|
|
|
|
|
+ ->willReturnMap([
|
|
|
|
|
+ [$organization1, true],
|
|
|
|
|
+ [$organization2, true],
|
|
|
|
|
+ [$organization3, true],
|
|
|
|
|
+ [$organization4, false],
|
|
|
|
|
+ ]);
|
|
|
|
|
+
|
|
|
|
|
+ $this->assertTrue($cotisationUtils->isManagerAndNotLastParentAndCMF($organization1));
|
|
|
|
|
+ $this->assertFalse($cotisationUtils->isManagerAndNotLastParentAndCMF($organization2));
|
|
|
|
|
+ $this->assertFalse($cotisationUtils->isManagerAndNotLastParentAndCMF($organization3));
|
|
|
|
|
+ $this->assertFalse($cotisationUtils->isManagerAndNotLastParentAndCMF($organization4));
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* @see Utils::getAlertState()
|
|
* @see Utils::getAlertState()
|
|
|
*/
|
|
*/
|
|
|
- public function testGetAlertStateAffiliation(): void
|
|
|
|
|
|
|
+ public function testGetAlertState(): void
|
|
|
{
|
|
{
|
|
|
- $year = 2022;
|
|
|
|
|
-
|
|
|
|
|
- $organizationMock = $this->getOrganizationMock();
|
|
|
|
|
-
|
|
|
|
|
- $utils = $this->getUtilsInstance();
|
|
|
|
|
-
|
|
|
|
|
- $this->cotisationApiResourcesRepositoryMock
|
|
|
|
|
- ->method('getAffiliationState')
|
|
|
|
|
- ->with($organizationMock->getId(), $year)
|
|
|
|
|
- ->willReturn(self::MEMBERSHIP_WAITING);
|
|
|
|
|
-
|
|
|
|
|
- $this->assertEquals(AlertStateEnum::AFFILIATION()->getValue(), $utils->getAlertState($organizationMock, $year) );
|
|
|
|
|
-
|
|
|
|
|
- $this->cotisationApiResourcesRepositoryMock
|
|
|
|
|
- ->method('getAffiliationState')
|
|
|
|
|
- ->with($organizationMock->getId(), $year)
|
|
|
|
|
- ->willReturn(self::SUBMIT_IN_PROGRESS);
|
|
|
|
|
-
|
|
|
|
|
- $this->assertEquals(AlertStateEnum::AFFILIATION()->getValue(), $utils->getAlertState($organizationMock, $year) );
|
|
|
|
|
|
|
+ $cotisationUtils = $this->getMockBuilder(CotisationUtils::class)
|
|
|
|
|
+ ->setConstructorArgs([$this->networkUtils, $this->organizationUtils, $this->networkOrganizationRepository, $this->cotisationApiResourcesRepository])
|
|
|
|
|
+ ->setMethodsExcept(['getAlertState'])
|
|
|
|
|
+ ->getMock();
|
|
|
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ $organization = $this->getMockBuilder(Organization::class)->getMock();
|
|
|
|
|
+ $organization->method('getId')->willReturn(1);
|
|
|
|
|
|
|
|
- /**
|
|
|
|
|
- * @see Utils::getAlertState()
|
|
|
|
|
- */
|
|
|
|
|
- public function testGetAlertStateInvoice(): void
|
|
|
|
|
- {
|
|
|
|
|
$year = 2022;
|
|
$year = 2022;
|
|
|
|
|
|
|
|
- $organizationMock = $this->getOrganizationMock();
|
|
|
|
|
-
|
|
|
|
|
- $utils = $this->getUtilsInstance();
|
|
|
|
|
-
|
|
|
|
|
- $this->cotisationApiResourcesRepositoryMock
|
|
|
|
|
|
|
+ $this->cotisationApiResourcesRepository
|
|
|
->method('getAffiliationState')
|
|
->method('getAffiliationState')
|
|
|
- ->with($organizationMock->getId(), $year)
|
|
|
|
|
- ->willReturn(self::MEMBERSHIP_NOPAYMENT);
|
|
|
|
|
|
|
+ ->with($organization->getId(), $year)
|
|
|
|
|
+ ->willReturnOnConsecutiveCalls(
|
|
|
|
|
+ self::MEMBERSHIP_WAITING, self::SUBMIT_IN_PROGRESS, self::MEMBERSHIP_NOPAYMENT
|
|
|
|
|
+ );
|
|
|
|
|
+
|
|
|
|
|
+ $this->assertEquals(AlertStateEnum::AFFILIATION()->getValue(), $cotisationUtils->getAlertState($organization, $year) );
|
|
|
|
|
+ $this->assertEquals(AlertStateEnum::AFFILIATION()->getValue(), $cotisationUtils->getAlertState($organization, $year) );
|
|
|
|
|
+ $this->assertEquals(AlertStateEnum::INVOICE()->getValue(), $cotisationUtils->getAlertState($organization, $year) );
|
|
|
|
|
|
|
|
- $this->assertEquals(AlertStateEnum::INVOICE()->getValue(), $utils->getAlertState($organizationMock, $year) );
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -305,18 +275,27 @@ class UtilsTest extends TestCase
|
|
|
*/
|
|
*/
|
|
|
public function testGetAlertStateInsurance(): void
|
|
public function testGetAlertStateInsurance(): void
|
|
|
{
|
|
{
|
|
|
|
|
+ $cotisationUtils = $this->getMockBuilder(CotisationUtils::class)
|
|
|
|
|
+ ->setConstructorArgs([$this->networkUtils, $this->organizationUtils, $this->networkOrganizationRepository, $this->cotisationApiResourcesRepository])
|
|
|
|
|
+ ->setMethodsExcept(['getAlertState'])
|
|
|
|
|
+ ->getMock();
|
|
|
|
|
+
|
|
|
$year = 2022;
|
|
$year = 2022;
|
|
|
|
|
|
|
|
- $organizationMock = $this->getOrganizationMock();
|
|
|
|
|
|
|
+ $organization = $this->getMockBuilder(Organization::class)->getMock();
|
|
|
|
|
+ $organization->method('getId')->willReturn(1);
|
|
|
|
|
|
|
|
- $utils = $this->getUtilsInstance();
|
|
|
|
|
|
|
+ $this->cotisationApiResourcesRepository
|
|
|
|
|
+ ->method('getAffiliationState')
|
|
|
|
|
+ ->with($organization->getId(), $year)
|
|
|
|
|
+ ->willReturn(null);
|
|
|
|
|
|
|
|
- $this->cotisationApiResourcesRepositoryMock
|
|
|
|
|
|
|
+ $this->cotisationApiResourcesRepository
|
|
|
->method('isInsuranceNotDone')
|
|
->method('isInsuranceNotDone')
|
|
|
- ->with($organizationMock->getId(), $year)
|
|
|
|
|
|
|
+ ->with($organization->getId(), $year)
|
|
|
->willReturn(true);
|
|
->willReturn(true);
|
|
|
|
|
|
|
|
- $this->assertEquals(AlertStateEnum::INSURANCE()->getValue(), $utils->getAlertState($organizationMock, $year) );
|
|
|
|
|
|
|
+ $this->assertEquals(AlertStateEnum::INSURANCE()->getValue(), $cotisationUtils->getAlertState($organization, $year) );
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -324,18 +303,27 @@ class UtilsTest extends TestCase
|
|
|
*/
|
|
*/
|
|
|
public function testGetAlertStateAdvertisingInsurance(): void
|
|
public function testGetAlertStateAdvertisingInsurance(): void
|
|
|
{
|
|
{
|
|
|
|
|
+ $cotisationUtils = $this->getMockBuilder(CotisationUtils::class)
|
|
|
|
|
+ ->setConstructorArgs([$this->networkUtils, $this->organizationUtils, $this->networkOrganizationRepository, $this->cotisationApiResourcesRepository])
|
|
|
|
|
+ ->setMethodsExcept(['getAlertState'])
|
|
|
|
|
+ ->getMock();
|
|
|
|
|
+
|
|
|
$year = 2022;
|
|
$year = 2022;
|
|
|
|
|
|
|
|
- $organizationMock = $this->getOrganizationMock();
|
|
|
|
|
|
|
+ $organization = $this->getMockBuilder(Organization::class)->getMock();
|
|
|
|
|
+ $organization->method('getId')->willReturn(1);
|
|
|
|
|
|
|
|
- $utils = $this->getUtilsInstance();
|
|
|
|
|
|
|
+ $this->cotisationApiResourcesRepository
|
|
|
|
|
+ ->method('getAffiliationState')
|
|
|
|
|
+ ->with($organization->getId(), $year)
|
|
|
|
|
+ ->willReturn(null);
|
|
|
|
|
|
|
|
- $this->cotisationApiResourcesRepositoryMock
|
|
|
|
|
|
|
+ $this->cotisationApiResourcesRepository
|
|
|
->method('isNotDGVCustomer')
|
|
->method('isNotDGVCustomer')
|
|
|
- ->with($organizationMock->getId())
|
|
|
|
|
|
|
+ ->with($organization->getId())
|
|
|
->willReturn(true);
|
|
->willReturn(true);
|
|
|
|
|
|
|
|
- $this->assertEquals(AlertStateEnum::ADVERTISINGINSURANCE()->getValue(), $utils->getAlertState($organizationMock, $year) );
|
|
|
|
|
|
|
+ $this->assertEquals(AlertStateEnum::ADVERTISINGINSURANCE()->getValue(), $cotisationUtils->getAlertState($organization, $year) );
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -343,13 +331,17 @@ class UtilsTest extends TestCase
|
|
|
*/
|
|
*/
|
|
|
public function testGetCurrentCotisationYear(): void
|
|
public function testGetCurrentCotisationYear(): void
|
|
|
{
|
|
{
|
|
|
- $utils = $this->getUtilsInstance();
|
|
|
|
|
|
|
+ $cotisationUtils = $this->getMockBuilder(CotisationUtils::class)
|
|
|
|
|
+ ->setConstructorArgs([$this->networkUtils, $this->organizationUtils, $this->networkOrganizationRepository, $this->cotisationApiResourcesRepository])
|
|
|
|
|
+ ->setMethodsExcept(['getCurrentCotisationYear'])
|
|
|
|
|
+ ->getMock();
|
|
|
|
|
|
|
|
$today = new \DateTime('now');
|
|
$today = new \DateTime('now');
|
|
|
- if($today->format('m') <= 9)
|
|
|
|
|
- $this->assertEquals($today->format('Y'), $utils->getCurrentCotisationYear());
|
|
|
|
|
- else
|
|
|
|
|
- $this->assertEquals(($today->format('Y') + 1), $utils->getCurrentCotisationYear());
|
|
|
|
|
|
|
+ $expectedYear = (int)$today->format('Y');
|
|
|
|
|
+ if($today->format('m') > 9) {
|
|
|
|
|
+ $expectedYear++;
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
|
|
+ $this->assertEquals($expectedYear, $cotisationUtils->getCurrentCotisationYear());
|
|
|
}
|
|
}
|
|
|
-}
|
|
|
|
|
|
|
+}
|