Initial commit: CloudOps infrastructure platform
This commit is contained in:
@@ -0,0 +1,67 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Mautic\PluginBundle\Tests\Entity;
|
||||
|
||||
use Mautic\CoreBundle\Test\MauticMysqlTestCase;
|
||||
use Mautic\PluginBundle\Entity\IntegrationEntityRepository;
|
||||
use PHPUnit\Framework\Assert;
|
||||
|
||||
/**
|
||||
* IntegrationRepository.
|
||||
*/
|
||||
class IntegrationEntityRepositoryTest extends MauticMysqlTestCase
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $prefix;
|
||||
|
||||
/**
|
||||
* @var IntegrationEntityRepository
|
||||
*/
|
||||
private $integrationEntityRepository;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
$this->prefix = static::getContainer()->getParameter('mautic.db_table_prefix');
|
||||
$this->integrationEntityRepository = $this->em->getRepository(\Mautic\PluginBundle\Entity\IntegrationEntity::class);
|
||||
}
|
||||
|
||||
public function testThatGetIntegrationsEntityIdReturnsCorrectValues(): void
|
||||
{
|
||||
$now = new \DateTimeImmutable();
|
||||
$integrationEntityId = random_int(1, 1000);
|
||||
$internalEntityId = random_int(1, 1000);
|
||||
|
||||
$this->connection->insert($this->prefix.'integration_entity', [
|
||||
'date_added' => $now->format('Y-m-d H:i:s'),
|
||||
'integration' => 'someIntegration',
|
||||
'integration_entity' => 'someIntegrationEntity',
|
||||
'integration_entity_id' => $integrationEntityId,
|
||||
'internal_entity' => 'someInternalEntity',
|
||||
'internal_entity_id' => $internalEntityId,
|
||||
'last_sync_date' => null,
|
||||
'internal' => 'someInternalValue',
|
||||
]);
|
||||
|
||||
$results = $this->integrationEntityRepository->getIntegrationsEntityId(
|
||||
'someIntegration',
|
||||
'someIntegrationEntity',
|
||||
'someInternalEntity',
|
||||
[$internalEntityId],
|
||||
null,
|
||||
null,
|
||||
false,
|
||||
0,
|
||||
0,
|
||||
null
|
||||
);
|
||||
|
||||
Assert::assertCount(1, $results);
|
||||
Assert::assertSame($integrationEntityId, (int) $results[0]['integration_entity_id']);
|
||||
Assert::assertSame($internalEntityId, (int) $results[0]['internal_entity_id']);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
namespace Mautic\PluginBundle\Tests\Entity;
|
||||
|
||||
use Mautic\PluginBundle\Entity\Plugin;
|
||||
|
||||
class PluginTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
public function testEmptyDescription(): void
|
||||
{
|
||||
$plugin = new Plugin();
|
||||
$this->assertNull($plugin->getDescription());
|
||||
$this->assertNull($plugin->getPrimaryDescription());
|
||||
$this->assertNull($plugin->getSecondaryDescription());
|
||||
$this->assertFalse($plugin->hasSecondaryDescription());
|
||||
}
|
||||
|
||||
public function testSimpleDescription(): void
|
||||
{
|
||||
$description = 'This is the best plugin in the whole galaxy';
|
||||
$plugin = new Plugin();
|
||||
$plugin->setDescription($description);
|
||||
$this->assertEquals($description, $plugin->getDescription());
|
||||
$this->assertEquals($description, $plugin->getPrimaryDescription());
|
||||
$this->assertNull($plugin->getSecondaryDescription());
|
||||
$this->assertFalse($plugin->hasSecondaryDescription());
|
||||
}
|
||||
|
||||
public function testSecondaryDescriptionWithUnixLineEnding(): void
|
||||
{
|
||||
$description = "This is the best plugin in the whole galaxy\n---\nLearn more about it <a href=\"#\">here</a>";
|
||||
$plugin = new Plugin();
|
||||
$plugin->setDescription($description);
|
||||
$this->assertEquals($description, $plugin->getDescription());
|
||||
$this->assertEquals('This is the best plugin in the whole galaxy', $plugin->getPrimaryDescription());
|
||||
$this->assertEquals('Learn more about it <a href="#">here</a>', $plugin->getSecondaryDescription());
|
||||
$this->assertTrue($plugin->hasSecondaryDescription());
|
||||
}
|
||||
|
||||
public function testSecondaryDescriptionWithWinLineEnding(): void
|
||||
{
|
||||
$description = "This is the best plugin in the whole galaxy\n\r---\n\rLearn more about it <a href=\"#\">here</a>";
|
||||
$plugin = new Plugin();
|
||||
$plugin->setDescription($description);
|
||||
$this->assertEquals($description, $plugin->getDescription());
|
||||
$this->assertEquals('This is the best plugin in the whole galaxy', $plugin->getPrimaryDescription());
|
||||
$this->assertEquals('Learn more about it <a href="#">here</a>', $plugin->getSecondaryDescription());
|
||||
$this->assertTrue($plugin->hasSecondaryDescription());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user