|
@@ -10,27 +10,53 @@ use App\Entity\Organization\Settings;
|
|
|
use App\Entity\Organization\Subdomain;
|
|
use App\Entity\Organization\Subdomain;
|
|
|
use App\Enum\Organization\OrganizationIdsEnum;
|
|
use App\Enum\Organization\OrganizationIdsEnum;
|
|
|
use App\Enum\Organization\SettingsProductEnum;
|
|
use App\Enum\Organization\SettingsProductEnum;
|
|
|
|
|
+use App\Repository\Network\NetworkOrganizationRepository;
|
|
|
|
|
+use App\Service\Network\Utils as NetworkUtils;
|
|
|
use App\Service\Organization\Utils as OrganizationUtils;
|
|
use App\Service\Organization\Utils as OrganizationUtils;
|
|
|
use App\Service\Utils\DatesUtils;
|
|
use App\Service\Utils\DatesUtils;
|
|
|
use Doctrine\Common\Collections\ArrayCollection;
|
|
use Doctrine\Common\Collections\ArrayCollection;
|
|
|
|
|
+use PHPUnit\Framework\MockObject\MockObject;
|
|
|
use PHPUnit\Framework\TestCase;
|
|
use PHPUnit\Framework\TestCase;
|
|
|
|
|
|
|
|
-class TestableOrganizationUtils extends OrganizationUtils
|
|
|
|
|
|
|
+class UtilsTest extends TestCase
|
|
|
{
|
|
{
|
|
|
- public function isOrganizationIdEqualTo(Organization $organization, OrganizationIdsEnum $organizationIdsEnum): bool
|
|
|
|
|
|
|
+ private MockObject|NetworkOrganizationRepository $networkOrganizationRepository;
|
|
|
|
|
+ private MockObject|NetworkUtils $networkUtils;
|
|
|
|
|
+
|
|
|
|
|
+ public function setUp(): void
|
|
|
{
|
|
{
|
|
|
- return parent::isOrganizationIdEqualTo($organization, $organizationIdsEnum);
|
|
|
|
|
|
|
+ $this->networkOrganizationRepository = $this->getMockBuilder(NetworkOrganizationRepository::class)
|
|
|
|
|
+ ->disableOriginalConstructor()
|
|
|
|
|
+ ->getMock();
|
|
|
|
|
+
|
|
|
|
|
+ $this->networkUtils = $this->getMockBuilder(NetworkUtils::class)->disableOriginalConstructor()->getMock();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public function getOrganizationUtilsMockFor(string $methodName): MockObject|OrganizationUtils
|
|
|
|
|
+ {
|
|
|
|
|
+ return $this->getMockBuilder(OrganizationUtils::class)
|
|
|
|
|
+ ->setConstructorArgs([$this->networkOrganizationRepository, $this->networkUtils])
|
|
|
|
|
+ ->setMethodsExcept([$methodName])
|
|
|
|
|
+ ->getMock();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private function createOrganizationWithProductMock(SettingsProductEnum $product): Organization
|
|
|
|
|
+ {
|
|
|
|
|
+ $settings = $this->getMockBuilder(Settings::class)->getMock();
|
|
|
|
|
+ $settings->method('getProduct')->willReturn($product);
|
|
|
|
|
+
|
|
|
|
|
+ $organization = $this->getMockBuilder(Organization::class)->getMock();
|
|
|
|
|
+ $organization->method('getSettings')->willReturn($settings);
|
|
|
|
|
+
|
|
|
|
|
+ return $organization;
|
|
|
}
|
|
}
|
|
|
-}
|
|
|
|
|
|
|
|
|
|
-class UtilsTest extends TestCase
|
|
|
|
|
-{
|
|
|
|
|
/**
|
|
/**
|
|
|
* @see OrganizationUtils::isStructure()
|
|
* @see OrganizationUtils::isStructure()
|
|
|
*/
|
|
*/
|
|
|
public function testIsStructure(): void
|
|
public function testIsStructure(): void
|
|
|
{
|
|
{
|
|
|
- $organizationUtils = $this->getMockBuilder(TestableOrganizationUtils::class)->setMethodsExcept(['isStructure'])->getMock();
|
|
|
|
|
|
|
+ $organizationUtils = $this->getOrganizationUtilsMockFor('isStructure');
|
|
|
|
|
|
|
|
$organization = $this->createOrganizationWithProductMock(SettingsProductEnum::ARTIST);
|
|
$organization = $this->createOrganizationWithProductMock(SettingsProductEnum::ARTIST);
|
|
|
$this->assertTrue($organizationUtils->isStructure($organization));
|
|
$this->assertTrue($organizationUtils->isStructure($organization));
|
|
@@ -56,7 +82,7 @@ class UtilsTest extends TestCase
|
|
|
*/
|
|
*/
|
|
|
public function testIsManager(): void
|
|
public function testIsManager(): void
|
|
|
{
|
|
{
|
|
|
- $organizationUtils = $this->getMockBuilder(TestableOrganizationUtils::class)->setMethodsExcept(['isManager'])->getMock();
|
|
|
|
|
|
|
+ $organizationUtils = $this->getOrganizationUtilsMockFor('isManager');
|
|
|
|
|
|
|
|
$organization = $this->createOrganizationWithProductMock(SettingsProductEnum::ARTIST);
|
|
$organization = $this->createOrganizationWithProductMock(SettingsProductEnum::ARTIST);
|
|
|
$this->assertFalse($organizationUtils->isManager($organization));
|
|
$this->assertFalse($organizationUtils->isManager($organization));
|
|
@@ -82,7 +108,7 @@ class UtilsTest extends TestCase
|
|
|
*/
|
|
*/
|
|
|
public function testIsOrganizationIs2ios(): void
|
|
public function testIsOrganizationIs2ios(): void
|
|
|
{
|
|
{
|
|
|
- $organizationUtils = $this->getMockBuilder(TestableOrganizationUtils::class)->setMethodsExcept(['is2iosOrganization'])->getMock();
|
|
|
|
|
|
|
+ $organizationUtils = $this->getOrganizationUtilsMockFor('is2iosOrganization');
|
|
|
|
|
|
|
|
$organization = $this->getMockBuilder(Organization::class)->getMock();
|
|
$organization = $this->getMockBuilder(Organization::class)->getMock();
|
|
|
|
|
|
|
@@ -92,17 +118,17 @@ class UtilsTest extends TestCase
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
- * @see OrganizationUtils::isOrganizationCMF()
|
|
|
|
|
|
|
+ * @see OrganizationUtils::isCMF()
|
|
|
*/
|
|
*/
|
|
|
- public function testIsOrganizationIsCMF(): void
|
|
|
|
|
|
|
+ public function testIsCMF(): void
|
|
|
{
|
|
{
|
|
|
- $organizationUtils = $this->getMockBuilder(TestableOrganizationUtils::class)->setMethodsExcept(['isOrganizationCMF'])->getMock();
|
|
|
|
|
|
|
+ $organizationUtils = $this->getOrganizationUtilsMockFor('isCMF');
|
|
|
|
|
|
|
|
$organization = $this->getMockBuilder(Organization::class)->getMock();
|
|
$organization = $this->getMockBuilder(Organization::class)->getMock();
|
|
|
|
|
|
|
|
$organizationUtils->expects(self::once())->method('isOrganizationIdEqualTo')->with($organization, OrganizationIdsEnum::CMF);
|
|
$organizationUtils->expects(self::once())->method('isOrganizationIdEqualTo')->with($organization, OrganizationIdsEnum::CMF);
|
|
|
|
|
|
|
|
- $organizationUtils->isOrganizationCMF($organization);
|
|
|
|
|
|
|
+ $organizationUtils->isCMF($organization);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -110,7 +136,7 @@ class UtilsTest extends TestCase
|
|
|
*/
|
|
*/
|
|
|
public function testIsOrganizationIdEqualTo(): void
|
|
public function testIsOrganizationIdEqualTo(): void
|
|
|
{
|
|
{
|
|
|
- $organizationUtils = $this->getMockBuilder(TestableOrganizationUtils::class)->setMethodsExcept(['isOrganizationIdEqualTo'])->getMock();
|
|
|
|
|
|
|
+ $organizationUtils = $this->getOrganizationUtilsMockFor('isOrganizationIdEqualTo');
|
|
|
|
|
|
|
|
$organization = $this->getMockBuilder(Organization::class)->getMock();
|
|
$organization = $this->getMockBuilder(Organization::class)->getMock();
|
|
|
$organization->method('getId')->willReturnOnConsecutiveCalls(123, OrganizationIdsEnum::_2IOS->value);
|
|
$organization->method('getId')->willReturnOnConsecutiveCalls(123, OrganizationIdsEnum::_2IOS->value);
|
|
@@ -124,7 +150,7 @@ class UtilsTest extends TestCase
|
|
|
*/
|
|
*/
|
|
|
public function testGetOrganizationCurrentActivityYear(): void
|
|
public function testGetOrganizationCurrentActivityYear(): void
|
|
|
{
|
|
{
|
|
|
- $organizationUtils = $this->getMockBuilder(TestableOrganizationUtils::class)->setMethodsExcept(['getOrganizationCurrentActivityYear'])->getMock();
|
|
|
|
|
|
|
+ $organizationUtils = $this->getOrganizationUtilsMockFor('getOrganizationCurrentActivityYear');
|
|
|
|
|
|
|
|
$parameters = $this->getMockBuilder(Parameters::class)->getMock();
|
|
$parameters = $this->getMockBuilder(Parameters::class)->getMock();
|
|
|
$parameters->method('getMusicalDate')->willReturnOnConsecutiveCalls(
|
|
$parameters->method('getMusicalDate')->willReturnOnConsecutiveCalls(
|
|
@@ -155,7 +181,7 @@ class UtilsTest extends TestCase
|
|
|
*/
|
|
*/
|
|
|
public function testGetActivityPeriodsSwitchYear(): void
|
|
public function testGetActivityPeriodsSwitchYear(): void
|
|
|
{
|
|
{
|
|
|
- $organizationUtils = $this->getMockBuilder(TestableOrganizationUtils::class)->setMethodsExcept(['getActivityPeriodsSwitchYear'])->getMock();
|
|
|
|
|
|
|
+ $organizationUtils = $this->getOrganizationUtilsMockFor('getActivityPeriodsSwitchYear');
|
|
|
|
|
|
|
|
$parameters = $this->getMockBuilder(Parameters::class)->getMock();
|
|
$parameters = $this->getMockBuilder(Parameters::class)->getMock();
|
|
|
$parameters->method('getMusicalDate')->willReturn(new \DateTime('2020-09-05'));
|
|
$parameters->method('getMusicalDate')->willReturn(new \DateTime('2020-09-05'));
|
|
@@ -174,7 +200,7 @@ class UtilsTest extends TestCase
|
|
|
*/
|
|
*/
|
|
|
public function testGetActivityPeriodsSwitchYearNoMusicalDate(): void
|
|
public function testGetActivityPeriodsSwitchYearNoMusicalDate(): void
|
|
|
{
|
|
{
|
|
|
- $organizationUtils = $this->getMockBuilder(TestableOrganizationUtils::class)->setMethodsExcept(['getActivityPeriodsSwitchYear'])->getMock();
|
|
|
|
|
|
|
+ $organizationUtils = $this->getOrganizationUtilsMockFor('getActivityPeriodsSwitchYear');
|
|
|
|
|
|
|
|
$parameters = $this->getMockBuilder(Parameters::class)->getMock();
|
|
$parameters = $this->getMockBuilder(Parameters::class)->getMock();
|
|
|
$parameters->method('getMusicalDate')->willReturn(null);
|
|
$parameters->method('getMusicalDate')->willReturn(null);
|
|
@@ -193,7 +219,7 @@ class UtilsTest extends TestCase
|
|
|
*/
|
|
*/
|
|
|
public function testGetActivityYearSwitchDate(): void
|
|
public function testGetActivityYearSwitchDate(): void
|
|
|
{
|
|
{
|
|
|
- $organizationUtils = $this->getMockBuilder(TestableOrganizationUtils::class)->setMethodsExcept(['getActivityYearSwitchDate'])->getMock();
|
|
|
|
|
|
|
+ $organizationUtils = $this->getOrganizationUtilsMockFor('getActivityYearSwitchDate');
|
|
|
|
|
|
|
|
$parameters = $this->getMockBuilder(Parameters::class)->getMock();
|
|
$parameters = $this->getMockBuilder(Parameters::class)->getMock();
|
|
|
$parameters->method('getMusicalDate')->willReturn(new \DateTime('2020-09-05'));
|
|
$parameters->method('getMusicalDate')->willReturn(new \DateTime('2020-09-05'));
|
|
@@ -210,7 +236,7 @@ class UtilsTest extends TestCase
|
|
|
*/
|
|
*/
|
|
|
public function testGetActivityYearSwitchDateNoMusicalDate(): void
|
|
public function testGetActivityYearSwitchDateNoMusicalDate(): void
|
|
|
{
|
|
{
|
|
|
- $organizationUtils = $this->getMockBuilder(TestableOrganizationUtils::class)->setMethodsExcept(['getActivityYearSwitchDate'])->getMock();
|
|
|
|
|
|
|
+ $organizationUtils = $this->getOrganizationUtilsMockFor('getActivityYearSwitchDate');
|
|
|
|
|
|
|
|
$parameters = $this->getMockBuilder(Parameters::class)->getMock();
|
|
$parameters = $this->getMockBuilder(Parameters::class)->getMock();
|
|
|
$parameters->method('getMusicalDate')->willReturn(null);
|
|
$parameters->method('getMusicalDate')->willReturn(null);
|
|
@@ -227,7 +253,7 @@ class UtilsTest extends TestCase
|
|
|
*/
|
|
*/
|
|
|
public function testGetOrganizationActiveSubdomain(): void
|
|
public function testGetOrganizationActiveSubdomain(): void
|
|
|
{
|
|
{
|
|
|
- $organizationUtils = $this->getMockBuilder(TestableOrganizationUtils::class)->setMethodsExcept(['getOrganizationActiveSubdomain'])->getMock();
|
|
|
|
|
|
|
+ $organizationUtils = $this->getOrganizationUtilsMockFor('getOrganizationActiveSubdomain');
|
|
|
|
|
|
|
|
$subdomain1 = $this->getMockBuilder(Subdomain::class)->getMock();
|
|
$subdomain1 = $this->getMockBuilder(Subdomain::class)->getMock();
|
|
|
$subdomain1->method('isActive')->willReturn(false);
|
|
$subdomain1->method('isActive')->willReturn(false);
|
|
@@ -250,7 +276,7 @@ class UtilsTest extends TestCase
|
|
|
*/
|
|
*/
|
|
|
public function testGetOrganizationActiveSubdomainNone(): void
|
|
public function testGetOrganizationActiveSubdomainNone(): void
|
|
|
{
|
|
{
|
|
|
- $organizationUtils = $this->getMockBuilder(TestableOrganizationUtils::class)->setMethodsExcept(['getOrganizationActiveSubdomain'])->getMock();
|
|
|
|
|
|
|
+ $organizationUtils = $this->getOrganizationUtilsMockFor('getOrganizationActiveSubdomain');
|
|
|
|
|
|
|
|
$subdomain1 = $this->getMockBuilder(Subdomain::class)->getMock();
|
|
$subdomain1 = $this->getMockBuilder(Subdomain::class)->getMock();
|
|
|
$subdomain1->method('isActive')->willReturn(false);
|
|
$subdomain1->method('isActive')->willReturn(false);
|
|
@@ -266,7 +292,7 @@ class UtilsTest extends TestCase
|
|
|
*/
|
|
*/
|
|
|
public function testOrganizationWebsite(): void
|
|
public function testOrganizationWebsite(): void
|
|
|
{
|
|
{
|
|
|
- $organizationUtils = $this->getMockBuilder(TestableOrganizationUtils::class)->setMethodsExcept(['getOrganizationWebsite'])->getMock();
|
|
|
|
|
|
|
+ $organizationUtils = $this->getOrganizationUtilsMockFor('getOrganizationWebsite');
|
|
|
|
|
|
|
|
$parameters = $this->getMockBuilder(Parameters::class)->getMock();
|
|
$parameters = $this->getMockBuilder(Parameters::class)->getMock();
|
|
|
$parameters->method('getDesactivateOpentalentSiteWeb')->willReturn(false);
|
|
$parameters->method('getDesactivateOpentalentSiteWeb')->willReturn(false);
|
|
@@ -285,7 +311,7 @@ class UtilsTest extends TestCase
|
|
|
*/
|
|
*/
|
|
|
public function testOrganizationWebsiteDeactivatedWithOther(): void
|
|
public function testOrganizationWebsiteDeactivatedWithOther(): void
|
|
|
{
|
|
{
|
|
|
- $organizationUtils = $this->getMockBuilder(TestableOrganizationUtils::class)->setMethodsExcept(['getOrganizationWebsite'])->getMock();
|
|
|
|
|
|
|
+ $organizationUtils = $this->getOrganizationUtilsMockFor('getOrganizationWebsite');
|
|
|
|
|
|
|
|
$parameters = $this->getMockBuilder(Parameters::class)->getMock();
|
|
$parameters = $this->getMockBuilder(Parameters::class)->getMock();
|
|
|
$parameters->method('getDesactivateOpentalentSiteWeb')->willReturn(true);
|
|
$parameters->method('getDesactivateOpentalentSiteWeb')->willReturn(true);
|
|
@@ -302,7 +328,7 @@ class UtilsTest extends TestCase
|
|
|
*/
|
|
*/
|
|
|
public function testOrganizationWebsiteDeactivatedNoOther(): void
|
|
public function testOrganizationWebsiteDeactivatedNoOther(): void
|
|
|
{
|
|
{
|
|
|
- $organizationUtils = $this->getMockBuilder(TestableOrganizationUtils::class)->setMethodsExcept(['getOrganizationWebsite'])->getMock();
|
|
|
|
|
|
|
+ $organizationUtils = $this->getOrganizationUtilsMockFor('getOrganizationWebsite');
|
|
|
|
|
|
|
|
$parameters = $this->getMockBuilder(Parameters::class)->getMock();
|
|
$parameters = $this->getMockBuilder(Parameters::class)->getMock();
|
|
|
$parameters->method('getDesactivateOpentalentSiteWeb')->willReturn(true);
|
|
$parameters->method('getDesactivateOpentalentSiteWeb')->willReturn(true);
|
|
@@ -319,7 +345,7 @@ class UtilsTest extends TestCase
|
|
|
*/
|
|
*/
|
|
|
public function testOrganizationWebsiteWithCustom(): void
|
|
public function testOrganizationWebsiteWithCustom(): void
|
|
|
{
|
|
{
|
|
|
- $organizationUtils = $this->getMockBuilder(TestableOrganizationUtils::class)->setMethodsExcept(['getOrganizationWebsite'])->getMock();
|
|
|
|
|
|
|
+ $organizationUtils = $this->getOrganizationUtilsMockFor('getOrganizationWebsite');
|
|
|
|
|
|
|
|
$parameters = $this->getMockBuilder(Parameters::class)->getMock();
|
|
$parameters = $this->getMockBuilder(Parameters::class)->getMock();
|
|
|
$parameters->method('getDesactivateOpentalentSiteWeb')->willReturn(false);
|
|
$parameters->method('getDesactivateOpentalentSiteWeb')->willReturn(false);
|
|
@@ -336,7 +362,7 @@ class UtilsTest extends TestCase
|
|
|
*/
|
|
*/
|
|
|
public function testOrganizationWebsiteNoSubdomains(): void
|
|
public function testOrganizationWebsiteNoSubdomains(): void
|
|
|
{
|
|
{
|
|
|
- $organizationUtils = $this->getMockBuilder(TestableOrganizationUtils::class)->setMethodsExcept(['getOrganizationWebsite'])->getMock();
|
|
|
|
|
|
|
+ $organizationUtils = $this->getOrganizationUtilsMockFor('getOrganizationWebsite');
|
|
|
|
|
|
|
|
$parameters = $this->getMockBuilder(Parameters::class)->getMock();
|
|
$parameters = $this->getMockBuilder(Parameters::class)->getMock();
|
|
|
$parameters->method('getDesactivateOpentalentSiteWeb')->willReturn(false);
|
|
$parameters->method('getDesactivateOpentalentSiteWeb')->willReturn(false);
|
|
@@ -350,12 +376,221 @@ class UtilsTest extends TestCase
|
|
|
$this->assertEquals(null, $organizationUtils->getOrganizationWebsite($organization));
|
|
$this->assertEquals(null, $organizationUtils->getOrganizationWebsite($organization));
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * @see OrganizationUtils::getOrganizationWebsite()
|
|
|
|
|
+ */
|
|
|
|
|
+ public function testOrganizationWebsiteOutOfNetSubdomain(): void
|
|
|
|
|
+ {
|
|
|
|
|
+ $organizationUtils = $this->getOrganizationUtilsMockFor('getOrganizationWebsite');
|
|
|
|
|
+
|
|
|
|
|
+ $parameters = $this->getMockBuilder(Parameters::class)->getMock();
|
|
|
|
|
+ $parameters->method('getDesactivateOpentalentSiteWeb')->willReturn(false);
|
|
|
|
|
+ $parameters->method('getCustomDomain')->willReturn(null);
|
|
|
|
|
+
|
|
|
|
|
+ $organization = $this->getMockBuilder(Organization::class)->getMock();
|
|
|
|
|
+ $organization->method('getParameters')->willReturn($parameters);
|
|
|
|
|
+
|
|
|
|
|
+ $organizationUtils->method('getOrganizationActiveSubdomain')->with($organization)->willReturn('outofnet');
|
|
|
|
|
+
|
|
|
|
|
+ $this->assertEquals('https://opentalent.fr', $organizationUtils->getOrganizationWebsite($organization));
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * @see Utils::isLastParentAndCMF()
|
|
|
|
|
+ */
|
|
|
|
|
+ public function testIsLastParentAndCMF(): void
|
|
|
|
|
+ {
|
|
|
|
|
+ $organizationUtils = $this->getOrganizationUtilsMockFor('isLastParentAndCMF');
|
|
|
|
|
+
|
|
|
|
|
+ $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->networkOrganizationRepository
|
|
|
|
|
+ ->method('isLastParent')
|
|
|
|
|
+ ->willReturnMap([
|
|
|
|
|
+ [$organization1, true],
|
|
|
|
|
+ [$organization2, true],
|
|
|
|
|
+ [$organization3, false],
|
|
|
|
|
+ [$organization4, false],
|
|
|
|
|
+ ]);
|
|
|
|
|
+
|
|
|
|
|
+ $this->networkUtils
|
|
|
|
|
+ ->method('isCMF')
|
|
|
|
|
+ ->willReturnMap([
|
|
|
|
|
+ [$organization1, true],
|
|
|
|
|
+ [$organization2, false],
|
|
|
|
|
+ [$organization3, true],
|
|
|
|
|
+ [$organization4, false],
|
|
|
|
|
+ ]);
|
|
|
|
|
+
|
|
|
|
|
+ $this->assertTrue($organizationUtils->isLastParentAndCMF($organization1));
|
|
|
|
|
+ $this->assertFalse($organizationUtils->isLastParentAndCMF($organization2));
|
|
|
|
|
+ $this->assertFalse($organizationUtils->isLastParentAndCMF($organization3));
|
|
|
|
|
+ $this->assertFalse($organizationUtils->isLastParentAndCMF($organization4));
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * @see Utils::isStructureAndCMF()
|
|
|
|
|
+ */
|
|
|
|
|
+ public function testIsStructureAndCMF(): void
|
|
|
|
|
+ {
|
|
|
|
|
+ $organizationUtils = $this->getOrganizationUtilsMockFor('isStructureAndCMF');
|
|
|
|
|
+
|
|
|
|
|
+ $organization1 = $this->getMockBuilder(Organization::class)->getMock();
|
|
|
|
|
+ $organization2 = $this->getMockBuilder(Organization::class)->getMock();
|
|
|
|
|
+ $organization3 = $this->getMockBuilder(Organization::class)->getMock();
|
|
|
|
|
+ $organization4 = $this->getMockBuilder(Organization::class)->getMock();
|
|
|
|
|
+
|
|
|
|
|
+ $organizationUtils
|
|
|
|
|
+ ->method('isStructure')
|
|
|
|
|
+ ->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($organizationUtils->isStructureAndCMF($organization1));
|
|
|
|
|
+ $this->assertFalse($organizationUtils->isStructureAndCMF($organization2));
|
|
|
|
|
+ $this->assertFalse($organizationUtils->isStructureAndCMF($organization3));
|
|
|
|
|
+ $this->assertFalse($organizationUtils->isStructureAndCMF($organization4));
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * @see Utils::isManagerAndCMF()
|
|
|
|
|
+ */
|
|
|
|
|
+ public function testIsManagerAndCMF(): void
|
|
|
|
|
+ {
|
|
|
|
|
+ $organizationUtils = $this->getOrganizationUtilsMockFor('isManagerAndCMF');
|
|
|
|
|
+
|
|
|
|
|
+ $organization1 = $this->getMockBuilder(Organization::class)->getMock();
|
|
|
|
|
+ $organization2 = $this->getMockBuilder(Organization::class)->getMock();
|
|
|
|
|
+ $organization3 = $this->getMockBuilder(Organization::class)->getMock();
|
|
|
|
|
+ $organization4 = $this->getMockBuilder(Organization::class)->getMock();
|
|
|
|
|
+
|
|
|
|
|
+ $organizationUtils
|
|
|
|
|
+ ->method('isManager')
|
|
|
|
|
+ ->willReturnMap([
|
|
|
|
|
+ [$organization1, true],
|
|
|
|
|
+ [$organization2, false],
|
|
|
|
|
+ [$organization3, true],
|
|
|
|
|
+ [$organization4, false],
|
|
|
|
|
+ ]);
|
|
|
|
|
+
|
|
|
|
|
+ $this->networkUtils
|
|
|
|
|
+ ->method('isCMF')
|
|
|
|
|
+ ->willReturnMap([
|
|
|
|
|
+ [$organization1, true],
|
|
|
|
|
+ [$organization2, false],
|
|
|
|
|
+ [$organization3, false],
|
|
|
|
|
+ [$organization4, true],
|
|
|
|
|
+ ]);
|
|
|
|
|
+
|
|
|
|
|
+ $this->assertTrue($organizationUtils->isManagerAndCMF($organization1));
|
|
|
|
|
+ $this->assertFalse($organizationUtils->isManagerAndCMF($organization2));
|
|
|
|
|
+ $this->assertFalse($organizationUtils->isManagerAndCMF($organization3));
|
|
|
|
|
+ $this->assertFalse($organizationUtils->isManagerAndCMF($organization4));
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * @see Utils::isManagerAndNotLastParentAndCMF()
|
|
|
|
|
+ */
|
|
|
|
|
+ public function testIsManagerAndLastParentAndCMF(): void
|
|
|
|
|
+ {
|
|
|
|
|
+ $organizationUtils = $this->getOrganizationUtilsMockFor('isManagerAndLastParentAndCMF');
|
|
|
|
|
+
|
|
|
|
|
+ $organization1 = $this->getMockBuilder(Organization::class)->getMock();
|
|
|
|
|
+ $organization2 = $this->getMockBuilder(Organization::class)->getMock();
|
|
|
|
|
+ $organization3 = $this->getMockBuilder(Organization::class)->getMock();
|
|
|
|
|
+ $organization4 = $this->getMockBuilder(Organization::class)->getMock();
|
|
|
|
|
+
|
|
|
|
|
+ $organizationUtils
|
|
|
|
|
+ ->method('isManager')
|
|
|
|
|
+ ->willReturnMap([
|
|
|
|
|
+ [$organization1, true],
|
|
|
|
|
+ [$organization2, false],
|
|
|
|
|
+ [$organization3, true],
|
|
|
|
|
+ [$organization4, false],
|
|
|
|
|
+ ]);
|
|
|
|
|
+
|
|
|
|
|
+ $organizationUtils
|
|
|
|
|
+ ->method('isLastParentAndCMF')
|
|
|
|
|
+ ->willReturnMap([
|
|
|
|
|
+ [$organization1, true],
|
|
|
|
|
+ [$organization2, false],
|
|
|
|
|
+ [$organization3, false],
|
|
|
|
|
+ [$organization4, true],
|
|
|
|
|
+ ]);
|
|
|
|
|
+
|
|
|
|
|
+ $this->assertTrue($organizationUtils->isManagerAndLastParentAndCMF($organization1));
|
|
|
|
|
+ $this->assertFalse($organizationUtils->isManagerAndLastParentAndCMF($organization2));
|
|
|
|
|
+ $this->assertFalse($organizationUtils->isManagerAndLastParentAndCMF($organization3));
|
|
|
|
|
+ $this->assertFalse($organizationUtils->isManagerAndLastParentAndCMF($organization4));
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * @see Utils::isManagerAndNotLastParentAndCMF()
|
|
|
|
|
+ */
|
|
|
|
|
+ public function testIsManagerAndNotLastParentAndCMF(): void
|
|
|
|
|
+ {
|
|
|
|
|
+ $organizationUtils = $this->getOrganizationUtilsMockFor('isManagerAndNotLastParentAndCMF');
|
|
|
|
|
+
|
|
|
|
|
+ $organization1 = $this->getMockBuilder(Organization::class)->getMock();
|
|
|
|
|
+ $organization2 = $this->getMockBuilder(Organization::class)->getMock();
|
|
|
|
|
+ $organization3 = $this->getMockBuilder(Organization::class)->getMock();
|
|
|
|
|
+ $organization4 = $this->getMockBuilder(Organization::class)->getMock();
|
|
|
|
|
+
|
|
|
|
|
+ $organizationUtils
|
|
|
|
|
+ ->method('isManager')
|
|
|
|
|
+ ->willReturnMap([
|
|
|
|
|
+ [$organization1, true],
|
|
|
|
|
+ [$organization2, false],
|
|
|
|
|
+ [$organization3, true],
|
|
|
|
|
+ [$organization4, true],
|
|
|
|
|
+ ]);
|
|
|
|
|
+
|
|
|
|
|
+ $this->networkOrganizationRepository
|
|
|
|
|
+ ->method('isLastParent')
|
|
|
|
|
+ ->willReturnMap([
|
|
|
|
|
+ [$organization1, false],
|
|
|
|
|
+ [$organization2, false],
|
|
|
|
|
+ [$organization3, true],
|
|
|
|
|
+ [$organization4, false],
|
|
|
|
|
+ ]);
|
|
|
|
|
+
|
|
|
|
|
+ $this->networkUtils
|
|
|
|
|
+ ->method('isCMF')
|
|
|
|
|
+ ->willReturnMap([
|
|
|
|
|
+ [$organization1, true],
|
|
|
|
|
+ [$organization2, true],
|
|
|
|
|
+ [$organization3, true],
|
|
|
|
|
+ [$organization4, false],
|
|
|
|
|
+ ]);
|
|
|
|
|
+
|
|
|
|
|
+ $this->assertTrue($organizationUtils->isManagerAndNotLastParentAndCMF($organization1));
|
|
|
|
|
+ $this->assertFalse($organizationUtils->isManagerAndNotLastParentAndCMF($organization2));
|
|
|
|
|
+ $this->assertFalse($organizationUtils->isManagerAndNotLastParentAndCMF($organization3));
|
|
|
|
|
+ $this->assertFalse($organizationUtils->isManagerAndNotLastParentAndCMF($organization4));
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* @see OrganizationUtils::isSchool()
|
|
* @see OrganizationUtils::isSchool()
|
|
|
*/
|
|
*/
|
|
|
public function testIsSchool(): void
|
|
public function testIsSchool(): void
|
|
|
{
|
|
{
|
|
|
- $organizationUtils = $this->getMockBuilder(TestableOrganizationUtils::class)->setMethodsExcept(['isSchool'])->getMock();
|
|
|
|
|
|
|
+ $organizationUtils = $this->getOrganizationUtilsMockFor('isSchool');
|
|
|
|
|
|
|
|
$organization = $this->createOrganizationWithProductMock(SettingsProductEnum::ARTIST);
|
|
$organization = $this->createOrganizationWithProductMock(SettingsProductEnum::ARTIST);
|
|
|
$this->assertFalse($organizationUtils->isSchool($organization));
|
|
$this->assertFalse($organizationUtils->isSchool($organization));
|
|
@@ -381,7 +616,7 @@ class UtilsTest extends TestCase
|
|
|
*/
|
|
*/
|
|
|
public function testIsArtist(): void
|
|
public function testIsArtist(): void
|
|
|
{
|
|
{
|
|
|
- $organizationUtils = $this->getMockBuilder(TestableOrganizationUtils::class)->setMethodsExcept(['isArtist'])->getMock();
|
|
|
|
|
|
|
+ $organizationUtils = $this->getOrganizationUtilsMockFor('isArtist');
|
|
|
|
|
|
|
|
$organization = $this->createOrganizationWithProductMock(SettingsProductEnum::ARTIST);
|
|
$organization = $this->createOrganizationWithProductMock(SettingsProductEnum::ARTIST);
|
|
|
$this->assertTrue($organizationUtils->isArtist($organization));
|
|
$this->assertTrue($organizationUtils->isArtist($organization));
|
|
@@ -407,7 +642,7 @@ class UtilsTest extends TestCase
|
|
|
*/
|
|
*/
|
|
|
public function testHasModule(): void
|
|
public function testHasModule(): void
|
|
|
{
|
|
{
|
|
|
- $organizationUtils = $this->getMockBuilder(TestableOrganizationUtils::class)->setMethodsExcept(['hasModule'])->getMock();
|
|
|
|
|
|
|
+ $organizationUtils = $this->getOrganizationUtilsMockFor('hasModule');
|
|
|
|
|
|
|
|
$settings = $this->getMockBuilder(Settings::class)->getMock();
|
|
$settings = $this->getMockBuilder(Settings::class)->getMock();
|
|
|
$settings->method('getModules')->willReturn(['foo', 'bar']);
|
|
$settings->method('getModules')->willReturn(['foo', 'bar']);
|
|
@@ -418,15 +653,4 @@ class UtilsTest extends TestCase
|
|
|
$this->assertTrue($organizationUtils->hasModule($organization, 'foo'));
|
|
$this->assertTrue($organizationUtils->hasModule($organization, 'foo'));
|
|
|
$this->assertFalse($organizationUtils->hasModule($organization, 'other'));
|
|
$this->assertFalse($organizationUtils->hasModule($organization, 'other'));
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
- private function createOrganizationWithProductMock(SettingsProductEnum $product): Organization
|
|
|
|
|
- {
|
|
|
|
|
- $settings = $this->getMockBuilder(Settings::class)->getMock();
|
|
|
|
|
- $settings->method('getProduct')->willReturn($product);
|
|
|
|
|
-
|
|
|
|
|
- $organization = $this->getMockBuilder(Organization::class)->getMock();
|
|
|
|
|
- $organization->method('getSettings')->willReturn($settings);
|
|
|
|
|
-
|
|
|
|
|
- return $organization;
|
|
|
|
|
- }
|
|
|
|
|
}
|
|
}
|