reflectionMock = $this->getMockBuilder(Reflection::class)->disableOriginalConstructor()->getMock(); $this->parser= new Parser(); } /** * @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, $this->parser, self::OPENTALENT_CONFIG); $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('dynamicInvokeServiceWithArgsAndMethod') ->withConsecutive( ['App\\Service\\Cotisation\\Utils', 'isLastParentAndCMF', array($organizationMock)] ) ->willReturnOnConsecutiveCalls( [true] ) ; $module = new Module($this->reflectionMock, $this->parser, self::OPENTALENT_CONFIG); $value = "CotisationCall"; // 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, $this->parser, self::OPENTALENT_CONFIG); $value = "MessagesAdvanced"; // assert function to test whether 'value' is a value of array $this->assertContains($value, $module->getModulesByProductConfiguration('artist-premium')) ; } }