| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950 |
- <?php
- namespace App\Test\Service\Organization;
- use App\ApiResources\Profile\OrganizationProfile;
- use App\Entity\Organization\Organization;
- use App\Entity\Organization\Parameters;
- use App\Entity\Organization\Settings;
- use App\Service\Network\Tree;
- use App\Service\Organization\OrganizationProfileCreator;
- use App\Service\Security\Module;
- use PHPUnit\Framework\TestCase;
- class OrganizationProfileCreatorTest extends TestCase
- {
- private Organization $organization;
- public function setUp():void
- {
- $this->organization = new Organization();
- $this->organization
- ->setParameters(new Parameters())
- ->setSettings(new Settings())
- ->setName('Foo')
- ;
- }
- /**
- * @see OrganizationProfileCreator::getOrganizationProfile()
- */
- public function testGetOrganizationProfile(){
- $moduleMock = $this->getMockBuilder(Module::class)->disableOriginalConstructor()->getMock();
- $moduleMock
- ->method('getOrganizationModules')
- ->with($this->organization)
- ->willReturn(["MODULE_A", "MODULE_B"]);
- $treeMock = $this->getMockBuilder(Tree::class)->disableOriginalConstructor()->getMock();
- $parent = new Organization();
- $parent->setParameters(new Parameters());
- $treeMock
- ->method('findAllParentsAndSortByType')
- ->with($this->organization)
- ->willReturn([$parent, $parent]);
- $organizationProfileCreator = new OrganizationProfileCreator($moduleMock,$treeMock);
- $organizationProfile = $organizationProfileCreator->getOrganizationProfile($this->organization);
- $this->assertInstanceOf(OrganizationProfile::class, $organizationProfile);
- }
- }
|