<commit_before><?php

namespace Platformsh\Cli\Tests;

use Platformsh\Cli\CliConfig;
use Platformsh\Cli\Local\LocalProject;
use org\bovigo\vfs\vfsStream;
use org\bovigo\vfs\vfsStreamDirectory;

class LocalProjectTest extends \PHPUnit_Framework_TestCase
{

    /** @var vfsStreamDirectory */
    protected $root;

    /**
     * @{inheritdoc}
     */
    public function setUp()
    {
        $this->root = vfsStream::setup(__CLASS__);
    }

    public function testGetLegacyProjectRoot()
    {
        $tempDir = $this->root->getName();
        $testDir = tempnam($tempDir, '');
        unlink($testDir);
        mkdir("$testDir/1/2/3/4/5", 0755, true);

        $expectedRoot = "$testDir/1";
        $config = new CliConfig();
        touch("$expectedRoot/" . $config->get('local.project_config_legacy'));

        chdir($testDir);
        $localProject = new LocalProject();
        $this->assertFalse($localProject->getLegacyProjectRoot());

        chdir($expectedRoot);
        $this->assertEquals($expectedRoot, $localProject->getLegacyProjectRoot());<commit_msg>Improve CliConfig coverage by force config reset<commit_after><?php

namespace Platformsh\Cli\Tests;

use Platformsh\Cli\CliConfig;
use Platformsh\Cli\Local\LocalProject;
use org\bovigo\vfs\vfsStream;
use org\bovigo\vfs\vfsStreamDirectory;

class LocalProjectTest extends \PHPUnit_Framework_TestCase
{

    /** @var vfsStreamDirectory */
    protected $root;

    /**
     * @{inheritdoc}
     */
    public function setUp()
    {
        $this->root = vfsStream::setup(__CLASS__);
    }

    public function testGetLegacyProjectRoot()
    {
        $tempDir = $this->root->getName();
        $testDir = tempnam($tempDir, '');
        unlink($testDir);
        mkdir("$testDir/1/2/3/4/5", 0755, true);

        $expectedRoot = "$testDir/1";
        $config = new CliConfig(null, null, true);
        $this->assertTrue($config->has('local.project_config_legacy'));
        touch("$expectedRoot/" . $config->get('local.project_config_legacy'));

        chdir($testDir);
        $localProject = new LocalProject();
        $this->assertFalse($localProject->getLegacyProjectRoot());

        chdir($expectedRoot);
        $this->assertEquals($expectedRoot, $localProject->getLegacyProjectRoot());
{'fraction_non_alphanumeric': 0.14759169244365886, 'fraction_numerical': 0.008837825894829872, 'mean_word_length': 3.2317757009345796, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 21, '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': '4870638', 'n_tokens_mistral': 719, 'n_tokens_neox': 691, 'n_words': 110}