<commit_before><?php
/**
 * Custom Installer Test.
 *
 * @author <NAME> <<EMAIL>>
 * @copyright Copyright (c) 2014, <NAME>
 */
namespace DavidBarratt\CustomInstaller\Tests;

use DavidBarratt\CustomInstaller\CustomInstaller;
use Composer\Config;
use Composer\Composer;
use Composer\Package\Package;
use Composer\Package\RootPackage;
use PHPUnit_Framework_TestCase;

class CustomInstallerTest extends PHPUnit_Framework_TestCase
{

    /**
     * Tests installation path for given package/spec combination.
     *
     * @param string $name      Full package name (including vendor)
     * @param string $type      Composer package type
     * @param array  $spec      Custom-Installer configuration
     * @param string $expected  Expected path
     *
     * @dataProvider dataForInstallPath
     */
    public function testInstallPath($name, $type, $spec, $expected)
    {

        $composer = new Composer();
        $config = new Config();
        $composer->setConfig($config);

        $repository = $this->getMock('Composer\Repository\InstalledRepositoryInterface');
        $io = $this->getMock('Composer\IO\IOInterface');

        $installer = new CustomInstaller($io, $composer);
        $package = new Package($name, '1.0.0', '1.0.0');
        $package->setType($type);
        $consumerPackage = new RootPackage('foo/bar', '1.0.0', '1.0.0');
        $composer->setPackage($consumerPackage);
        $consumerPackage->setExtra(array(
          'custom-installer' => $spec,
        ));
        $result = $installer->getInstallPath($package);
        $this->assertEquals($expected, $result);
    }

    /**
     * Data provider for testing multiple install paths.
     *
     * @return array
     */
    public function dataForInstallPath()
    {
        return array(
          array(
            'davidbarratt/davidwbarratt',
            'drupal-site',
            array('drupal-site' => 'sites/{$name}/'),
            'sites/davidwbarratt/',
          ),
          array(
            'awesome/package',
            'custom-type',
            array('custom-type' => 'custom/{$vendor}/{$name}/'),
            'custom/awesome/package/',
          ),
          array(
            'drupal/core',
            'drupal-core',
            array('drupal-core' => 'web/'),
            'web/',
          ),
        );
    }
}
<commit_msg>Added tests for new format<commit_after><?php
/**
 * Custom Installer Test.
 *
 * @author <NAME> <<EMAIL>>
 * @copyright Copyright (c) 2014, <NAME>
 */
namespace DavidBarratt\CustomInstaller\Tests;

use DavidBarratt\CustomInstaller\CustomInstaller;
use Composer\Config;
use Composer\Composer;
use Composer\Package\Package;
use Composer\Package\RootPackage;
use PHPUnit_Framework_TestCase;

class CustomInstallerTest extends PHPUnit_Framework_TestCase
{

    /**
     * Tests installation path for given package/spec combination.
     *
     * @param string $name      Full package name (including vendor)
     * @param string $type      Composer package type
     * @param array  $spec      Custom-Installer configuration
     * @param string $expected  Expected path
     *
     * @dataProvider dataForInstallPath
     */
    public function testInstallPath($name, $type, $spec, $expected)
    {

        $composer = new Composer();
        $config = new Config(false, realpath('.'));
        $composer->setConfig($config);

        $repository = $this->getMock('Composer\Repository\InstalledRepositoryInterface');
        $io = $this->getMock('Composer\IO\IOInterface');

        $installer = new CustomInstaller($io, $composer);
        $package = new Package($name, '1.0.0', '1.0.0');
        $package->setType($type);
        $consumerPackage = new RootPackage('foo/bar', '1.0.0', '1.0.0');
        $composer->setPackage($consumerPackage);
        $consumerPackage->setExtra(array(
          'custom-installer' => $spec,
        ));
        $result = $installer->getInstallPath($package);
        $this->assertEquals($expected, $result);
    }

    /**
     * Data provider for testing multiple install paths.
     *
     * @return array
     */
    public function dataForInstallPath()
    {
        return array(
          array(
            'davidbarratt/davidwbarratt',
            'drupal-site',
            array('drupal-site' => 'sites/{$name}/'),
            'sites/davidwbarratt/',
          ),
          array(
            'awesome/package',
            'custom-type',
            array('custom-type' => 'custom/{$vendor}/{$name}/'),
            'custom/awesome/package/',
          ),
          array(
            'drupal/core',
            'drupal-core',
            array('drupal-core' => 'web/'),
            'web/',
          ),
          // Without spec.
          array(
            'package/without-spec',
            'library',
            array(),
            realpath('.') . '/vendor/package/without-spec',
          ),
          // New format
          array(
            'config/with-new-format',
            'custom-type',
            array(
              'custom/{$type}/{$vendor}/{$name}/' => array('type:custom-type'),
            ),
            'custom/custom-type/config/with-new-format/',
          ),
          // Per package
          array(
            'config/per-package',
            'custom-type',
            array(
              'custom/{$vendor}/{$name}/' => array('config/per-package'),
            ),
            'custom/config/per-package/',
          ),
          // Package over type
          array(
            'config/package-over-type',
            'custom-type',
            array(
              'type-folder/{$vendor}/{$name}/' => array('type:custom-type'),
              'package-folder/{$vendor}/{$name}/' => array('config/package-over-type'),
            ),
            'package-folder/config/package-over-type/',
          ),
        );
    }
}

{'fraction_non_alphanumeric': 0.14589041095890412, 'fraction_numerical': 0.005479452054794521, 'mean_word_length': 1.989252814738997, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 39, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6788374', 'n_tokens_mistral': 1678, 'n_tokens_neox': 1650, 'n_words': 313}