UtilsTest.php 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564
  1. <?php /** @noinspection PhpUnhandledExceptionInspection */
  2. namespace App\Tests\Unit\Service\Organization;
  3. use App\Entity\Organization\Organization;
  4. use App\Entity\Organization\Parameters;
  5. use App\Entity\Organization\Settings;
  6. use App\Entity\Organization\Subdomain;
  7. use App\Enum\Organization\OrganizationIdsEnum;
  8. use App\Enum\Organization\SettingsProductEnum;
  9. use App\Repository\Network\NetworkOrganizationRepository;
  10. use App\Service\Network\Utils as NetworkUtils;
  11. use App\Service\Organization\Utils as OrganizationUtils;
  12. use App\Service\Utils\DatesUtils;
  13. use Doctrine\Common\Collections\ArrayCollection;
  14. use PHPUnit\Framework\MockObject\MockObject;
  15. use PHPUnit\Framework\TestCase;
  16. class UtilsTest extends TestCase
  17. {
  18. private MockObject | NetworkOrganizationRepository $networkOrganizationRepository;
  19. private MockObject | NetworkUtils $networkUtils;
  20. public function setUp(): void
  21. {
  22. $this->networkOrganizationRepository = $this->getMockBuilder(NetworkOrganizationRepository::class)
  23. ->disableOriginalConstructor()
  24. ->getMock();
  25. $this->networkUtils = $this->getMockBuilder(NetworkUtils::class)->disableOriginalConstructor()->getMock();
  26. }
  27. public function getOrganizationUtilsMockFor(string $methodName) {
  28. return $this->getMockBuilder(OrganizationUtils::class)
  29. ->setConstructorArgs([$this->networkOrganizationRepository, $this->networkUtils])
  30. ->setMethodsExcept([$methodName])
  31. ->getMock();
  32. }
  33. /**
  34. * @see OrganizationUtils::isStructure()
  35. */
  36. public function testIsStructure(): void
  37. {
  38. $organizationUtils = $this->getOrganizationUtilsMockFor('isStructure');
  39. $settings = $this->getMockBuilder(Settings::class)->getMock();
  40. $organization = $this->getMockBuilder(Organization::class)->getMock();
  41. $organization->method('getSettings')->willReturn($settings);
  42. // Each cal to 'isStructure' provoke 2 calls on getProduct
  43. $settings->method('getProduct')->willReturnOnConsecutiveCalls(
  44. SettingsProductEnum::ARTIST()->getValue(),
  45. SettingsProductEnum::ARTIST()->getValue(),
  46. SettingsProductEnum::ARTIST_PREMIUM()->getValue(),
  47. SettingsProductEnum::ARTIST_PREMIUM()->getValue(),
  48. SettingsProductEnum::SCHOOL()->getValue(),
  49. SettingsProductEnum::SCHOOL()->getValue(),
  50. SettingsProductEnum::SCHOOL_PREMIUM()->getValue(),
  51. SettingsProductEnum::SCHOOL_PREMIUM()->getValue(),
  52. SettingsProductEnum::MANAGER()->getValue(),
  53. SettingsProductEnum::MANAGER()->getValue(),
  54. SettingsProductEnum::MANAGER_PREMIUM()->getValue(),
  55. SettingsProductEnum::MANAGER_PREMIUM()->getValue(),
  56. );
  57. $this->assertTrue($organizationUtils->isStructure($organization));
  58. $this->assertTrue($organizationUtils->isStructure($organization));
  59. $this->assertTrue($organizationUtils->isStructure($organization));
  60. $this->assertTrue($organizationUtils->isStructure($organization));
  61. $this->assertFalse($organizationUtils->isStructure($organization));
  62. $this->assertFalse($organizationUtils->isStructure($organization));
  63. }
  64. /**
  65. * @see OrganizationUtils::isStructure()
  66. */
  67. public function testIsManager(): void
  68. {
  69. $organizationUtils = $this->getOrganizationUtilsMockFor('isManager');
  70. $settings = $this->getMockBuilder(Settings::class)->getMock();
  71. $organization = $this->getMockBuilder(Organization::class)->getMock();
  72. $organization->method('getSettings')->willReturn($settings);
  73. $settings->method('getProduct')->willReturnOnConsecutiveCalls(
  74. SettingsProductEnum::ARTIST()->getValue(),
  75. SettingsProductEnum::ARTIST_PREMIUM()->getValue(),
  76. SettingsProductEnum::SCHOOL()->getValue(),
  77. SettingsProductEnum::SCHOOL_PREMIUM()->getValue(),
  78. SettingsProductEnum::MANAGER()->getValue(),
  79. SettingsProductEnum::MANAGER_PREMIUM()->getValue(),
  80. );
  81. $this->assertFalse($organizationUtils->isManager($organization));
  82. $this->assertFalse($organizationUtils->isManager($organization));
  83. $this->assertFalse($organizationUtils->isManager($organization));
  84. $this->assertFalse($organizationUtils->isManager($organization));
  85. $this->assertTrue($organizationUtils->isManager($organization));
  86. $this->assertFalse($organizationUtils->isManager($organization));
  87. }
  88. /**
  89. * @see OrganizationUtils::is2iosOrganization()
  90. */
  91. public function testIsOrganizationIs2ios(): void
  92. {
  93. $organizationUtils = $this->getOrganizationUtilsMockFor('is2iosOrganization');
  94. $organization = $this->getMockBuilder(Organization::class)->getMock();
  95. $organizationUtils->expects(self::once())->method('isOrganizationIdEqualTo')->with($organization, OrganizationIdsEnum::_2IOS());
  96. $organizationUtils->is2iosOrganization($organization);
  97. }
  98. /**
  99. * @see OrganizationUtils::isCMF()
  100. */
  101. public function testIsCMF(): void
  102. {
  103. $organizationUtils = $this->getOrganizationUtilsMockFor('isCMF');
  104. $organization = $this->getMockBuilder(Organization::class)->getMock();
  105. $organizationUtils->expects(self::once())->method('isOrganizationIdEqualTo')->with($organization, OrganizationIdsEnum::CMF());
  106. $organizationUtils->isCMF($organization);
  107. }
  108. /**
  109. * @see OrganizationUtils::is2iosOrganization()
  110. */
  111. public function testIsOrganizationIdEqualTo(): void
  112. {
  113. $organizationUtils = $this->getOrganizationUtilsMockFor('isOrganizationIdEqualTo');
  114. $organization = $this->getMockBuilder(Organization::class)->getMock();
  115. $organization->method('getId')->willReturnOnConsecutiveCalls(123, OrganizationIdsEnum::_2IOS()->getValue());
  116. $this->assertFalse($organizationUtils->isOrganizationIdEqualTo($organization, OrganizationIdsEnum::_2IOS()));
  117. $this->assertTrue($organizationUtils->isOrganizationIdEqualTo($organization, OrganizationIdsEnum::_2IOS()));
  118. }
  119. /**
  120. * @see OrganizationUtils::getOrganizationCurrentActivityYear()
  121. */
  122. public function testGetOrganizationCurrentActivityYear(): void
  123. {
  124. $organizationUtils = $this->getOrganizationUtilsMockFor('getOrganizationCurrentActivityYear');
  125. $parameters = $this->getMockBuilder(Parameters::class)->getMock();
  126. $parameters->method('getMusicalDate')->willReturnOnConsecutiveCalls(
  127. null, // default should be '2020-08-31'
  128. new \DateTime('2020-10-01')
  129. );
  130. $organization = $this->getMockBuilder(Organization::class)->getMock();
  131. $organization->method('getParameters')->willReturn($parameters);
  132. DatesUtils::setFakeDatetime('2020-03-01');
  133. $this->assertEquals(
  134. 2019,
  135. $organizationUtils->getOrganizationCurrentActivityYear($organization)
  136. );
  137. DatesUtils::setFakeDatetime('2020-11-01');
  138. $this->assertEquals(
  139. 2020,
  140. $organizationUtils->getOrganizationCurrentActivityYear($organization)
  141. );
  142. }
  143. /**
  144. * @see OrganizationUtils::getActivityPeriodsSwitchYear()
  145. */
  146. public function testGetActivityPeriodsSwitchYear(): void
  147. {
  148. $organizationUtils = $this->getOrganizationUtilsMockFor('getActivityPeriodsSwitchYear');
  149. $parameters = $this->getMockBuilder(Parameters::class)->getMock();
  150. $parameters->method('getMusicalDate')->willReturn(new \DateTime('2020-09-05'));
  151. $organization = $this->getMockBuilder(Organization::class)->getMock();
  152. $organization->method('getParameters')->willReturn($parameters);
  153. $periods = $organizationUtils->getActivityPeriodsSwitchYear($organization, 2022);
  154. $this->assertEquals('2022-09-05', $periods['dateStart']);
  155. $this->assertEquals('2023-09-04', $periods['dateEnd']);
  156. }
  157. /**
  158. * @see OrganizationUtils::getActivityPeriodsSwitchYear()
  159. */
  160. public function testGetActivityPeriodsSwitchYearNoMusicalDate(): void
  161. {
  162. $organizationUtils = $this->getOrganizationUtilsMockFor('getActivityPeriodsSwitchYear');
  163. $parameters = $this->getMockBuilder(Parameters::class)->getMock();
  164. $parameters->method('getMusicalDate')->willReturn(null);
  165. $organization = $this->getMockBuilder(Organization::class)->getMock();
  166. $organization->method('getParameters')->willReturn($parameters);
  167. $periods = $organizationUtils->getActivityPeriodsSwitchYear($organization, 2022);
  168. $this->assertEquals('2022-09-01', $periods['dateStart']);
  169. $this->assertEquals('2023-08-31', $periods['dateEnd']);
  170. }
  171. /**
  172. * @see OrganizationUtils::getActivityYearSwitchDate()
  173. */
  174. public function testGetActivityYearSwitchDate(): void
  175. {
  176. $organizationUtils = $this->getOrganizationUtilsMockFor('getActivityYearSwitchDate');
  177. $parameters = $this->getMockBuilder(Parameters::class)->getMock();
  178. $parameters->method('getMusicalDate')->willReturn(new \DateTime('2020-09-05'));
  179. $organization = $this->getMockBuilder(Organization::class)->getMock();
  180. $organization->method('getParameters')->willReturn($parameters);
  181. $this->assertEquals(2022, $organizationUtils->getActivityYearSwitchDate($organization, new \DateTime('2022-09-10')));
  182. $this->assertEquals(2021, $organizationUtils->getActivityYearSwitchDate($organization, new \DateTime('2022-09-02')));
  183. }
  184. /**
  185. * @see OrganizationUtils::getActivityYearSwitchDate()
  186. */
  187. public function testGetActivityYearSwitchDateNoMusicalDate(): void
  188. {
  189. $organizationUtils = $this->getOrganizationUtilsMockFor('getActivityYearSwitchDate');
  190. $parameters = $this->getMockBuilder(Parameters::class)->getMock();
  191. $parameters->method('getMusicalDate')->willReturn(null);
  192. $organization = $this->getMockBuilder(Organization::class)->getMock();
  193. $organization->method('getParameters')->willReturn($parameters);
  194. $this->assertEquals(2021, $organizationUtils->getActivityYearSwitchDate($organization, new \DateTime('2022-08-01')));
  195. $this->assertEquals(2022, $organizationUtils->getActivityYearSwitchDate($organization, new \DateTime('2022-09-02')));
  196. }
  197. /**
  198. * @see OrganizationUtils::getOrganizationActiveSubdomain()
  199. */
  200. public function testGetOrganizationActiveSubdomain(): void {
  201. $organizationUtils = $this->getOrganizationUtilsMockFor('getOrganizationActiveSubdomain');
  202. $subdomain1 = $this->getMockBuilder(Subdomain::class)->getMock();
  203. $subdomain1->method('isActive')->willReturn(false);
  204. $subdomain2 = $this->getMockBuilder(Subdomain::class)->getMock();
  205. $subdomain2->method('isActive')->willReturn(false);
  206. $subdomain3 = $this->getMockBuilder(Subdomain::class)->getMock();
  207. $subdomain3->method('isActive')->willReturn(true);
  208. $subdomain3->method('getSubdomain')->willReturn('foo');
  209. $organization = $this->getMockBuilder(Organization::class)->getMock();
  210. $organization->method('getSubdomains')->willReturn(new ArrayCollection([$subdomain1, $subdomain2, $subdomain3]));
  211. $this->assertEquals('foo', $organizationUtils->getOrganizationActiveSubdomain($organization));
  212. }
  213. /**
  214. * @see OrganizationUtils::getOrganizationActiveSubdomain()
  215. */
  216. public function testGetOrganizationActiveSubdomainNone(): void {
  217. $organizationUtils = $this->getOrganizationUtilsMockFor('getOrganizationActiveSubdomain');
  218. $subdomain1 = $this->getMockBuilder(Subdomain::class)->getMock();
  219. $subdomain1->method('isActive')->willReturn(false);
  220. $organization = $this->getMockBuilder(Organization::class)->getMock();
  221. $organization->method('getSubdomains')->willReturn(new ArrayCollection([$subdomain1]));
  222. $this->assertEquals(null, $organizationUtils->getOrganizationActiveSubdomain($organization));
  223. }
  224. /**
  225. * @see OrganizationUtils::getOrganizationWebsite()
  226. */
  227. public function testOrganizationWebsite(): void
  228. {
  229. $organizationUtils = $this->getOrganizationUtilsMockFor('getOrganizationWebsite');
  230. $parameters = $this->getMockBuilder(Parameters::class)->getMock();
  231. $parameters->method('getDesactivateOpentalentSiteWeb')->willReturn(false);
  232. $parameters->method('getCustomDomain')->willReturn(null);
  233. $organization = $this->getMockBuilder(Organization::class)->getMock();
  234. $organization->method('getParameters')->willReturn($parameters);
  235. $organizationUtils->method('getOrganizationActiveSubdomain')->with($organization)->willReturn('foo');
  236. $this->assertEquals('https://foo.opentalent.fr', $organizationUtils->getOrganizationWebsite($organization));
  237. }
  238. /**
  239. * @see OrganizationUtils::getOrganizationWebsite()
  240. */
  241. public function testOrganizationWebsiteDeactivatedWithOther(): void
  242. {
  243. $organizationUtils = $this->getOrganizationUtilsMockFor('getOrganizationWebsite');
  244. $parameters = $this->getMockBuilder(Parameters::class)->getMock();
  245. $parameters->method('getDesactivateOpentalentSiteWeb')->willReturn(true);
  246. $parameters->method('getWebsite')->willReturn('foo.net');
  247. $organization = $this->getMockBuilder(Organization::class)->getMock();
  248. $organization->method('getParameters')->willReturn($parameters);
  249. $this->assertEquals('https://foo.net', $organizationUtils->getOrganizationWebsite($organization));
  250. }
  251. /**
  252. * @see OrganizationUtils::getOrganizationWebsite()
  253. */
  254. public function testOrganizationWebsiteDeactivatedNoOther(): void
  255. {
  256. $organizationUtils = $this->getOrganizationUtilsMockFor('getOrganizationWebsite');
  257. $parameters = $this->getMockBuilder(Parameters::class)->getMock();
  258. $parameters->method('getDesactivateOpentalentSiteWeb')->willReturn(true);
  259. $parameters->method('getWebsite')->willReturn(null);
  260. $organization = $this->getMockBuilder(Organization::class)->getMock();
  261. $organization->method('getParameters')->willReturn($parameters);
  262. $this->assertEquals(null, $organizationUtils->getOrganizationWebsite($organization));
  263. }
  264. /**
  265. * @see OrganizationUtils::getOrganizationWebsite()
  266. */
  267. public function testOrganizationWebsiteWithCustom(): void
  268. {
  269. $organizationUtils = $this->getOrganizationUtilsMockFor('getOrganizationWebsite');
  270. $parameters = $this->getMockBuilder(Parameters::class)->getMock();
  271. $parameters->method('getDesactivateOpentalentSiteWeb')->willReturn(false);
  272. $parameters->method('getCustomDomain')->willReturn('bar.net');
  273. $organization = $this->getMockBuilder(Organization::class)->getMock();
  274. $organization->method('getParameters')->willReturn($parameters);
  275. $this->assertEquals('https://bar.net', $organizationUtils->getOrganizationWebsite($organization));
  276. }
  277. /**
  278. * @see OrganizationUtils::getOrganizationWebsite()
  279. */
  280. public function testOrganizationWebsiteNoSubdomains(): void
  281. {
  282. $organizationUtils = $this->getOrganizationUtilsMockFor('getOrganizationWebsite');
  283. $parameters = $this->getMockBuilder(Parameters::class)->getMock();
  284. $parameters->method('getDesactivateOpentalentSiteWeb')->willReturn(false);
  285. $parameters->method('getCustomDomain')->willReturn(null);
  286. $organization = $this->getMockBuilder(Organization::class)->getMock();
  287. $organization->method('getParameters')->willReturn($parameters);
  288. $organizationUtils->method('getOrganizationActiveSubdomain')->with($organization)->willReturn(null);
  289. $this->assertEquals(null, $organizationUtils->getOrganizationWebsite($organization));
  290. }
  291. /**
  292. * @see Utils::isLastParentAndCMF()
  293. */
  294. public function testIsLastParentAndCMF(): void
  295. {
  296. $organizationUtils = $this->getOrganizationUtilsMockFor('isLastParentAndCMF');
  297. $organization1 = $this->getMockBuilder(Organization::class)->getMock();
  298. $organization2 = $this->getMockBuilder(Organization::class)->getMock();
  299. $organization3 = $this->getMockBuilder(Organization::class)->getMock();
  300. $organization4 = $this->getMockBuilder(Organization::class)->getMock();
  301. $this->networkOrganizationRepository
  302. ->method('isLastParent')
  303. ->willReturnMap([
  304. [$organization1, true],
  305. [$organization2, true],
  306. [$organization3, false],
  307. [$organization4, false],
  308. ]);
  309. $this->networkUtils
  310. ->method('isCMF')
  311. ->willReturnMap([
  312. [$organization1, true],
  313. [$organization2, false],
  314. [$organization3, true],
  315. [$organization4, false],
  316. ]);
  317. $this->assertTrue($organizationUtils->isLastParentAndCMF($organization1));
  318. $this->assertFalse($organizationUtils->isLastParentAndCMF($organization2));
  319. $this->assertFalse($organizationUtils->isLastParentAndCMF($organization3));
  320. $this->assertFalse($organizationUtils->isLastParentAndCMF($organization4));
  321. }
  322. /**
  323. * @see Utils::isStructureAndCMF()
  324. */
  325. public function testIsStructureAndCMF(): void
  326. {
  327. $organizationUtils = $this->getOrganizationUtilsMockFor('isStructureAndCMF');
  328. $organization1 = $this->getMockBuilder(Organization::class)->getMock();
  329. $organization2 = $this->getMockBuilder(Organization::class)->getMock();
  330. $organization3 = $this->getMockBuilder(Organization::class)->getMock();
  331. $organization4 = $this->getMockBuilder(Organization::class)->getMock();
  332. $organizationUtils
  333. ->method('isStructure')
  334. ->willReturnMap([
  335. [$organization1, true],
  336. [$organization2, false],
  337. [$organization3, true],
  338. [$organization4, false],
  339. ]);
  340. $this->networkUtils
  341. ->method('isCMF')
  342. ->with($organization1)
  343. ->willReturnMap([
  344. [$organization1, true],
  345. [$organization2, false],
  346. [$organization3, false],
  347. [$organization4, true],
  348. ]);
  349. $this->assertTrue($organizationUtils->isStructureAndCMF($organization1));
  350. $this->assertFalse($organizationUtils->isStructureAndCMF($organization2));
  351. $this->assertFalse($organizationUtils->isStructureAndCMF($organization3));
  352. $this->assertFalse($organizationUtils->isStructureAndCMF($organization4));
  353. }
  354. /**
  355. * @see Utils::isManagerAndCMF()
  356. */
  357. public function testIsManagerAndCMF(): void
  358. {
  359. $organizationUtils = $this->getOrganizationUtilsMockFor('isManagerAndCMF');
  360. $organization1 = $this->getMockBuilder(Organization::class)->getMock();
  361. $organization2 = $this->getMockBuilder(Organization::class)->getMock();
  362. $organization3 = $this->getMockBuilder(Organization::class)->getMock();
  363. $organization4 = $this->getMockBuilder(Organization::class)->getMock();
  364. $organizationUtils
  365. ->method('isManager')
  366. ->willReturnMap([
  367. [$organization1, true],
  368. [$organization2, false],
  369. [$organization3, true],
  370. [$organization4, false],
  371. ]);
  372. $this->networkUtils
  373. ->method('isCMF')
  374. ->willReturnMap([
  375. [$organization1, true],
  376. [$organization2, false],
  377. [$organization3, false],
  378. [$organization4, true],
  379. ]);
  380. $this->assertTrue($organizationUtils->isManagerAndCMF($organization1));
  381. $this->assertFalse($organizationUtils->isManagerAndCMF($organization2));
  382. $this->assertFalse($organizationUtils->isManagerAndCMF($organization3));
  383. $this->assertFalse($organizationUtils->isManagerAndCMF($organization4));
  384. }
  385. /**
  386. * @see Utils::isManagerAndNotLastParentAndCMF()
  387. */
  388. public function testIsManagerAndLastParentAndCMF(): void
  389. {
  390. $organizationUtils = $this->getOrganizationUtilsMockFor('isManagerAndLastParentAndCMF');
  391. $organization1 = $this->getMockBuilder(Organization::class)->getMock();
  392. $organization2 = $this->getMockBuilder(Organization::class)->getMock();
  393. $organization3 = $this->getMockBuilder(Organization::class)->getMock();
  394. $organization4 = $this->getMockBuilder(Organization::class)->getMock();
  395. $organizationUtils
  396. ->method('isManager')
  397. ->willReturnMap([
  398. [$organization1, true],
  399. [$organization2, false],
  400. [$organization3, true],
  401. [$organization4, false],
  402. ]);
  403. $organizationUtils
  404. ->method('isLastParentAndCMF')
  405. ->willReturnMap([
  406. [$organization1, true],
  407. [$organization2, false],
  408. [$organization3, false],
  409. [$organization4, true],
  410. ]);
  411. $this->assertTrue($organizationUtils->isManagerAndLastParentAndCMF($organization1));
  412. $this->assertFalse($organizationUtils->isManagerAndLastParentAndCMF($organization2));
  413. $this->assertFalse($organizationUtils->isManagerAndLastParentAndCMF($organization3));
  414. $this->assertFalse($organizationUtils->isManagerAndLastParentAndCMF($organization4));
  415. }
  416. /**
  417. * @see Utils::isManagerAndNotLastParentAndCMF()
  418. */
  419. public function testIsManagerAndNotLastParentAndCMF(): void
  420. {
  421. $organizationUtils = $this->getOrganizationUtilsMockFor('isManagerAndNotLastParentAndCMF');
  422. $organization1 = $this->getMockBuilder(Organization::class)->getMock();
  423. $organization2 = $this->getMockBuilder(Organization::class)->getMock();
  424. $organization3 = $this->getMockBuilder(Organization::class)->getMock();
  425. $organization4 = $this->getMockBuilder(Organization::class)->getMock();
  426. $organizationUtils
  427. ->method('isManager')
  428. ->willReturnMap([
  429. [$organization1, true],
  430. [$organization2, false],
  431. [$organization3, true],
  432. [$organization4, true],
  433. ]);
  434. $this->networkOrganizationRepository
  435. ->method('isLastParent')
  436. ->willReturnMap([
  437. [$organization1, false],
  438. [$organization2, false],
  439. [$organization3, true],
  440. [$organization4, false],
  441. ]);
  442. $this->networkUtils
  443. ->method('isCMF')
  444. ->willReturnMap([
  445. [$organization1, true],
  446. [$organization2, true],
  447. [$organization3, true],
  448. [$organization4, false],
  449. ]);
  450. $this->assertTrue($organizationUtils->isManagerAndNotLastParentAndCMF($organization1));
  451. $this->assertFalse($organizationUtils->isManagerAndNotLastParentAndCMF($organization2));
  452. $this->assertFalse($organizationUtils->isManagerAndNotLastParentAndCMF($organization3));
  453. $this->assertFalse($organizationUtils->isManagerAndNotLastParentAndCMF($organization4));
  454. }
  455. }