<commit_before><?php

namespace Dominikzogg\Pimple\Doctrine\Registry;

use Doctrine\ORM\EntityManager;
use Dominikzogg\Pimple\Provider\DoctrineOrmManagerRegistryProvider;

class ManagerRegistryTest extends \PHPUnit_Framework_TestCase
{
    /**
     * @return array
     */
    protected function createMockDefaultAppAndDeps()
    {
        $app = new \Pimple;

        $connection = $this
            ->getMockBuilder('Doctrine\DBAL\Connection')
            ->disableOriginalConstructor()
            ->getMock()
        ;

        $app['dbs'] = new \Pimple(array(
            'default' => $connection,
        ));

        $app['dbs.default'] = 'default';

        $configuration = $this->getMock('Doctrine\ORM\Configuration');

        $configuration
            ->expects($this->any())
            ->method('getEntityNamespace')
            ->will($this->returnValue('Dominikzogg\Pimple\Doctrine\Registry\ManagerRegistryTest'))
        ;

        $repository = $this->getMock('Doctrine\Common\Persistence\ObjectRepository');

        $metadataFactory = $this->getMock('Doctrine\ORM\Mapping\ClassMetadataFactory');

        $entityManager = $this
            ->getMockBuilder('Doctrine\ORM\EntityManager')
            ->disableOriginalConstructor()
            ->getMock()
        ;

        $entityManager
            ->expects($this->any())
            ->method('getConfiguration')
            ->will($this->returnValue($configuration))
        ;

        $entityManager
            ->expects($this->any())
            ->method('getRepository')
            ->will($this->returnValue($repository))
        ;

        $entityManager
            ->expects($this->any())
            ->method('getMetadataFactory')
            ->will($this->returnValue($metadataFactory))
        ;

        $app['orm.ems'] = new \Pimple(array(
            'default' => $entityManager,
        ));

        $app['orm.ems.default'] = 'default';

        return $app;
    }

    public function testRegisterDefaultImplementations()
    {
        $app = $this->createMockDefaultAppAndDeps();

        $doctrineOrmManagerRegistryProvider = new DoctrineOrmManagerRegistryProvider();
        $doctrineOrmManagerRegistryProvider->register($app);

        $this->assertEquals($app['doctrine']->getDefaultConnectionName(), 'default');
        $this->assertInstanceOf('Doctrine\DBAL\Connection', $app['doctrine']->getConnection());
        $this->assertInstanceOf('\Pimple', $app['doctrine']->getConnections());
        $this->assertCount(1, $app['doctrine']->getConnectionNames());

        $this->assertEquals($app['doctrine']->getDefaultManagerName(), 'default');
        $this->assertInstanceOf('Doctrine\ORM\EntityManager', $app['doctrine']->getManager());
        $this->assertInstanceOf('\Pimple', $app['doctrine']->getManagers());
        $this->assertCount(1, $app['doctrine']->getManagerNames());
        $this->assertEquals($app['doctrine']->getAliasNamespace('Test'), 'Dominikzogg\Pimple\Doctrine\Registry\ManagerRegistryTest');
        $this->assertInstanceOf('Doctrine\Common\Persistence\ObjectRepository', $app['doctrine']->getRepository('Dominikzogg\Pimple\Doctrine\Registry\ManagerRegistryTest'));
        $this->assertInstanceOf('Doctrine\ORM\EntityManager', $app['doctrine']->getManagerForClass('Dominikzogg\Pimple\Doctrine\Registry\ManagerRegistryTest'));
    }
}<commit_msg>fix the assert parameter order<commit_after><?php

namespace Dominikzogg\Pimple\Doctrine\Registry;

use Doctrine\ORM\EntityManager;
use Dominikzogg\Pimple\Provider\DoctrineOrmManagerRegistryProvider;

class ManagerRegistryTest extends \PHPUnit_Framework_TestCase
{
    /**
     * @return array
     */
    protected function createMockDefaultAppAndDeps()
    {
        $app = new \Pimple;

        $connection = $this
            ->getMockBuilder('Doctrine\DBAL\Connection')
            ->disableOriginalConstructor()
            ->getMock()
        ;

        $app['dbs'] = new \Pimple(array(
            'default' => $connection,
        ));

        $app['dbs.default'] = 'default';

        $configuration = $this->getMock('Doctrine\ORM\Configuration');

        $configuration
            ->expects($this->any())
            ->method('getEntityNamespace')
            ->will($this->returnValue('Dominikzogg\Pimple\Doctrine\Registry\ManagerRegistryTest'))
        ;

        $repository = $this->getMock('Doctrine\Common\Persistence\ObjectRepository');

        $metadataFactory = $this->getMock('Doctrine\ORM\Mapping\ClassMetadataFactory');

        $entityManager = $this
            ->getMockBuilder('Doctrine\ORM\EntityManager')
            ->disableOriginalConstructor()
            ->getMock()
        ;

        $entityManager
            ->expects($this->any())
            ->method('getConfiguration')
            ->will($this->returnValue($configuration))
        ;

        $entityManager
            ->expects($this->any())
            ->method('getRepository')
            ->will($this->returnValue($repository))
        ;

        $entityManager
            ->expects($this->any())
            ->method('getMetadataFactory')
            ->will($this->returnValue($metadataFactory))
        ;

        $app['orm.ems'] = new \Pimple(array(
            'default' => $entityManager,
        ));

        $app['orm.ems.default'] = 'default';

        return $app;
    }

    public function testRegisterDefaultImplementations()
    {
        $app = $this->createMockDefaultAppAndDeps();

        $doctrineOrmManagerRegistryProvider = new DoctrineOrmManagerRegistryProvider();
        $doctrineOrmManagerRegistryProvider->register($app);

        $this->assertEquals('default', $app['doctrine']->getDefaultConnectionName());
        $this->assertInstanceOf('Doctrine\DBAL\Connection', $app['doctrine']->getConnection());
        $this->assertInstanceOf('\Pimple', $app['doctrine']->getConnections());
        $this->assertCount(1, $app['doctrine']->getConnectionNames());
        $this->assertEquals('default', $app['doctrine']->getDefaultManagerName());
        $this->assertInstanceOf('Doctrine\ORM\EntityManager', $app['doctrine']->getManager());
        $this->assertInstanceOf('\Pimple', $app['doctrine']->getManagers());
        $this->assertCount(1, $app['doctrine']->getManagerNames());
        $this->assertEquals($app['doctrine']->getAliasNamespace('Test'), 'Dominikzogg\Pimple\Doctrine\Registry\ManagerRegistryTest');
        $this->assertInstanceOf('Doctrine\Common\Persistence\ObjectRepository', $app['doctrine']->getRepository('Dominikzogg\Pimple\Doctrine\Registry\ManagerRegistryTest'));
        $this->assertInstanceOf('Doctrine\ORM\EntityManager', $app['doctrine']->getManagerForClass('Dominikzogg\Pimple\Doctrine\Registry\ManagerRegistryTest'));
    }
}
{'fraction_non_alphanumeric': 0.15762962962962962, 'fraction_numerical': 0.0005925925925925926, 'mean_word_length': 3.04251497005988, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 113, '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': '5563702', 'n_tokens_mistral': 1860, 'n_tokens_neox': 1817, 'n_words': 200}