Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TASK] Make composer test work on Appveyor #492

Merged
merged 1 commit into from
May 7, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 0 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,6 @@ notifications:
before_install:
- |
export COMPOSER_ROOT_VERSION=4.5.3
export CONSOLE_ROOT="$PWD"
export TYPO3_PATH_ROOT="$CONSOLE_ROOT/.Build/Web"
export PATH="$PATH:./Scripts"
- if php -i | grep -q xdebug; then phpenv config-rm xdebug.ini; fi

Expand Down
36 changes: 35 additions & 1 deletion Tests/Functional/Command/AbstractCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@
*/

use Helhum\Typo3Console\Mvc\Cli\CommandDispatcher;
use Helhum\Typo3Console\Mvc\Cli\FailedSubProcessCommandException;
use Symfony\Component\Filesystem\Filesystem;
use Symfony\Component\Process\PhpExecutableFinder;
use Symfony\Component\Process\ProcessBuilder;

abstract class AbstractCommandTest extends \PHPUnit_Framework_TestCase
Expand Down Expand Up @@ -115,7 +117,7 @@ protected function restoreDatabase()
*/
protected function installFixtureExtensionCode($extensionKey)
{
$sourcePath = dirname(__DIR__) . '/Fixtures/' . $extensionKey;
$sourcePath = dirname(__DIR__) . '/Fixtures/Extensions/' . $extensionKey;
$targetPath = getenv('TYPO3_PATH_ROOT') . '/typo3conf/ext/' . $extensionKey;
$this->copyDirectory($sourcePath, $targetPath);
}
Expand Down Expand Up @@ -163,4 +165,36 @@ protected function removeDirectory($targetPath)
$fileSystem->remove($iterator);
$fileSystem->remove($targetPath);
}

/**
* @param array $arguments
* @param array $environmentVariables
* @throws FailedSubProcessCommandException
* @return string
*/
protected function executeComposerCommand(array $arguments = [], array $environmentVariables = [])
{
$processBuilder = new ProcessBuilder();
$processBuilder->addEnvironmentVariables($environmentVariables);

if ($phpPath = getenv('PHP_PATH')) {
$phpFinder = new PhpExecutableFinder();
$processBuilder->setPrefix($phpFinder->find(false));
$processBuilder->add($phpPath . '/composer.phar');
} else {
$processBuilder->setPrefix('composer');
}
foreach ($arguments as $argument) {
$processBuilder->add($argument);
}
$processBuilder->add('-d');
$processBuilder->add(getenv('TYPO3_PATH_COMPOSER_ROOT'));

$process = $processBuilder->setTimeout(null)->getProcess();
$process->run();
if (!$process->isSuccessful()) {
throw FailedSubProcessCommandException::forProcess('composer', $process);
}
return $process->getOutput() . $process->getErrorOutput();
}
}
30 changes: 13 additions & 17 deletions Tests/Functional/Command/Install/InstallCommandControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
*/

use Helhum\Typo3Console\Tests\Functional\Command\AbstractCommandTest;
use Symfony\Component\Process\ProcessBuilder;

class InstallCommandControllerTest extends AbstractCommandTest
{
Expand Down Expand Up @@ -123,24 +122,21 @@ public function packageStatesFileIsCreatedWithDefaultPackages()
*/
public function packageStatesFileIsCreatedFromComposerRun()
{
if (DIRECTORY_SEPARATOR === '\\') {
// TODO: find out the reason, why composer cannot be executed using Symfony Process
$this->markTestSkipped('Currently does not work on Windows');
}
$packageStatesFile = getenv('TYPO3_PATH_ROOT') . '/typo3conf/PackageStates.php';
@unlink($packageStatesFile);
$processBuilder = new ProcessBuilder();
$processBuilder->setEnv('TYPO3_CONSOLE_FEATURE_GENERATE_PACKAGE_STATES', 'yes');
$processBuilder->setEnv('TYPO3_CONSOLE_TEST_SETUP', 'yes');
$processBuilder->setEnv('TYPO3_ACTIVATE_DEFAULT_FRAMEWORK_EXTENSIONS', 'yes');
$processBuilder->setPrefix('composer');
$processBuilder->add('dump-autoload');
$processBuilder->add('-vv');
$processBuilder->add('-d');
$processBuilder->add(dirname(dirname(dirname(dirname(__DIR__)))));
$composerProcess = $processBuilder->getProcess();
$composerProcess->run();
$this->assertTrue($composerProcess->isSuccessful());

$this->executeComposerCommand(
[
'dump-autoload',
'-vv',
],
[
'TYPO3_CONSOLE_FEATURE_GENERATE_PACKAGE_STATES' => 'yes',
'TYPO3_CONSOLE_TEST_SETUP' => 'yes',
'TYPO3_ACTIVATE_DEFAULT_FRAMEWORK_EXTENSIONS' => 'yes',
]
);

$this->assertTrue(file_exists($packageStatesFile));
$packageConfig = require $packageStatesFile;
if ($packageConfig['version'] === 5) {
Expand Down
7 changes: 3 additions & 4 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,14 @@ services:

environment:
COMPOSER_NO_INTERACTION: 1
TYPO3_PATH_ROOT: 'c:\t3c\.Build\Web'
TYPO3_INSTALL_DB_USER: 'root'
TYPO3_INSTALL_DB_PASSWORD: 'Password12!'
TYPO3_INSTALL_DB_DBNAME: 'appveyor_console_test'

matrix:
- TYPO3_VERSION: '~8.6'
- TYPO3_VERSION: '~8.7'
PHP_VERSION: '7.1.1'
- TYPO3_VERSION: '~8.6'
- TYPO3_VERSION: '~8.7'
PHP_VERSION: '7.0.9'
- TYPO3_VERSION: '~7.6'
PHP_VERSION: '7.1.1'
Expand All @@ -30,6 +29,7 @@ cache:

init:
- SET PATH=c:\php\%PHP_VERSION%;"C:\Program Files\MySQL\MySQL Server 5.7\bin\";%PATH%
- SET PHP_PATH=c:\php\%PHP_VERSION%

install:
- mysql --version
Expand All @@ -54,7 +54,6 @@ install:

- cd c:\t3c
- composer require "typo3/cms=%TYPO3_VERSION%" --prefer-dist --no-progress --ansi
- DIR %TYPO3_PATH_ROOT%

test_script:
- cd c:\t3c
Expand Down