diff --git a/src/OroCRM/Bundle/AnalyticsBundle/Tests/Functional/Model/RFMMetricStateManagerTest.php b/src/OroCRM/Bundle/AnalyticsBundle/Tests/Functional/Model/RFMMetricStateManagerTest.php index 03923595c4e..d76c737c76d 100644 --- a/src/OroCRM/Bundle/AnalyticsBundle/Tests/Functional/Model/RFMMetricStateManagerTest.php +++ b/src/OroCRM/Bundle/AnalyticsBundle/Tests/Functional/Model/RFMMetricStateManagerTest.php @@ -39,6 +39,8 @@ public function tearDown() } $em->flush($entities); + + parent::tearDown(); } public function testResetChannelMetrics() diff --git a/src/OroCRM/Bundle/CampaignBundle/Model/EmailCampaignStatisticsConnector.php b/src/OroCRM/Bundle/CampaignBundle/Model/EmailCampaignStatisticsConnector.php index 89a467644bf..4ae3954480d 100644 --- a/src/OroCRM/Bundle/CampaignBundle/Model/EmailCampaignStatisticsConnector.php +++ b/src/OroCRM/Bundle/CampaignBundle/Model/EmailCampaignStatisticsConnector.php @@ -59,8 +59,12 @@ public function getStatisticsRecord(EmailCampaign $emailCampaign, $entity) ->getMarketingListItem($marketingList, $entityId); $manager = $this->doctrineHelper->getEntityManager($this->entityName); - $statisticsRecord = $manager->getRepository($this->entityName) - ->findOneBy(['emailCampaign' => $emailCampaign, 'marketingListItem' => $marketingListItem]); + + $statisticsRecord = null; + if ($marketingListItem->getId() !== null) { + $statisticsRecord = $manager->getRepository($this->entityName) + ->findOneBy(['emailCampaign' => $emailCampaign, 'marketingListItem' => $marketingListItem]); + } if (!$statisticsRecord) { $statisticsRecord = new EmailCampaignStatistics(); diff --git a/src/OroCRM/Bundle/CampaignBundle/Tests/Unit/Model/EmailCampaignStatisticsConnectorTest.php b/src/OroCRM/Bundle/CampaignBundle/Tests/Unit/Model/EmailCampaignStatisticsConnectorTest.php index 276d339892b..9c869059440 100644 --- a/src/OroCRM/Bundle/CampaignBundle/Tests/Unit/Model/EmailCampaignStatisticsConnectorTest.php +++ b/src/OroCRM/Bundle/CampaignBundle/Tests/Unit/Model/EmailCampaignStatisticsConnectorTest.php @@ -67,6 +67,9 @@ public function testGetStatisticsRecordExisting($existing) $marketingListItem = $this->getMockBuilder('OroCRM\Bundle\MarketingListBundle\Entity\MarketingListItem') ->disableOriginalConstructor() ->getMock(); + $marketingListItem->expects($this->any()) + ->method('getId') + ->willReturn(42); $this->marketingListItemConnector->expects($this->once()) ->method('getMarketingListItem') diff --git a/src/OroCRM/Bundle/ContactBundle/Tests/Functional/ImportExportTest.php b/src/OroCRM/Bundle/ContactBundle/Tests/Functional/ImportExportTest.php index 2291628db4e..da49ae4d174 100644 --- a/src/OroCRM/Bundle/ContactBundle/Tests/Functional/ImportExportTest.php +++ b/src/OroCRM/Bundle/ContactBundle/Tests/Functional/ImportExportTest.php @@ -34,6 +34,8 @@ protected function tearDown() $batchJobManager->createQuery('DELETE AkeneoBatchBundle:JobInstance')->execute(); $batchJobManager->createQuery('DELETE AkeneoBatchBundle:JobExecution')->execute(); $batchJobManager->createQuery('DELETE AkeneoBatchBundle:StepExecution')->execute(); + + parent::tearDown(); } /** diff --git a/src/OroCRM/Bundle/MagentoBundle/Tests/Functional/Controller/NewsletterSubscriberControllerTest.php b/src/OroCRM/Bundle/MagentoBundle/Tests/Functional/Controller/NewsletterSubscriberControllerTest.php index 42dc69bfd8c..22af0bb96bb 100644 --- a/src/OroCRM/Bundle/MagentoBundle/Tests/Functional/Controller/NewsletterSubscriberControllerTest.php +++ b/src/OroCRM/Bundle/MagentoBundle/Tests/Functional/Controller/NewsletterSubscriberControllerTest.php @@ -2,6 +2,8 @@ namespace OroCRM\Bundle\MagentoBundle\Tests\Functional\Controller; +use Doctrine\ORM\EntityManager; + use Oro\Bundle\ImportExportBundle\Job\JobExecutor; use Oro\Bundle\ImportExportBundle\Job\JobResult; use OroCRM\Bundle\MagentoBundle\Entity\NewsletterSubscriber; @@ -66,6 +68,11 @@ protected function tearDown() $this->getContainer()->set('oro_importexport.job_executor', $this->baseJobExecutor); unset($this->transport, $this->baseJobExecutor); + + $entityManager = $this->getContainer()->get('akeneo_batch.job_repository')->getJobManager(); + $entityManager->getConnection()->close(); + + parent::tearDown(); } /** diff --git a/src/OroCRM/Bundle/MagentoBundle/Tests/Functional/ImportExport/Writer/AbstractExportWriterTest.php b/src/OroCRM/Bundle/MagentoBundle/Tests/Functional/ImportExport/Writer/AbstractExportWriterTest.php index 5ea2584f015..85cb6b01346 100644 --- a/src/OroCRM/Bundle/MagentoBundle/Tests/Functional/ImportExport/Writer/AbstractExportWriterTest.php +++ b/src/OroCRM/Bundle/MagentoBundle/Tests/Functional/ImportExport/Writer/AbstractExportWriterTest.php @@ -4,6 +4,7 @@ use Akeneo\Bundle\BatchBundle\Entity\JobExecution; +use Doctrine\ORM\EntityManager; use Oro\Bundle\TestFrameworkBundle\Test\WebTestCase; use OroCRM\Bundle\MagentoBundle\Provider\Transport\MagentoTransportInterface; @@ -30,6 +31,9 @@ protected function setUp() protected function tearDown() { $this->dropBatchJobs(); + $this->closeConnections(); + + parent::tearDown(); } protected function dropBatchJobs() @@ -43,6 +47,14 @@ protected function dropBatchJobs() unset($this->transport); } + protected function closeConnections() + { + $entityManager = $this->getContainer()->get('akeneo_batch.job_repository')->getJobManager(); + $entityManager + ->getConnection() + ->close(); + } + /** * @param string $alias * @param string $status