<commit_before><?php
/**
 * AnimeDb package
 *
 * @package   AnimeDb
 * @author    <NAME> <<EMAIL>>
 * @copyright Copyright (c) 2011, <NAME>
 * @license   http://opensource.org/licenses/GPL-3.0 GPL v3
 */

namespace AnimeDb\Bundle\PaginationBundle\Tests\Twig\Extension;

use AnimeDb\Bundle\PaginationBundle\Twig\Extension\PaginationExtension;
use AnimeDb\Bundle\PaginationBundle\Service\Configuration;

/**
 * Class PaginationExtensionTest
 * @package AnimeDb\Bundle\PaginationBundle\Tests\Twig\Extension
 */
class PaginationExtensionTest extends \PHPUnit_Framework_TestCase
{
    /**
     * @var PaginationExtension
     */
    protected $extension;

    /**
     * @var string
     */
    protected $template = 'foo';

    protected function setUp()
    {
        $this->extension = new PaginationExtension($this->template);
    }

    public function testGetFunctions()
    {
        $functions = $this->extension->getFunctions();

        $this->assertInternalType('array', $functions);
        $this->assertEquals(1, count($functions));
        $this->assertInstanceOf('\Twig_SimpleFunction', $functions[0]);
    }

    public function testRender()
    {
        $expected = 'bar';
        $view = 'baz';
        /* @var $env \PHPUnit_Framework_MockObject_MockObject|\Twig_Environment */
        $env = $this
            ->getMockBuilder('\Twig_Environment')
            ->disableOriginalConstructor()
            ->getMock();
        $env
            ->expects($this->once())
            ->method('render')
            ->with($this->template, ['pagination' => $view])
            ->will($this->returnValue($expected));

        /* @var $configuration \PHPUnit_Framework_MockObject_MockObject|Configuration */
        $configuration = $this
            ->getMockBuilder('\AnimeDb\Bundle\PaginationBundle\Service\Configuration')
            ->disableOriginalConstructor()
            ->getMock();
        $configuration
            ->expects($this->once())
            ->method('getView')
            ->will($this->returnValue($view));

        $this->assertEquals($expected, $this->extension->render(
            $env,
            $configuration
        ));
    }

    public function testRenderChangeTemplate()
    {
        $expected = 'bar';
        $view = 'baz';
        $template = 'my_template';
        /* @var $env \PHPUnit_Framework_MockObject_MockObject|\Twig_Environment */
        $env = $this
            ->getMockBuilder('\Twig_Environment')
            ->disableOriginalConstructor()
            ->getMock();
        $env
            ->expects($this->once())
            ->method('render')
            ->with($template, ['pagination' => $view, 'my_params' => 12345])
            ->will($this->returnValue($expected));

        /* @var $configuration \PHPUnit_Framework_MockObject_MockObject|Configuration */
        $configuration = $this
            ->getMockBuilder('\AnimeDb\Bundle\PaginationBundle\Service\Configuration')
            ->disableOriginalConstructor()
            ->getMock();
        $configuration
            ->expects($this->once())
            ->method('getView')
            ->will($this->returnValue($view));

        $this->assertEquals($expected, $this->extension->render(
            $env,
            $configuration,
            $template,
            ['my_params' => 12345]
        ));
    }

