Skip to content

Commit

Permalink
added regression test covering pull request #65
Browse files Browse the repository at this point in the history
  • Loading branch information
fglaser-dotsource committed Aug 26, 2015
1 parent 2fe7390 commit 4ec7f94
Showing 1 changed file with 180 additions and 0 deletions.
180 changes: 180 additions & 0 deletions tests/MagentoHackathon/Composer/FullStack/Regression/IssueC065Test.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,180 @@
<?php
/**
* Copyright (c) 2008-2015 dotSource GmbH.
* All rights reserved.
* http://www.dotsource.de
*
* Created:
* 26.08.2015
*
* Contributors:
* Felix Glaser - initial contents
*
* @category Dotsource
*/

namespace MagentoHackathon\Composer\FullStack\Regression;

use Composer\Util\Filesystem;
use Cotya\ComposerTestFramework;

class IssueC065Test extends ComposerTestFramework\PHPUnit\FullStackTestCase
{
/** @var ComposerTestFramework\Composer\Wrapper */
protected $composer;

/** @var \SplFileInfo */
protected $projectDirectory;

/** @var \SplFileInfo */
protected $artifactDirectory;

/** @var string */
protected $testFilePath;

protected function setUp()
{
$this->composer = new ComposerTestFramework\Composer\Wrapper();
$this->projectDirectory = new \SplFileInfo(self::getTempComposerProjectPath());
$this->artifactDirectory = new \SplFileInfo(__DIR__.'/../../../../../tests/FullStackTest/artifact');
$this->testFilePath = $this->projectDirectory->getPathname()."/mage/app/code/local/Test/Module";
}

private function prepareProject()
{
$fs = new Filesystem();
$fs->remove($this->projectDirectory->getPathname()."/mage/app");
$fs->ensureDirectoryExists($this->projectDirectory->getPathname()."/app/code/local/Test/Module");

$modman = new \SplFileObject($this->projectDirectory->getPathname()."/modman", "w");
$modmanContent = <<<MODMAN
app/code/local/* app/code/local/
MODMAN;

$modman->fwrite($modmanContent);
}

/**
* @group regression
*/
public function testIncludeRootPackageNotSet()
{
$this->prepareProject();

$composerJson = new \SplTempFileObject();
$composerJsonContent = <<<JSON
{
"name": "test/module",
"type": "magento-module",
"repositories": [
{
"type": "composer",
"url": "http://packages.firegento.com"
},
{
"type": "artifact",
"url": "$this->artifactDirectory/"
}
],
"require": {
"magento-hackathon/magento-composer-installer": "999.0.0"
},
"extra": {
"magento-deploy-strategy": "symlink",
"magento-root-dir": "./mage"
}
}
JSON;

$composerJson->fwrite($composerJsonContent);

$this->composer->install($this->projectDirectory, $composerJson);

$this->assertFileNotExists($this->testFilePath);
}

/**
* @group regression
*/
public function testIncludeRootPackageIsFalse()
{
$this->prepareProject();


$composerJson = new \SplTempFileObject();
$composerJsonContent = <<<JSON
{
"name": "test/module",
"type": "magento-module",
"repositories": [
{
"type": "composer",
"url": "http://packages.firegento.com"
},
{
"type": "artifact",
"url": "$this->artifactDirectory/"
}
],
"require": {
"magento-hackathon/magento-composer-installer": "999.0.0"
},
"extra": {
"magento-deploy-strategy": "symlink",
"magento-root-dir": "./mage",
"include-root-package": false
}
}
JSON;

$composerJson->fwrite($composerJsonContent);

$this->composer->install($this->projectDirectory, $composerJson);

$this->assertFileNotExists($this->testFilePath);
}

/**
* @group regression
*/
public function testIncludeRootPackageIsTrue()
{
$this->prepareProject();


$composerJson = new \SplTempFileObject();
$composerJsonContent = <<<JSON
{
"name": "test/module",
"type": "magento-module",
"repositories": [
{
"type": "composer",
"url": "http://packages.firegento.com"
},
{
"type": "artifact",
"url": "$this->artifactDirectory/"
}
],
"require": {
"magento-hackathon/magento-composer-installer": "999.0.0"
},
"extra": {
"magento-deploy-strategy": "symlink",
"magento-root-dir": "./mage",
"include-root-package": true
}
}
JSON;

$composerJson->fwrite($composerJsonContent);

$this->composer->install($this->projectDirectory, $composerJson);

$this->assertFileExists($this->testFilePath);
}
}

0 comments on commit 4ec7f94

Please sign in to comment.