-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
SUPESC-558 Fixed memory leak during repository synchronization export…
…. (#9417) SUPESC-558 Fixed memory leak during repository synchronization export.
- Loading branch information
Showing
6 changed files
with
156 additions
and
10 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
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
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
80 changes: 80 additions & 0 deletions
80
tests/SprykerTest/Zed/Synchronization/Business/Export/RepositoryExporterTest.php
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 | ||
|
||
/** | ||
* Copyright © 2016-present Spryker Systems GmbH. All rights reserved. | ||
* Use of this software requires acceptance of the Evaluation License Agreement. See LICENSE file. | ||
*/ | ||
|
||
namespace SprykerTest\Zed\Synchronization\Business\Export; | ||
|
||
use Codeception\Test\Unit; | ||
use Spryker\Zed\Synchronization\Business\Export\ExporterInterface; | ||
use Spryker\Zed\Synchronization\Business\Export\RepositoryExporter; | ||
use Spryker\Zed\Synchronization\Business\Message\QueueMessageCreatorInterface; | ||
use Spryker\Zed\Synchronization\Dependency\Client\SynchronizationToQueueClientInterface; | ||
use Spryker\Zed\Synchronization\Dependency\Service\SynchronizationToUtilEncodingServiceInterface; | ||
use Spryker\Zed\Synchronization\SynchronizationConfig; | ||
|
||
/** | ||
* Auto-generated group annotations | ||
* | ||
* @group SprykerTest | ||
* @group Zed | ||
* @group Synchronization | ||
* @group Business | ||
* @group Export | ||
* @group RepositoryExporterTest | ||
* Add your own group annotations below this line | ||
*/ | ||
class RepositoryExporterTest extends Unit | ||
{ | ||
/** | ||
* @return void | ||
*/ | ||
public function testExportSynchronizedDataWillNotDisablePoolingWithDisableInstantPoolingParamFalse(): void | ||
{ | ||
// Arrange | ||
$repositoryExporterMock = $this->createRepositoryExporterMock(false); | ||
$repositoryExporterMock->expects($this->never())->method('disableInstancePooling'); | ||
$repositoryExporterMock->expects($this->never())->method('enableInstancePooling'); | ||
|
||
// Act, Assert | ||
$repositoryExporterMock->exportSynchronizedData([], []); | ||
} | ||
|
||
/** | ||
* @return void | ||
*/ | ||
public function testExportSynchronizedDataWillDisablePoolingWithDisableInstantPoolingParamTrue(): void | ||
{ | ||
// Arrange | ||
$repositoryExporterMock = $this->createRepositoryExporterMock(true); | ||
$repositoryExporterMock->expects($this->once())->method('disableInstancePooling')->willReturn(true); | ||
$repositoryExporterMock->expects($this->once())->method('enableInstancePooling'); | ||
|
||
// Act, Assert | ||
$repositoryExporterMock->exportSynchronizedData([], []); | ||
} | ||
|
||
/** | ||
* @param bool $disablePropelInstancePool | ||
* | ||
* @return \Spryker\Zed\Synchronization\Business\Export\ExporterInterface | ||
*/ | ||
protected function createRepositoryExporterMock(bool $disablePropelInstancePool): ExporterInterface | ||
{ | ||
$synchronizationConfigStub = $this->getMockBuilder(SynchronizationConfig::class) | ||
->onlyMethods(['isRepositorySyncExportPropelInstancePoolingDisabled'])->getMock(); | ||
$synchronizationConfigStub->method('isRepositorySyncExportPropelInstancePoolingDisabled')->willReturn($disablePropelInstancePool); | ||
|
||
return $this->getMockBuilder(RepositoryExporter::class) | ||
->setConstructorArgs([ | ||
$this->getMockBuilder(SynchronizationToQueueClientInterface::class)->getMock(), | ||
$this->getMockBuilder(QueueMessageCreatorInterface::class)->getMock(), | ||
$this->getMockBuilder(SynchronizationToUtilEncodingServiceInterface::class)->getMock(), | ||
$synchronizationConfigStub, | ||
]) | ||
->onlyMethods(['disableInstancePooling', 'enableInstancePooling']) | ||
->getMock(); | ||
} | ||
} |