Skip to content
Snippets Groups Projects
Commit d7836196 authored by jurgenhaas's avatar jurgenhaas
Browse files

Remove unused tests

parent 1e4a010f
No related branches found
No related tags found
No related merge requests found
Pipeline #
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/4.1/phpunit.xsd"
backupGlobals="false"
colors="true"
bootstrap="vendor/autoload.php"
verbose="true"
>
<testsuites>
<testsuite name="docker4drupal">
<directory>./tests/</directory>
</testsuite>
</testsuites>
</phpunit>
<?php
/**
* @file
* Contains \LakeDrops\Docker4Drupal\Tests\PluginTest.
*/
namespace LakeDrops\Docker4Drupal\Tests;
use Composer\Util\Filesystem;
/**
* Tests composer plugin functionality.
*/
class PluginTest extends \PHPUnit_Framework_TestCase {
static $name = 'docker4drupal';
/**
* @var \Composer\Util\Filesystem
*/
protected $fs;
/**
* @var string
*/
protected $tmpDir;
/**
* @var string
*/
protected $rootDir;
/**
* @var string
*/
protected $tmpReleaseTag;
/**
* SetUp test
*/
public function setUp() {
$this->rootDir = realpath(realpath(__DIR__ . '/..'));
// Prepare temp directory.
$this->fs = new Filesystem();
$this->tmpDir = realpath(sys_get_temp_dir()) . DIRECTORY_SEPARATOR . self::$name;
$this->ensureDirectoryExistsAndClear($this->tmpDir);
$this->writeTestReleaseTag();
$this->writeComposerJSON();
chdir($this->tmpDir);
}
/**
* tearDown
*
* @return void
*/
public function tearDown() {
$this->fs->removeDirectory($this->tmpDir);
$this->git(sprintf('tag -d "%s"', $this->tmpReleaseTag));
}
/**
* Tests a simple composer install without core, but adding core later.
*/
public function testComposerInstallAndUpdate() {
# TODO: Write the actual tests
}
/**
* Writes the default composer json to the temp direcoty.
*/
protected function writeComposerJSON() {
$json = json_encode($this->composerJSONDefaults(), JSON_PRETTY_PRINT);
file_put_contents($this->tmpDir . '/composer.json', $json);
}
/**
* Writes a tag for the current commit, so we can reference it directly in the
* composer.json.
*/
protected function writeTestReleaseTag() {
$this->tmpReleaseTag = '999.0.' . time();
$this->git(sprintf('tag -a "%s" -m "%s"', $this->tmpReleaseTag, 'Tag for testing this exact commit'));
}
/**
* Provides the default composer.json data.
*
* @return array
*/
protected function composerJSONDefaults() {
return array(
'repositories' => array(
array(
'type' => 'vcs',
'url' => $this->rootDir,
),
array(
'type' => 'composer',
'url' => 'https://packages.drupal.org/8',
),
),
'require' => array(
'lakedrops/' . self::$name => $this->tmpReleaseTag,
'composer/installers' => '~1.2.0',
'drupal/core' => '~8.2.0',
'drupal-composer/drupal-scaffold' => '~2.2.0',
),
'scripts' => array(
self::$name => 'LakeDrops\\Drupal8Scaffold\\Plugin::configProject',
),
'minimum-stability' => 'dev',
'extra' => array(
'installer-paths' => array(
'web/core' => array('type:drupal-core'),
'web/modules/contrib/{$name}' => array('type:drupal-module'),
'web/profiles/contrib/{$name}' => array('type:drupal-profile'),
'web/themes/contrib/{$name}' => array('type:drupal-theme'),
'drush/contrib/{$name}' => array('type:drupal-drush'),
),
)
);
}
/**
* Wrapper for the composer command.
*
* @param string $command
* Composer command name, arguments and/or options
* @throws \Exception
*/
protected function composer($command) {
chdir($this->tmpDir);
passthru(escapeshellcmd($this->rootDir . '/vendor/bin/composer ' . $command), $exit_code);
if ($exit_code !== 0) {
throw new \Exception('Composer returned a non-zero exit code');
}
}
/**
* Wrapper for git command in the root directory.
*
* @param $command
* Git command name, arguments and/or options.
* @throws \Exception
*/
protected function git($command) {
chdir($this->rootDir);
passthru(escapeshellcmd('git -c "user.email=phpunit@test.com" ' . $command), $exit_code);
if ($exit_code !== 0) {
throw new \Exception('Git returned a non-zero exit code');
}
}
/**
* Makes sure the given directory exists and has no content.
*
* @param string $directory
*/
protected function ensureDirectoryExistsAndClear($directory) {
if (is_dir($directory)) {
$this->fs->removeDirectory($directory);
}
mkdir($directory, 0777, TRUE);
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment