| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970 |
- <?php
- namespace App\Test\Service\Security;
- use App\Entity\Organization\Organization;
- use App\Entity\Organization\Settings;
- use App\Service\Utils\Reflection;
- use PHPUnit\Framework\TestCase;
- use App\Service\Security\Module;
- class ModuleTest extends TestCase
- {
- private $reflectionMock;
- public function setUp():void
- {
- $this->reflectionMock = $this->getMockBuilder(Reflection::class)->disableOriginalConstructor()->getMock();
- }
- /**
- * @see Module::getModuleBySettings()
- */
- public function testGetModuleBySettings(){
- $settingsMock = $this->getMockBuilder(Settings::class)->getMock();
- $settingsMock
- ->expects($this->once())
- ->method('getModules')
- ->willReturn(["Sms" => true]);
- $organizationMock = $this->getMockBuilder(Organization::class)->getMock();
- $organizationMock
- ->expects($this->once())
- ->method('getSettings')
- ->willReturn($settingsMock);
- $module = new Module($this->reflectionMock);
- $value = "Sms";
- // assert function to test whether 'value' is a value of array
- $this->assertContains($value, $module->getModuleBySettings($organizationMock)) ;
- }
- /**
- * @see Module::getModulesByConditions()
- */
- public function testGetModulesByConditions()
- {
- $organizationMock = $this->getMockBuilder(Organization::class)->getMock();
- $this->reflectionMock
- ->method('dynamicInvokeWithArgsServiceMethod')
- ->with('opentalent.network.utils', 'isCMF', array($organizationMock))
- ->willReturn(true);
- $module = new Module($this->reflectionMock);
- $value = "Network";
- // assert function to test whether 'value' is a value of array
- $this->assertContains($value, $module->getModulesByConditions($organizationMock)) ;
- }
- /**
- * @see Module::getModulesByProductConfiguration()
- */
- public function testGetModulesByProductConfiguration()
- {
- $module = new Module($this->reflectionMock);
- $value = "MessagesAdvanced";
- // assert function to test whether 'value' is a value of array
- $this->assertContains($value, $module->getModulesByProductConfiguration('artist-premium')) ;
- }
- }
|