organization = new Organization(); $this->moduleMock = $this->getMockBuilder(Module::class)->disableOriginalConstructor()->getMock(); $this->moduleMock ->method('getOrganizationModules') ->with($this->organization) ->willReturn(["MODULE_A", "MODULE_B"]); $this->treeMock = $this->getMockBuilder(Tree::class)->disableOriginalConstructor()->getMock(); $parent = new Organization(); $parent->setName('Parent'); $parent->setParameters(new Parameters()); $this->treeMock ->method('findAllParentsAndSortByType') ->with($this->organization) ->willReturn([$parent, $parent]); $organizationUtils = new \App\Service\Organization\Utils(); $this->organizationProfileCreator = new OrganizationProfileCreator($this->moduleMock,$this->treeMock, $organizationUtils); $this->organization->setPrincipalType(PrincipalTypeEnum::ARTISTIC_EDUCATION_ONLY()); $settings = new Settings(); $settings->setProduct('adminassos'); $parameters = new Parameters(); $parameters->setShowAdherentList(true); $subdomain = new Subdomain(); $this->organization ->setParameters($parameters) ->setSettings($settings) ->addSubdomain($subdomain) ->setName('Foo') ; } /** * @see OrganizationProfileCreator::createCompleteOrganizationProfile() */ public function testCreateCompleteOrganizationProfile(){ $organizationProfile = $this->organizationProfileCreator->createCompleteOrganizationProfile($this->organization); $this->assertInstanceOf(OrganizationProfile::class, $organizationProfile); } public function testCreateOrganizationProfileWithoutAdherentListBecauseOfPrincipalType(){ $organizationProfile = $this->organizationProfileCreator->createCompleteOrganizationProfile($this->organization); $this->assertFalse($organizationProfile->getShowAdherentList()); } public function testCreateOrganizationProfileWithoutAdherentList(){ $this->organization->setPrincipalType(PrincipalTypeEnum::ARTISTIC_PRACTICE_ONLY()); $this->organization->getParameters()->setShowAdherentList(false); $organizationProfile = $this->organizationProfileCreator->createCompleteOrganizationProfile($this->organization); $this->assertFalse($organizationProfile->getShowAdherentList()); } public function testCreateOrganizationProfileWithAdherentList(){ $this->organization->setPrincipalType(PrincipalTypeEnum::ARTISTIC_PRACTICE_ONLY()); $organizationProfile = $this->organizationProfileCreator->createCompleteOrganizationProfile($this->organization); $this->assertTrue($organizationProfile->getShowAdherentList()); } }