<commit_before><?php namespace Arcanedev\Support\Tests;

use Arcanedev\Support\Stub;

/**
 * Class     StubTest
 *
 * @package  Arcanedev\Support\Tests
 * @author   ARCANEDEV <<EMAIL>>
 */
class StubTest extends TestCase
{
    /* ------------------------------------------------------------------------------------------------
     |  Properties
     | ------------------------------------------------------------------------------------------------
     */
    /** @var Stub */
    private $stub;

    /* ------------------------------------------------------------------------------------------------
     |  Main Functions
     | ------------------------------------------------------------------------------------------------
     */
    public function setUp()
    {
        parent::setUp();
    }

    public function tearDown()
    {
        unset($this->stub);

        parent::tearDown();
    }

    /* ------------------------------------------------------------------------------------------------
     |  Test Functions
     | ------------------------------------------------------------------------------------------------
     */
    /** @test */
    public function it_can_be_instantiated()
    {
        $file = $this->getFixturesPath('stubs/composer.stub');
        $this->stub = new Stub($file);

        $this->assertInstanceOf('Arcanedev\\Support\\Stub', $this->stub);
        $fileContent = file_get_contents($file);
        $this->assertEquals($fileContent, $this->stub->render());
        $this->assertEquals($fileContent, (string) $this->stub);
    }

    /** @test */
    public function it_can_create()
    {
        $basePath   = $this->getFixturesPath('stubs');
        Stub::setBasePath($basePath);

        $this->stub = Stub::create('composer.stub');

        $this->stub->replaces([
            'VENDOR'            => 'arcanedev',
            'PACKAGE'           => 'package',
            'AUTHOR_NAME'       => 'ARCANEDEV',
            'AUTHOR_EMAIL'      => '<EMAIL>',
            'MODULE_NAMESPACE'  => str_studly('arcanedev'),
            'STUDLY_NAME'       => str_studly('package'),
        ]);

        $this->stub->save('composer.json');

        $fixture = $this->getFixturesPath('stubs/composer.json');

        $this->assertEquals(file_get_contents($fixture),$this->stub->render());

        $this->stub->saveTo($basePath, 'composer.json');

        $this->assertEquals(file_get_contents($fixture), $this->stub->render());
    }

    /** @test */
    public function it_can_set_and_get_base_path()
    {
        $basePath = $this->getFixturesPath('stubs');
        Stub::setBasePath($basePath);

        $this->assertEquals($basePath, Stub::getBasePath());
    }

    /** @test */
    public function it_can_create_from_path()
    {
        $path = $this->getFixturesPath('stubs') . '/composer.stub';

        $this->stub = Stub::createFromPath($path);

        $this->assertEmpty($this->stub->getBasePath());
        $this->assertEquals($path, $this->stub->getPath());
        $this->assertEmpty($this->stub->getReplaces());
    }
}
<commit_msg>Fixing the tests<commit_after><?php namespace Arcanedev\Support\Tests;

use Arcanedev\Support\Stub;

/**
 * Class     StubTest
 *
 * @package  Arcanedev\Support\Tests
 * @author   ARCANEDEV <<EMAIL>>
 */
class StubTest extends TestCase
{
    /* ------------------------------------------------------------------------------------------------
     |  Properties
     | ------------------------------------------------------------------------------------------------
     */
    /** @var Stub */
    private $stub;

    /* ------------------------------------------------------------------------------------------------
     |  Main Functions
     | ------------------------------------------------------------------------------------------------
     */
    public function setUp()
    {
        parent::setUp();
    }

    public function tearDown()
    {
        unset($this->stub);

        parent::tearDown();
    }

    /* ------------------------------------------------------------------------------------------------
     |  Test Functions
     | ------------------------------------------------------------------------------------------------
     */
    /** @test */
    public function it_can_be_instantiated()
    {
        $file = $this->getFixturesPath('stubs/composer.stub');
        $this->stub = new Stub($file);

        $this->assertInstanceOf('Arcanedev\\Support\\Stub', $this->stub);
        $fileContent = file_get_contents($file);
        $this->assertEquals($fileContent, $this->stub->render());
        $this->assertEquals($fileContent, (string) $this->stub);
    }

    /** @test */
    public function it_can_create()
    {
        $basePath   = $this->getFixturesPath('stubs');
        Stub::setBasePath($basePath);

        $this->stub = Stub::create('composer.stub');

        $this->stub->replaces([
            'VENDOR'            => 'arcanedev',
            'PACKAGE'           => 'package',
            'AUTHOR_NAME'       => 'ARCANEDEV',
            'AUTHOR_EMAIL'      => '<EMAIL>',
            'MODULE_NAMESPACE'  => studly_case('arcanedev'),
            'STUDLY_NAME'       => studly_case('package'),
        ]);

        $this->stub->save('composer.json');

        $fixture = $this->getFixturesPath('stubs/composer.json');

        $this->assertEquals(file_get_contents($fixture),$this->stub->render());

        $this->stub->saveTo($basePath, 'composer.json');

        $this->assertEquals(file_get_contents($fixture), $this->stub->render());
    }

    /** @test */
    public function it_can_set_and_get_base_path()
    {
        $basePath = $this->getFixturesPath('stubs');
        Stub::setBasePath($basePath);

        $this->assertEquals($basePath, Stub::getBasePath());
    }

    /** @test */
    public function it_can_create_from_path()
    {
        $path = $this->getFixturesPath('stubs') . '/composer.stub';

        $this->stub = Stub::createFromPath($path);

        $this->assertEmpty($this->stub->getBasePath());
        $this->assertEquals($path, $this->stub->getPath());
        $this->assertEmpty($this->stub->getReplaces());
    }
}

{'fraction_non_alphanumeric': 0.32864305353388323, 'fraction_numerical': 0.0, 'mean_word_length': 1.3083240014930944, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 97, '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': '2533146', 'n_tokens_mistral': 1638, 'n_tokens_neox': 1641, 'n_words': 210}