|
|
@@ -5,6 +5,7 @@ use App\Entity\Organization\Organization;
|
|
|
use App\Entity\Organization\Settings;
|
|
|
use App\Service\Utils\Parser;
|
|
|
use App\Service\Utils\Reflection;
|
|
|
+use Doctrine\Common\Collections\ArrayCollection;
|
|
|
use PHPUnit\Framework\TestCase;
|
|
|
use App\Service\Security\Module;
|
|
|
|
|
|
@@ -18,7 +19,30 @@ class ModuleTest extends TestCase
|
|
|
public function setUp():void
|
|
|
{
|
|
|
$this->reflectionMock = $this->getMockBuilder(Reflection::class)->disableOriginalConstructor()->getMock();
|
|
|
- $this->parser= new Parser();
|
|
|
+ $this->parser = new Parser();
|
|
|
+ }
|
|
|
+
|
|
|
+ public function testGetOrganizationModules() {
|
|
|
+ $module = $this->getMockBuilder(Module::class)
|
|
|
+ ->onlyMethods(['getModuleBySettings', 'getModulesByConditions', 'getModulesByProductConfiguration'])
|
|
|
+ ->disableOriginalConstructor()
|
|
|
+ ->getMock();
|
|
|
+
|
|
|
+ $module->expects(self::once())->method('getModuleBySettings')->willReturn(['Sms']);
|
|
|
+ $module->expects(self::once())->method('getModulesByConditions')->willReturn(['CotisationCall']);
|
|
|
+
|
|
|
+ $settings = $this->getMockBuilder(Settings::class)->disableOriginalConstructor()->getMock();
|
|
|
+ $settings->expects(self::once())->method('getProduct')->willReturn('school');
|
|
|
+
|
|
|
+ $organization = $this->getMockBuilder(Organization::class)->disableOriginalConstructor()->getMock();
|
|
|
+ $organization->expects(self::once())->method('getSettings')->willReturn($settings);
|
|
|
+
|
|
|
+ $module->expects(self::once())->method('getModulesByProductConfiguration')->willReturn(['Notification']);
|
|
|
+
|
|
|
+ $this->assertEqualsCanonicalizing(
|
|
|
+ ['Sms', 'CotisationCall', 'Notification'],
|
|
|
+ $module->getOrganizationModules($organization)
|
|
|
+ );
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -76,4 +100,4 @@ class ModuleTest extends TestCase
|
|
|
// assert function to test whether 'value' is a value of array
|
|
|
$this->assertContains($value, $module->getModulesByProductConfiguration('artist-premium')) ;
|
|
|
}
|
|
|
-}
|
|
|
+}
|