<commit_before><?php

namespace FOS\ElasticaBundle\Tests\EventListener;

use FOS\ElasticaBundle\Event\PopulateEvent;
use FOS\ElasticaBundle\EventListener\PopulateListener;
use PHPUnit_Framework_MockObject_MockObject;

class PopulateListenerTest extends \PHPUnit_Framework_TestCase
{
    /**
     * @var PHPUnit_Framework_MockObject_MockObject
     */
    private $resetter;

    /**
     * @var PopulateListener
     */
    private $listener;

    protected function setUp()
    {
        $this->resetter = $this->getMockBuilder('FOS\ElasticaBundle\Index\Resetter')
            ->disableOriginalConstructor()
            ->getMock();

        $this->listener = new PopulateListener($this->resetter);
    }

    public function testPostIndexPopulate()
    {
        $this->resetter->expects($this->once())->method('postPopulate')->with('indexName');
        $this->listener->postIndexPopulate(new PopulateEvent('indexName', null, true, array()));
    }

    public function testPreIndexPopulateWhenNoResetRequired()
    {
        $this->resetter->expects($this->never())->method('resetIndex');
        $this->resetter->expects($this->never())->method('resetIndexType');
        $this->listener->preIndexPopulate(new PopulateEvent('indexName', null, false, array()));
    }

    public function testPreIndexPopulateWhenResetIsRequiredAndNoTypeIsSpecified()
    {
        $this->resetter->expects($this->once())->method('resetIndex')->with('indexName');
        $this->listener->preIndexPopulate(new PopulateEvent('indexName', null, true, array()));
    }

    public function testPreIndexPopulateWhenResetIsRequiredAndTypeIsSpecified()
    {
        $this->resetter->expects($this->once())->method('resetIndexType')->with('indexName', 'indexType');
        $this->listener->preIndexPopulate(new PopulateEvent('indexName', 'indexType', true, array()));
    }
}<commit_msg>attempt to make scrutinizer happy, about duplicate code in test<commit_after><?php

namespace FOS\ElasticaBundle\Tests\EventListener;

use FOS\ElasticaBundle\Event\PopulateEvent;
use FOS\ElasticaBundle\EventListener\PopulateListener;
use PHPUnit_Framework_MockObject_MockObject;

class PopulateListenerTest extends \PHPUnit_Framework_TestCase
{
    /**
     * @var PHPUnit_Framework_MockObject_MockObject
     */
    private $resetter;

    /**
     * @var PopulateListener
     */
    private $listener;

    protected function setUp()
    {
        $this->resetter = $this->getMockBuilder('FOS\ElasticaBundle\Index\Resetter')
            ->disableOriginalConstructor()
            ->getMock();

        $this->listener = new PopulateListener($this->resetter);
    }

    public function testPostIndexPopulate()
    {
        $this->resetter->expects($this->once())->method('postPopulate')->with('indexName');
        $this->listener->postIndexPopulate(new PopulateEvent('indexName', null, true, array()));
    }

    public function preIndexPopulateDataProvider()
    {
        return array(
            array(
                array(
                    array('resetIndex', $this->never()),
                    array('resetIndexType', $this->never())
                ),
                array('indexName', true),
                new PopulateEvent('indexName', null, false, array())
            ),
            array(
                array(
                    array('resetIndex', $this->once())
                ),
                array('indexName', true),
                new PopulateEvent('indexName', null, true, array())
            ),
            array(
                array(
                    array('resetIndexType', $this->once())
                ),
                array('indexName', 'indexType'),
                new PopulateEvent('indexName', 'indexType', true, array())
            )
        );
    }

    /**
     * @param array         $asserts
     * @param array         $withArgs
     * @param PopulateEvent $event
     *
     * @dataProvider preIndexPopulateDataProvider
     */
    public function testPreIndexPopulate(array $asserts, array $withArgs, PopulateEvent $event)
    {
        foreach ($asserts as $assert) {
            $this->resetter->expects($assert[1])->method($assert[0])->with($withArgs[0], $withArgs[1]);
        }

        $this->listener->preIndexPopulate($event);
    }
}
{'fraction_non_alphanumeric': 0.13661840261560018, 'fraction_numerical': 0.0009341429238673517, 'mean_word_length': 2.734088927637315, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 63, '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': '3007338', 'n_tokens_mistral': 1192, 'n_tokens_neox': 1160, 'n_words': 184}