networkOrganizationRepositoryMock = $this ->getMockBuilder(NetworkOrganizationRepository::class) ->disableOriginalConstructor() ->getMock(); $this->networkUtilsMock = $this ->getMockBuilder(NetworkUtils::class) ->disableOriginalConstructor() ->getMock(); $this->organizationUtilsMock = $this ->getMockBuilder(OrganizationUtils::class) ->getMock(); } /** * @see Utils::isLastParentAndCMF() */ public function testIsLastParentAndCMF(): void { $organizationMock = $this->getMockBuilder(Organization::class)->getMock(); $organizationMock ->method('getId') ->willReturn(1); $this->networkOrganizationRepositoryMock ->expects($this->once()) ->method('isLastParent') ->with($organizationMock) ->willReturn(true); $this->networkUtilsMock ->expects($this->once()) ->method('isCMF') ->with($organizationMock) ->willReturn(true); $utils = new Utils($this->networkUtilsMock, $this->organizationUtilsMock, $this->networkOrganizationRepositoryMock); $this->assertTrue($utils->isLastParentAndCMF($organizationMock)); } /** * @see Utils::isLastParentAndCMF() */ public function testIsNotLastParentAndCMF(): void { $organizationMock = $this->getMockBuilder(Organization::class)->getMock(); $organizationMock ->method('getId') ->willReturn(1); $this->networkOrganizationRepositoryMock ->expects($this->once()) ->method('isLastParent') ->with($organizationMock) ->willReturn(false); $this->networkUtilsMock ->expects($this->never()) ->method('isCMF'); $utils = new Utils($this->networkUtilsMock, $this->organizationUtilsMock, $this->networkOrganizationRepositoryMock); $this->assertFalse($utils->isLastParentAndCMF($organizationMock)); } /** * @see Utils::isStructureAndCMF() */ 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); $utils = new Utils($this->networkUtilsMock, $this->organizationUtilsMock, $this->networkOrganizationRepositoryMock); $this->assertTrue($utils->isStructureAndCMF($organizationMock)); } /** * @see Utils::isStructureAndCMF() */ public function testIsNotStructureAndCMF(): void { $organizationMock = $this->getMockBuilder(Organization::class)->getMock(); $this->organizationUtilsMock ->expects($this->once()) ->method('isStructure') ->with($organizationMock) ->willReturn(false); $this->networkUtilsMock ->expects($this->never()) ->method('isCMF'); $utils = new Utils($this->networkUtilsMock, $this->organizationUtilsMock, $this->networkOrganizationRepositoryMock); $this->assertFalse($utils->isStructureAndCMF($organizationMock)); } /** * @see Utils::isManagerAndCMF() */ public function testIsManagerAndCMF(): void { $organizationMock = $this->getMockBuilder(Organization::class)->getMock(); $this->organizationUtilsMock ->expects($this->once()) ->method('isManager') ->with($organizationMock) ->willReturn(true); $this->networkUtilsMock ->expects($this->once()) ->method('isCMF') ->with($organizationMock) ->willReturn(true); $utils = new Utils($this->networkUtilsMock, $this->organizationUtilsMock, $this->networkOrganizationRepositoryMock); $this->assertTrue($utils->isManagerAndCMF($organizationMock)); } /** * @see Utils::isManagerAndCMF() */ public function testIsNotManagerAndCMF(): void { $organizationMock = $this->getMockBuilder(Organization::class)->getMock(); $this->organizationUtilsMock ->expects($this->once()) ->method('isManager') ->with($organizationMock) ->willReturn(false); $this->networkUtilsMock ->expects($this->never()) ->method('isCMF'); $utils = new Utils($this->networkUtilsMock, $this->organizationUtilsMock, $this->networkOrganizationRepositoryMock); $this->assertFalse($utils->isManagerAndCMF($organizationMock)); } /** * @see Utils::isManagerAndNotLastParentAndCMF() */ public function testIsManagerAndNotLastParentAndCMF(): void { $organizationMock = $this->getMockBuilder(Organization::class)->getMock(); $organizationMock ->method('getId') ->willReturn(1); $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 = new Utils($this->networkUtilsMock, $this->organizationUtilsMock, $this->networkOrganizationRepositoryMock); $this->assertTrue($utils->isManagerAndNotLastParentAndCMF($organizationMock)); } /** * @see Utils::isManagerAndLastParentAndCMF() */ public function testIsManagerAndLastParentAndCMF(): void { $organizationMock = $this->getMockBuilder(Organization::class)->getMock(); $organizationMock ->method('getId') ->willReturn(1); $this->organizationUtilsMock ->expects($this->once()) ->method('isManager') ->with($organizationMock) ->willReturn(true); $this->networkOrganizationRepositoryMock ->expects($this->once()) ->method('isLastParent') ->with($organizationMock) ->willReturn(true); $this->networkUtilsMock ->expects($this->once()) ->method('isCMF') ->willReturn(true); $utils = new Utils($this->networkUtilsMock, $this->organizationUtilsMock, $this->networkOrganizationRepositoryMock); $this->assertTrue($utils->isManagerAndLastParentAndCMF($organizationMock)); } }