Skip to content

Commit

Permalink
Fix module variable handling
Browse files Browse the repository at this point in the history
  • Loading branch information
cmuench authored Feb 24, 2022
1 parent d50f57c commit 3710d82
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
7 changes: 1 addition & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,11 +122,6 @@ Example module structure:
```xml
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"
bootstrap="vendor/autoload.php"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
<coverage includeUncoveredFiles="true">
Expand All @@ -136,7 +131,7 @@ Example module structure:
</coverage>
<testsuites>
<testsuite name="n98-magerun2 Project Transfer Tools Commands">
<directory suffix="Test.php">tests</directory>
<directory>tests</directory>
</testsuite>
</testsuites>
</phpunit>
Expand Down
14 changes: 10 additions & 4 deletions src/Command/PHPUnit/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,12 @@ abstract class TestCase extends \PHPUnit\Framework\TestCase
public function loadConfigFile($configPath)
{
$config = $this->getApplication()->getConfig();
$additionalConfig = ConfigFile::createFromFile($configPath)->toArray();
$mergedConfig = ArrayFunctions::mergeArrays($config, $additionalConfig);
$additionalConfig = ConfigFile::createFromFile($configPath);
$configFile = new \SplFileInfo($configPath);
$additionalConfig->applyVariables($this->getApplication()->getMagentoRootFolder(), $configFile);
$additionalConfigArray = $additionalConfig->toArray();

$mergedConfig = ArrayFunctions::mergeArrays($config, $additionalConfigArray);
$this->getApplication()->reinit($mergedConfig);
}

Expand Down Expand Up @@ -115,10 +119,12 @@ public function getApplication()
$root = $this->getTestMagentoRoot();

/** @var Application|\PHPUnit\Framework\MockObject\MockObject $application */
$application = $this->getMock('N98\Magento\Application', array('getMagentoRootFolder'));
$application = $this->getMockBuilder(\N98\Magento\Application::class)
->onlyMethods(['getMagentoRootFolder'])
->getMock();
$application->expects($this->any())->method('getMagentoRootFolder')->will($this->returnValue($root));
$loader = require __DIR__ . '/../../../../../../vendor/autoload.php';
$application->setAutoloader($loader);
$application->expects($this->any())->method('getMagentoRootFolder')->will($this->returnValue($root));
$application->init();
$application->initMagento();

Expand Down

0 comments on commit 3710d82

Please sign in to comment.