    public function testRenderNoOverrideTemplateParams()
    {
        $expected = 'bar';
        $view = 'baz';
        /* @var $env \PHPUnit_Framework_MockObject_MockObject|\Twig_Environment */
        $env = $this
            ->getMockBuilder('\Twig_Environment')
            ->disableOriginalConstructor()
            ->getMock();
        $env
            ->expects($this->once())
            ->method('render')
            ->with($this->template, ['pagination' => $view])
            ->will($this->returnValue($expected));

        /* @var $configuration \PHPUnit_Framework_MockObject_MockObject|Configuration */
        $configuration = $this
            ->getMockBuilder('\AnimeDb\Bundle\PaginationBundle\Service\Configuration')
            ->disableOriginalConstructor()<commit_msg>correct pagination twig extension test<commit_after><?php
/**
 * AnimeDb package
 *
 * @package   AnimeDb
 * @author    <NAME> <<EMAIL>>
 * @copyright Copyright (c) 2011, <NAME>
 * @license   http://opensource.org/licenses/GPL-3.0 GPL v3
 */

namespace AnimeDb\Bundle\PaginationBundle\Tests\Twig\Extension;

use AnimeDb\Bundle\PaginationBundle\Twig\Extension\PaginationExtension;
use AnimeDb\Bundle\PaginationBundle\Service\Configuration;

/**
 * Class PaginationExtensionTest
 * @package AnimeDb\Bundle\PaginationBundle\Tests\Twig\Extension
 */
class PaginationExtensionTest extends \PHPUnit_Framework_TestCase
{
    /**
     * @var PaginationExtension
     */
    protected $extension;

    /**
     * @var string
     */
    protected $template = 'foo';

    protected function setUp()
    {
        $this->extension = new PaginationExtension($this->template);
    }

    public function testGetFunctions()
    {
        $functions = $this->extension->getFunctions();

        $this->assertInternalType('array', $functions);
        $this->assertEquals(1, count($functions));
        $this->assertInstanceOf(\Twig_Function::class, $functions[0]);
    }

    public function testRender()
    {
        $expected = 'bar';
        $view = 'baz';
        /* @var $env \PHPUnit_Framework_MockObject_MockObject|\Twig_Environment */
        $env = $this
            ->getMockBuilder(\Twig_Environment::class)
            ->disableOriginalConstructor()
            ->getMock();
        $env
            ->expects($this->once())
            ->method('render')
            ->with($this->template, ['pagination' => $view])
            ->will($this->returnValue($expected));

        /* @var $configuration \PHPUnit_Framework_MockObject_MockObject|Configuration */
        $configuration = $this
            ->getMockBuilder(Configuration::class)
            ->disableOriginalConstructor()
            ->getMock();
        $configuration
            ->expects($this->once())
            ->method('getView')
            ->will($this->returnValue($view));

        $this->assertEquals($expected, $this->extension->render(
            $env,
            $configuration
        ));
    }

    public function testRenderChangeTemplate()
    {
        $expected = 'bar';
        $view = 'baz';
        $template = 'my_template';
        /* @var $env \PHPUnit_Framework_MockObject_MockObject|\Twig_Environment */
        $env = $this
            ->getMockBuilder(\Twig_Environment::class)
            ->disableOriginalConstructor()
            ->getMock();
        $env
            ->expects($this->once())
            ->method('render')
            ->with($template, ['pagination' => $view, 'my_params' => 12345])
            ->will($this->returnValue($expected));

        /* @var $configuration \PHPUnit_Framework_MockObject_MockObject|Configuration */
        $configuration = $this
            ->getMockBuilder(Configuration::class)
            ->disableOriginalConstructor()
            ->getMock();
        $configuration
            ->expects($this->once())
            ->method('getView')
            ->will($this->returnValue($view));

        $this->assertEquals($expected, $this->extension->render(
            $env,
            $configuration,
            $template,
            ['my_params' => 12345]
        ));
    }

    public function testRenderNoOverrideTemplateParams()
    {
        $expected = 'bar';
        $view = 'baz';
        /* @var $env \PHPUnit_Framework_MockObject_MockObject|\Twig_Environment */
        $env = $this
            ->getMockBuilder(\Twig_Environment::class)
            ->disableOriginalConstructor()
            ->getMock();
        $env
            ->expects($this->once())
            ->method('render')
            ->with($this->template, ['pagination' => $view])
            ->will($this->returnValue($expected));

        /* @var $configuration \PHPUnit_Framework_MockObject_MockObject|Configuration */
        $configuration = $this
            ->getMockBuilder(Configuration::class)
            ->disableOriginalConstructor()
{'fraction_non_alphanumeric': 0.1443210930828352, 'fraction_numerical': 0.004635842381359034, 'mean_word_length': 2.3029814665592263, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 141, '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': '5444204', 'n_tokens_mistral': 2192, 'n_tokens_neox': 2149, 'n_words': 341}