-
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.
SDK-2870: Use new structure of test data provider (#123)
- Loading branch information
1 parent
d236c5f
commit 6e0c515
Showing
9 changed files
with
238 additions
and
184 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
143 changes: 143 additions & 0 deletions
143
tests/SprykerSdkTest/Integrator/AbstractIntegratorTestCase.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,143 @@ | ||
<?php | ||
|
||
/** | ||
* Copyright © 2016-present Spryker Systems GmbH. All rights reserved. | ||
* Use of this software requires acceptance of the Evaluation License Agreement. See LICENSE file. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace SprykerSdkTest\Integrator; | ||
|
||
use SprykerSdk\Integrator\IntegratorFacade; | ||
use Symfony\Component\Filesystem\Filesystem; | ||
|
||
abstract class AbstractIntegratorTestCase extends BaseTestCase | ||
{ | ||
/** | ||
* @var string | ||
*/ | ||
protected const MANIFESTS_DIR_PATH = ''; | ||
|
||
/** | ||
* @var string | ||
*/ | ||
protected const ZIP_PATH = ''; | ||
|
||
/** | ||
* @return void | ||
*/ | ||
protected function setUp(): void | ||
{ | ||
$this->prepareTestEnv(); | ||
} | ||
|
||
/** | ||
* @return void | ||
*/ | ||
protected function tearDown(): void | ||
{ | ||
$this->clearTestEnv(); | ||
} | ||
|
||
/** | ||
* @return void | ||
*/ | ||
public static function setUpBeforeClass(): void | ||
{ | ||
$zipPath = ROOT_TESTS . DIRECTORY_SEPARATOR . static::ZIP_PATH; | ||
$dirPath = DATA_PROVIDER_DIR . DIRECTORY_SEPARATOR . static::MANIFESTS_DIR_PATH; | ||
|
||
static::zipDir($dirPath, $zipPath); | ||
} | ||
|
||
/** | ||
* @return void | ||
*/ | ||
public static function tearDownAfterClass(): void | ||
{ | ||
$fs = new Filesystem(); | ||
$zipPath = ROOT_TESTS . DIRECTORY_SEPARATOR . static::ZIP_PATH; | ||
$fs->remove($zipPath); | ||
} | ||
|
||
/** | ||
* @return \SprykerSdk\Integrator\Business\IntegratorFacade | ||
*/ | ||
protected function createIntegratorFacade(): IntegratorFacade | ||
{ | ||
return new IntegratorFacade(); | ||
} | ||
|
||
/** | ||
* @return void | ||
*/ | ||
private function removeTmpDirectory(): void | ||
{ | ||
$fileSystem = $this->createFilesystem(); | ||
$tmpPath = $this->getTempDirectoryPath(); | ||
|
||
if ($fileSystem->exists($tmpPath)) { | ||
$fileSystem->remove($tmpPath); | ||
} | ||
} | ||
|
||
/** | ||
* @return void | ||
*/ | ||
private function createTmpDirectory(): void | ||
{ | ||
$fileSystem = $this->createFilesystem(); | ||
$tmpPath = $this->getTempDirectoryPath(); | ||
|
||
if (!$fileSystem->exists($tmpPath)) { | ||
$fileSystem->mkdir($tmpPath, 0700); | ||
} | ||
} | ||
|
||
/** | ||
* @return void | ||
*/ | ||
private function createTmpStandaloneModulesDirectory(): void | ||
{ | ||
$fileSystem = $this->createFilesystem(); | ||
$path = $this->getTempStandaloneModulesDirectoryPath(); | ||
|
||
if (!$fileSystem->exists($path)) { | ||
$fileSystem->mkdir($path, 0700); | ||
} | ||
} | ||
|
||
/** | ||
* @return void | ||
*/ | ||
protected function copyProjectMockToTmpDirectory(): void | ||
{ | ||
$fileSystem = $this->createFilesystem(); | ||
$tmpPath = $this->getTempDirectoryPath(); | ||
$projectMockPath = $this->getProjectMockOriginalPath(); | ||
|
||
if ($fileSystem->exists($this->getTempDirectoryPath())) { | ||
$fileSystem->mirror($projectMockPath, $tmpPath); | ||
} | ||
} | ||
|
||
/** | ||
* @return void | ||
*/ | ||
private function prepareTestEnv(): void | ||
{ | ||
$this->removeTmpDirectory(); | ||
$this->createTmpDirectory(); | ||
$this->createTmpStandaloneModulesDirectory(); | ||
$this->copyProjectMockToTmpDirectory(); | ||
} | ||
|
||
/** | ||
* @return void | ||
*/ | ||
private function clearTestEnv(): void | ||
{ | ||
$this->removeTmpDirectory(); | ||
} | ||
} |
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
71 changes: 71 additions & 0 deletions
71
tests/SprykerSdkTest/Integrator/IntegratorFacadeGeneralTest.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,71 @@ | ||
<?php | ||
|
||
/** | ||
* Copyright © 2016-present Spryker Systems GmbH. All rights reserved. | ||
* Use of this software requires acceptance of the Evaluation License Agreement. See LICENSE file. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace SprykerSdkTest\Integrator; | ||
|
||
class IntegratorFacadeGeneralTest extends AbstractIntegratorTestCase | ||
{ | ||
/** | ||
* @var string | ||
*/ | ||
protected const MANIFESTS_DIR_PATH = 'general/manifests/src'; | ||
|
||
/** | ||
* @var string | ||
*/ | ||
protected const ZIP_PATH = '_data/archive.zip'; | ||
|
||
/** | ||
* Rewrite the path to mock project | ||
* | ||
* @return string | ||
*/ | ||
protected function getProjectMockOriginalPath(): string | ||
{ | ||
return $this->getDataDirectoryPath() . DIRECTORY_SEPARATOR . 'general' . DIRECTORY_SEPARATOR . 'project_original'; | ||
} | ||
|
||
/** | ||
* Rewrite the path to mock project after integration | ||
* | ||
* @return string | ||
*/ | ||
protected function getProjectMockCurrentPath(): string | ||
{ | ||
return $this->getDataDirectoryPath() . DIRECTORY_SEPARATOR . 'general' . DIRECTORY_SEPARATOR . 'project_current'; | ||
} | ||
|
||
/** | ||
* @return void | ||
*/ | ||
public function testRunInstallationGlossary(): void | ||
{ | ||
// Arrange | ||
$ioAdapter = $this->buildSymfonyConsoleInputOutputAdapter(); | ||
|
||
// Act | ||
$this->createIntegratorFacade()->runModuleManifestInstallation( | ||
$ioAdapter, | ||
$this->createCommandArgumentsTransfer(false, [$this->getModuleTransfer('Spryker.TestIntegratorGlossary')]), | ||
); | ||
|
||
// Assert | ||
$glossaryPath = '/data/import/common/common/glossary.csv'; | ||
$testFilePath = $this->getProjectMockCurrentPath() . $glossaryPath; | ||
$testResultFile = $this->getTestTmpDirPath() . $glossaryPath; | ||
|
||
$this->assertFileExists($testFilePath); | ||
$this->assertFileExists($testResultFile); | ||
$this->assertStringContainsString( | ||
trim(file_get_contents($this->getProjectMockOriginalPath() . $glossaryPath)), | ||
trim(file_get_contents($testResultFile)), | ||
); | ||
$this->assertSame(trim(file_get_contents($testFilePath)), trim(file_get_contents($testResultFile))); | ||
} | ||
} |
Oops, something went wrong.