<commit_before><commit_msg>add test for dynamic bundle clean command..<commit_after><?php
/** CleanDynamicBundleCacheCommandTest **/

namespace Graviton\GeneratorBundle\Tests\Command;

use Graviton\GeneratorBundle\Command\CleanDynamicBundleCacheCommand;
use Graviton\TestBundle\Test\GravitonTestCase;
use Symfony\Bundle\FrameworkBundle\Console\Application;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Tester\CommandTester;

/**
 * CleanDynamicBundleCacheCommandTest
 *
 * @author   List of contributors <https://github.com/libgraviton/graviton/graphs/contributors>
 * @license  http://opensource.org/licenses/gpl-license.php GNU Public License
 * @link     http://swisscom.ch
 */
class CleanDynamicBundleCacheCommandTest extends \PHPUnit_Framework_TestCase
{
    /**
     * Tests the execution of the command
     *
     * @return void
     */
    public function testExecute()
    {
        $kernel = GravitonTestCase::createKernel();
        $application = new Application($kernel);

        $application->add(new CleanDynamicBundleCacheCommand());

        $command = $application->find('graviton:clean:dynamicbundles');
        $command->setKernel($kernel);
        $command->setFilesystem($this->getFsMock());

        $commandTester = new CommandTester($command);
        $commandTester->execute(array());
    }

    /**
     * Gets the fs mock
     *
     * @return mock
     */
    private function getFsMock()
    {
        $fs = $this->getMockBuilder('Symfony\Component\Filesystem\Filesystem')
                   ->getMock();

        $fs->method('exists')
           ->willReturn(true);

        $fs->expects($this->once())
           ->method('exists')
           ->with($this->stringContains('GravitonDyn'));

        $fs->expects($this->once())
           ->method('remove')
           ->with($this->stringContains('GravitonDyn'));

        return $fs;
    }
}
{'fraction_non_alphanumeric': 0.13581541688515994, 'fraction_numerical': 0.0, 'mean_word_length': 3.13882863340564, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 24, 'https://': 1, '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': '2280481', 'n_tokens_mistral': 546, 'n_tokens_neox': 516, 'n_words': 85}