<commit_before><?php

namespace phpDocumentor\Translator;

use Cilex\Application;
use Mockery as m;

class ServiceProviderTest extends \PHPUnit_Framework_TestCase
{
    /** @var ServiceProvider $fixture */
    protected $fixture = null;

    /** @var Cilex\Application $application */
    protected $application = null;

    protected function setUp()
    {
        $this->application = new Application('test');
        $this->application['config'] = m::mock('phpDocumentor\Configuration');
        $translatorConfiguration = m::mock('phpDocumentor\Translator\Configuration');
        $translatorConfiguration->shouldReceive('getLocale')->andReturn('foobar');

        $this->application['config']->shouldReceive('getTranslator')
        ->andReturn($translatorConfiguration);
        $this->fixture = new ServiceProvider();
    }

    /**
     * @covers phpDocumentor\Translator\ServiceProvider::register
     */
    public function testRegisterSetsTranslator()
    {
        $this->fixture->register($this->application);
        $translator = $this->application['translator'];

        $this->assertSame('foobar', $this->application['translator.locale']);
        $this->assertInstanceOf('phpDocumentor\Translator\Translator', $translator);
        $this->assertSame($this->application['translator.locale'], $translator->getLocale());
    }
}<commit_msg>improve test code. Moved locale to class variable, Optimized mock creation<commit_after><?php

namespace phpDocumentor\Translator;

use Cilex\Application;
use Mockery as m;

class ServiceProviderTest extends \PHPUnit_Framework_TestCase
{
    protected $locale = 'foobar';

    /** @var ServiceProvider $fixture */
    protected $fixture = null;

    /** @var Cilex\Application $application */
    protected $application = null;

    protected function setUp()
    {
        $this->application = new Application('test');
        $this->application['config'] = m::mock('phpDocumentor\Configuration');

        $this->application['config']->shouldReceive('getTranslator->getLocale')
        ->andReturn($this->locale);
        $this->fixture = new ServiceProvider();
    }

    /**
     * @covers phpDocumentor\Translator\ServiceProvider::register
     */
    public function testRegisterSetsTranslator()
    {
        $this->fixture->register($this->application);
        $translator = $this->application['translator'];

        $this->assertSame($this->locale, $this->application['translator.locale']);
        $this->assertInstanceOf('phpDocumentor\Translator\Translator', $translator);
        $this->assertSame($this->application['translator.locale'], $translator->getLocale());
    }
}
{'fraction_non_alphanumeric': 0.14561270801815432, 'fraction_numerical': 0.0, 'mean_word_length': 3.91635687732342, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 40, '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': '255140', 'n_tokens_mistral': 730, 'n_tokens_neox': 707, 'n_words': 120}