<commit_before><?php

use Mockery as m;
use Basset\Factory\AssetFactory;

class AssetFactoryTest extends PHPUnit_Framework_TestCase {


    public function tearDown()
    {
        m::close();
    }


    public function testMakeAsset()
    {
        $files = $this->getFilesMock();
        $filterFactory = $this->getFilterFactoryMock();
        $assetFactory = new AssetFactory($files, $filterFactory, __DIR__, 'testing');

        $asset = $assetFactory->make(__FILE__);

        $this->assertEquals(basename(__FILE__), $asset->getRelativePath());
        $this->assertEquals(__FILE__, $asset->getAbsolutePath());
    }


    public function testBuildingOfAbsolutePath()
    {
        $files = $this->getFilesMock();
        $filterFactory = $this->getFilterFactoryMock();
        $assetFactory = new AssetFactory($files, $filterFactory, '/path/to/public', 'testing');

        $this->assertEquals(__FILE__, $assetFactory->buildAbsolutePath(__FILE__));
        $this->assertEquals('http://foo.com', $assetFactory->buildAbsolutePath('http://foo.com'));
    }


    public function testBuildingOfRelativePath()
    {
        $files = $this->getFilesMock();
        $filterFactory = $this->getFilterFactoryMock();
        $assetFactory = new AssetFactory($files, $filterFactory, __DIR__, 'testing');

        $this->assertEquals('foo.css', $assetFactory->buildRelativePath(__DIR__.'/foo.css'));
        $this->assertEquals('bar/foo.css', $assetFactory->buildRelativePath(__DIR__.'/bar/foo.css'));
        $this->assertEquals('http://foo.com', $assetFactory->buildRelativePath('http://foo.com'));
    }


    public function testBuildingOfRelativePathFromOutsidePublicDirectory()
    {
        $files = $this->getFilesMock();
        $filterFactory = $this->getFilterFactoryMock();
        $assetFactory = new AssetFactory($files, $filterFactory, '/path/to/public', 'testing');

        $this->assertEquals(md5('path/to/outside').'/foo.css', $assetFactory->buildRelativePath('path/to/outside/foo.css'));
        $this->assertEquals(md5('path/to').'/bar.css', $assetFactory->buildRelativePath('path/to/bar.css'));
    }


    protected function getFilesMock()
    {
        return m::mock('Illuminate\Filesystem\Filesystem');
    }


    protected function getFilterFactoryMock()
    {
        return m::mock('Basset\Factory\FilterFactory');
    }


}<commit_msg>Fixing test coverage for asset factory.<commit_after><?php

use Mockery as m;
use Basset\Factory\AssetFactory;

class AssetFactoryTest extends PHPUnit_Framework_TestCase {


    public function tearDown()
    {
        m::close();
    }


    public function testMakeAsset()
    {
        $files = $this->getFilesMock();
        $manager = $this->getFactoryManagerMock();
        $factory = new AssetFactory($files, $manager, __DIR__, 'testing');

        $asset = $factory->make(__FILE__);

        $this->assertEquals(basename(__FILE__), $asset->getRelativePath());
        $this->assertEquals(__FILE__, $asset->getAbsolutePath());
        $this->assertInstanceOf('Basset\Asset', $asset);
    }


    public function testBuildingOfAbsolutePath()
    {
        $files = $this->getFilesMock();
        $manager = $this->getFactoryManagerMock();
        $factory = new AssetFactory($files, $manager, __DIR__, 'testing');

        $this->assertEquals(__FILE__, $factory->buildAbsolutePath(__FILE__));
        $this->assertEquals('http://foo.com', $factory->buildAbsolutePath('http://foo.com'));
    }


    public function testBuildingOfRelativePath()
    {
        $files = $this->getFilesMock();
        $manager = $this->getFactoryManagerMock();
        $factory = new AssetFactory($files, $manager, __DIR__, 'testing');

        $this->assertEquals('foo.css', $factory->buildRelativePath(__DIR__.'/foo.css'));
        $this->assertEquals('bar/foo.css', $factory->buildRelativePath(__DIR__.'/bar/foo.css'));
        $this->assertEquals('http://foo.com', $factory->buildRelativePath('http://foo.com'));
    }


    public function testBuildingOfRelativePathFromOutsidePublicDirectory()
    {
        $files = $this->getFilesMock();
        $manager = $this->getFactoryManagerMock();
        $factory = new AssetFactory($files, $manager, __DIR__, 'testing');

        $this->assertEquals(md5('path/to/outside').'/foo.css', $factory->buildRelativePath('path/to/outside/foo.css'));
        $this->assertEquals(md5('path/to').'/bar.css', $factory->buildRelativePath('path/to/bar.css'));
    }


    protected function getFilesMock()
    {
        return m::mock('Illuminate\Filesystem\Filesystem');
    }


    protected function getFactoryManagerMock()
    {
        return m::mock('Basset\Factory\FactoryManager');
    }


}
{'fraction_non_alphanumeric': 0.16100790091821482, 'fraction_numerical': 0.0008541533205210335, 'mean_word_length': 3.5431619786614936, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 58, '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': '6626034', 'n_tokens_mistral': 1348, 'n_tokens_neox': 1288, 'n_words': 201}