-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added new test case and updated existing one
- Loading branch information
1 parent
504c3a5
commit 0b0a998
Showing
5 changed files
with
219 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace MauticPlugin\LeuchtfeuerGoToBundle\Tests; | ||
|
||
use Mautic\LeadBundle\Entity\Lead; | ||
use Mautic\LeadBundle\Entity\LeadList; | ||
use Mautic\PluginBundle\Entity\Integration; | ||
use Mautic\PluginBundle\Entity\Plugin; | ||
use Mautic\PluginBundle\Helper\IntegrationHelper; | ||
|
||
trait CreateEntities | ||
{ | ||
protected function createSegment($listConfig): LeadList | ||
{ | ||
$list = new LeadList(); | ||
$list->setName($listConfig['name']); | ||
$list->setPublicName($listConfig['name']); | ||
$list->setAlias($listConfig['alias']); | ||
$list->setIsGlobal($listConfig['public']); | ||
$list->setFilters($listConfig['filters']); | ||
|
||
$this->em->persist($list); | ||
|
||
return $list; | ||
} | ||
|
||
protected function createIntegration(): void | ||
{ | ||
$plugin = new Plugin(); | ||
$plugin->setName('GoTo Integration by Leuchtfeuer'); | ||
$plugin->setDescription('Enables integration with Mautic supported GoTo collaboration products.'); | ||
$plugin->setBundle('LeuchtfeuerGoToBundle'); | ||
$plugin->setVersion('1.0'); | ||
$plugin->setAuthor('Mautic'); | ||
|
||
$this->em->persist($plugin); | ||
|
||
$webinar = new Integration(); | ||
$webinar->setIsPublished(true); | ||
$webinar->setApiKeys([ | ||
'app_name' => 'Mautic', | ||
'client_id' => 'client_id', | ||
'client_secret' => 'client_secret', | ||
]); | ||
$webinar->setPlugin($plugin); | ||
$webinar->setName('GoTo Integration by Leuchtfeuer'); | ||
|
||
$this->em->persist($webinar); | ||
$this->em->flush(); | ||
|
||
/** @var IntegrationHelper $integrationHelper */ | ||
$integrationHelper = self::$container->get('mautic.helper.integration'); | ||
|
||
/** @var Integration $integration */ | ||
$integrationObject = $integrationHelper->getIntegrationObject('Gotowebinar'); | ||
|
||
$integrationObject->encryptAndSetApiKeys([ | ||
'app_name' => 'Mautic', | ||
'client_id' => 'client_id', | ||
'client_secret' => 'client_secret', | ||
], $webinar); | ||
|
||
$integrationObject->getIntegrationSettings()->setIsPublished(true); | ||
|
||
$this->em->flush(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace MauticPlugin\LeuchtfeuerGoToBundle\Tests\Functional; | ||
|
||
use Mautic\CoreBundle\Test\MauticMysqlTestCase; | ||
use Mautic\UserBundle\DataFixtures\ORM\LoadRoleData; | ||
use Mautic\UserBundle\DataFixtures\ORM\LoadUserData; | ||
use MauticPlugin\LeuchtfeuerGoToBundle\Tests\CreateEntities; | ||
use MauticPlugin\LeuchtfeuerGoToBundle\Tests\DataFixtures\ORM\LoadCitrixData; | ||
|
||
class GotoSegmentFilterFunctionalTest extends MauticMysqlTestCase | ||
{ | ||
use CreateEntities; | ||
|
||
protected function setUp(): void | ||
{ | ||
parent::setUp(); | ||
|
||
$this->fixtures = $this->loadFixtures( | ||
[ | ||
LoadRoleData::class, | ||
LoadUserData::class, | ||
LoadCitrixData::class | ||
], | ||
false | ||
)->getReferenceRepository(); | ||
|
||
$this->createIntegration(); | ||
} | ||
|
||
protected function beforeBeginTransaction(): void | ||
{ | ||
$this->resetAutoincrement( | ||
[ | ||
'leads', | ||
'lead_lists', | ||
'users', | ||
] | ||
); | ||
} | ||
|
||
public function testGotoSegments(): void | ||
{ | ||
// Create Segment with filters | ||
$segment = $this->createSegment([ | ||
'name' => 'Goto: Webinar Registration', | ||
'alias' => 'goto-webinar-registration', | ||
'public' => true, | ||
'filters' => [ | ||
[ | ||
'glue' => 'and', | ||
'type' => 'email', | ||
'object' => 'lead', | ||
'field' => 'webinar-registration', | ||
'operator' => 'including', | ||
'properties' => ['filter' => 'Any Webinar', 'display' => null], | ||
], | ||
], | ||
]); | ||
|
||
$this->em->flush(); | ||
$this->em->clear(); | ||
|
||
// Build segments | ||
$command = $this->testSymfonyCommand( | ||
'mautic:segments:update', | ||
[ | ||
'-i' => $segment->getId(), | ||
'--env' => 'test', | ||
] | ||
); | ||
|
||
$output = $command->getDisplay(); | ||
$this->assertEquals(0, $command->getStatusCode()); | ||
$this->assertStringContainsString('1 total contact(s) to be added in batches of 300', $output); | ||
$this->assertStringContainsString('1 contact(s) affected', $output); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters