<commit_before><?php
/**
 * This file is part of the RedKiteCmsBunde Application and it is distributed
 * under the GPL LICENSE Version 2.0. To use this application you must leave
 * intact this copyright notice.
 *
 * Copyright (c) RedKite Labs <<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.redkite-labs.com
 *
 * @license    GPL LICENSE Version 2.0
 *
 */

namespace RedKiteLabs\RedKiteCmsBundle\Tests\Unit\Core\Content\Block\ImagesBlock;

use RedKiteLabs\RedKiteCmsBundle\Tests\Unit\Core\Content\Block\Base\AlBlockManagerContainerBase;
use RedKiteLabs\RedKiteCmsBundle\Core\Content\Block\ImagesBlock\AlBlockManagerImages;

/**
 * AlBlockManagerJsonBlockTest
 *
 * @author RedKite Labs <<EMAIL>>
 */
class AlBlockManagerImagesBlockTest extends AlBlockManagerContainerBase
{
    protected $blockManager;

    /**
     * @expectedException \RedKiteLabs\RedKiteCmsBundle\Core\Content\Block\JsonBlock\Exception\InvalidJsonFormatException
     */
    public function testAnExceptionIsThrownWhenTheSavedJsonContentIsNotDecodable()
    {
        $htmlContent = '{
            "0" : {
                "image" : "/path/to/image"
            },
        }';
        $block = $this->initBlock(2, $htmlContent);

        $this->initContainer();
        $params = array('AddFile' => "/new/path/to/image");
        $this->blockManager = new AlBlockManagerImagesBlockTester($this->container, $this->validator);
        $this->blockManager->set($block)
                           ->save($params);
    }

    public function testANewImageHasBeenAddedToImagesBlock()
    {
        $this->initContainer();
        $this->container->expects($this->once())
                        ->method('getParameter');

        $request = $this->getMockBuilder('Symfony\Component\HttpFoundation\Request')
                                    ->disableOriginalConstructor()
                                    ->getMock();
        
        $this->container->expects($this->at(2))
                        ->method('get')
                        ->with('request')
                        ->will($this->returnValue($request));
        
        $block = $this->initBlock();
        $params = array('AddFile' => "/new/path/to/image");
        $this->blockManager = new AlBlockManagerImagesBlockTester($this->container, $this->validator);
        $this->doSave($block, $params);
        
        return $this->blockManager;
    }

    public function testAnImageHasBeenRemovedFromImagesBlock()
    {
        $this->initContainer();

        $block = $this->initBlock();<commit_msg>updated unit test<commit_after><?php
/**
 * This file is part of the RedKiteCmsBunde Application and it is distributed
 * under the GPL LICENSE Version 2.0. To use this application you must leave
 * intact this copyright notice.
 *
 * Copyright (c) RedKite Labs <<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.redkite-labs.com
 *
 * @license    GPL LICENSE Version 2.0
 *
 */

namespace RedKiteLabs\RedKiteCmsBundle\Tests\Unit\Core\Content\Block\ImagesBlock;

use RedKiteLabs\RedKiteCmsBundle\Tests\Unit\Core\Content\Block\Base\AlBlockManagerContainerBase;
use RedKiteLabs\RedKiteCmsBundle\Core\Content\Block\ImagesBlock\AlBlockManagerImages;

/**
 * AlBlockManagerJsonBlockTest
 *
 * @author RedKite Labs <<EMAIL>>
 */
class AlBlockManagerImagesBlockTest extends AlBlockManagerContainerBase
{
    protected $blockManager;

    /**
     * @expectedException \RedKiteLabs\RedKiteCmsBundle\Core\Content\Block\JsonBlock\Exception\InvalidJsonFormatException
     */
    public function testAnExceptionIsThrownWhenTheSavedJsonContentIsNotDecodable()
    {
        $htmlContent = '{
            "0" : {
                "image" : "/path/to/image"
            },
        }';
        $block = $this->initBlock(2, $htmlContent);

        $this->initContainer();
        $params = array('AddFile' => "/new/path/to/image");
        $this->blockManager = new AlBlockManagerImagesBlockTester($this->container, $this->validator);
        $this->blockManager->set($block)
                           ->save($params);
    }

    public function testANewImageHasBeenAddedToImagesBlock()
    {
        $this->initContainer();
        $this->container->expects($this->once())
                        ->method('getParameter');

        $request = $this->getMockBuilder('Symfony\Component\HttpFoundation\Request')
                                    ->disableOriginalConstructor()
                                    ->getMock();
        
        $this->container->expects($this->at(3))
                        ->method('get')
                        ->with('request')
                        ->will($this->returnValue($request));
        
        $block = $this->initBlock();
        $params = array('AddFile' => "/new/path/to/image");
        $this->blockManager = new AlBlockManagerImagesBlockTester($this->container, $this->validator);
        $this->doSave($block, $params);
        
        return $this->blockManager;
    }

    public function testAnImageHasBeenRemovedFromImagesBlock()
    {
        $this->initContainer();

        $block = $this->initBlock();
{'fraction_non_alphanumeric': 0.12333333333333334, 'fraction_numerical': 0.0025925925925925925, 'mean_word_length': 2.54629021667761, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 77, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3879198', 'n_tokens_mistral': 1495, 'n_tokens_neox': 1462, 'n_words': 279}