<commit_before><?php
/*
 * This file is part of the BusinessDropCapBundle and it is distributed
 * under the GPL LICENSE Version 2.0. To use this application you must leave
 * intact this copyright notice.
 *
 * Copyright (c) AlphaLemon <<EMAIL>>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 *
 * For extra documentation and help please visit http://www.alphalemon.com
 *
 * @license    GPL LICENSE Version 2.0
 *
 */

namespace AlphaLemon\Block\BusinessDropCapBundle\Tests\Unit\Core\Block;

use AlphaLemon\Block\BusinessDropCapBundle\Tests\TestCase;
use AlphaLemon\Block\BusinessDropCapBundle\Core\Block\AlBlockManagerBusinessDropCap;

/**
 * AlBlockManagerBusinessDropCapTest
 *
 * @author alphalemon <<EMAIL>>
 */
class AlBlockManagerBusinessDropCapTest extends TestCase
{
    protected function setUp()
    {
        parent::setUp();

        $factoryRepository = $this->getMock('AlphaLemon\AlphaLemonCmsBundle\Core\Repository\Factory\AlFactoryRepositoryInterface');
        $validator = $this->getMock('Symfony\Component\Validator\ValidatorInterface');
        $eventsHandler = $this->getMock('AlphaLemon\AlphaLemonCmsBundle\Core\EventsHandler\AlEventsHandlerInterface');
        $this->blockManager = new AlBlockManagerBusinessDropCap($eventsHandler, $validator, $factoryRepository);
    }

    public function testDefaultValue()
    {
        $value =
        '{
            "0" : {
                "dropcap" : "A",
                "title" : "A Dropcap",
                "subtitle" : "Title"
            }
        }';
        $expectedValue = array(
            'Content' => $value,
            'InternalJavascript' => '$(\'.business-dropcap h3\').doCufon();',
        );
        $this->assertEquals($expectedValue, $this->blockManager->getDefaultValue());
    }

    public function testAnEmptyStringIsReturnedWhenTheBlockHasNotBeenSet()
    {
        $this->assertEquals('', $this->blockManager->getHtml());
    }

    public function testTheDropCapIsRendered()
    {
        $block = $this->setUpBlock();
        $this->blockManager->set($block);
        $content = $this->blockManager->getHtml();

        $expectedResult = '<div class="business-dropcap"><h3><span class="dropcap">A</span>A Dropcap<span>Title</span></h3></div>';
        $this->assertEquals($expectedResult, $content);
    }

    private function setUpBlock()
    {
        $value =
        '{
            "0" : {
                "dropcap" : "A",
                "title" : "A Dropcap",
                "subtitle" : "Title"
            }
        }';

        $block = $this->getMock('AlphaLemon\AlphaLemonCmsBundle\Model\AlBlock');
        $block->expects($this->once())
            ->method('getContent')<commit_msg>updated unit test to reflect latest changes<commit_after><?php
/*
 * This file is part of the BusinessDropCapBundle and it is distributed
 * under the GPL LICENSE Version 2.0. To use this application you must leave
 * intact this copyright notice.
 *
 * Copyright (c) AlphaLemon <<EMAIL>>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 *
 * For extra documentation and help please visit http://www.alphalemon.com
 *
 * @license    GPL LICENSE Version 2.0
 *
 */

namespace AlphaLemon\Block\BusinessDropCapBundle\Tests\Unit\Core\Block;

use AlphaLemon\Block\BusinessDropCapBundle\Tests\TestCase;
use AlphaLemon\Block\BusinessDropCapBundle\Core\Block\AlBlockManagerBusinessDropCap;

/**
 * AlBlockManagerBusinessDropCapTest
 *
 * @author alphalemon <<EMAIL>>
 */
class AlBlockManagerBusinessDropCapTest extends TestCase
{
    protected function setUp()
    {
        parent::setUp();

        $factoryRepository = $this->getMock('AlphaLemon\AlphaLemonCmsBundle\Core\Repository\Factory\AlFactoryRepositoryInterface');
        $validator = $this->getMock('Symfony\Component\Validator\ValidatorInterface');
        $eventsHandler = $this->getMock('AlphaLemon\AlphaLemonCmsBundle\Core\EventsHandler\AlEventsHandlerInterface');
        $this->blockManager = new AlBlockManagerBusinessDropCap($eventsHandler, $validator, $factoryRepository);
    }

    public function testDefaultValue()
    {
        $value =
        '{
            "0" : {
                "dropcap" : "A",
                "title" : "A Dropcap",
                "subtitle" : "Title"
            }
        }';
        $expectedValue = array(
            'Content' => $value,
            'InternalJavascript' => '$(\'.business-dropcap h3\').doCufon();',
        );
        $this->assertEquals($expectedValue, $this->blockManager->getDefaultValue());
    }

    public function testAnEmptyStringIsReturnedWhenTheBlockHasNotBeenSet()
    {
        $this->assertEquals('', $this->blockManager->getHtml());
    }

    public function testTheDropCapIsRendered()
    {
        $block = $this->setUpBlock();
        $this->blockManager->set($block);
        $content = $this->blockManager->getHtml();
        
        $expectedResult = array
        (
            "RenderView" => array
            (
                "view" => "BusinessDropCapBundle:DropCap:dropcap.html.twig",
                "options" => array
                (
                    "item" => array
                    (
                        "dropcap" => "A",
                        "title" => "A Dropcap",
                        "subtitle" => "Title",
                    ),
                ),
            ),
        );

        
        $this->assertEquals($expectedResult, $content);
    }

    private function setUpBlock()
    {
        $value =
        '{
            "0" : {
                "dropcap" : "A",
                "title" : "A Dropcap",
                "subtitle" : "Title"
            }
        }';

        $block = $this->getMock('AlphaLemon\AlphaLemonCmsBundle\Model\AlBlock');
        $block->expects($this->once())
            ->method('getContent')
{'fraction_non_alphanumeric': 0.1275381775465682, 'fraction_numerical': 0.0026850142641382784, 'mean_word_length': 2.407661520869068, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 70, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '2273603', 'n_tokens_mistral': 1670, 'n_tokens_neox': 1616, 'n_words': 319}