<commit_before><?php

namespace DMR\Functional;

use Doctrine\Common\EventManager;
use Doctrine\Common\Annotations\AnnotationReader;
use Doctrine\Common\Cache\ArrayCache;
use Doctrine\Common\Annotations\CachedReader;
use Doctrine\Common\Persistence\Mapping\Driver\MappingDriver;
use Doctrine\Common\Persistence\Mapping\Driver\SymfonyFileLocator;
use Doctrine\Common\Persistence\Mapping\Driver\MappingDriverChain;
// ORM specific
use Doctrine\ORM\Mapping\DefaultQuoteStrategy;
use Doctrine\ORM\Mapping\DefaultNamingStrategy;
use Doctrine\ORM\Mapping\Driver\AnnotationDriver as AnnotationDriverORM;
use Doctrine\ORM\EntityManager;
use Doctrine\ORM\Mapping\Driver\SimplifiedYamlDriver;
use Doctrine\ORM\Mapping\Driver\SimplifiedXmlDriver;
// ODM specific
use Doctrine\ODM\MongoDB\Mapping\Driver\AnnotationDriver as AnnotationDriverODM;
use Doctrine\ODM\MongoDB\DocumentManager;
use Doctrine\ODM\MongoDB\Mapping\Driver\YamlDriver;
use Doctrine\ODM\MongoDB\Mapping\Driver\XmlDriver;

/**
 * Functional tests.
 *
 * @author <NAME> <<EMAIL>>
 */
class BaseTestCase extends \PHPUnit_Framework_TestCase
{
    const DRIVER_NAMESPACE = 'DMR\Functional\Mock\Extension\Encoder';

    /**
     * @var EventManager
     */
    protected $evm;

    public function getMockRegistries()
    {
    	$registries = array();

    	$registry = $this->getMockBuilder('Doctrine\Common\Persistence\AbstractManagerRegistry')
    		->disableOriginalConstructor()
    		->setMethods(array('getManagerForClass'))
    		->getMockForAbstractClass();

        $instance = $this;

    	$callback = function ($class) use ($instance) {

    		if (strpos($class, 'ORM') > -1) {
    			$chain = $instance->getMockORMMappingDriver();

    			return $instance->getMockSqliteEntityManager($chain);
    		}

    		if (strpos($class, 'ODM') > -1) {
    			$chain = $instance->getMockMongoDBMappingDriver();

    			return $instance->getMockMongoDBDocumentManager($chain);
    		}
    	};
    	
    	$this->assertNull($callback(''));
    	$this->assertInstanceOf('Doctrine\ORM\EntityManager', $callback('ORM'));
    	$this->assertInstanceOf('Doctrine\ODM\MongoDB\DocumentManager', $callback('ODM'));

    	$registry->expects($this->any())
    		->method('getManagerForClass')
    		->will($this->returnCallback($callback));
    	
    	$registries[] = $registry;
    	
    	$registry = $this->getMockBuilder('Doctrine\Common\Persistence\AbstractManagerRegistry')
	    	->disableOriginalConstructor()
	    	->setMethods(array('getManagerForClass'))<commit_msg>Fixes the bug that occurs in PHP 5.3 when $this is used inside a closure in a method<commit_after><?php

namespace DMR\Functional;

use Doctrine\Common\EventManager;
use Doctrine\Common\Annotations\AnnotationReader;
use Doctrine\Common\Cache\ArrayCache;
use Doctrine\Common\Annotations\CachedReader;
use Doctrine\Common\Persistence\Mapping\Driver\MappingDriver;
use Doctrine\Common\Persistence\Mapping\Driver\SymfonyFileLocator;
use Doctrine\Common\Persistence\Mapping\Driver\MappingDriverChain;
// ORM specific
use Doctrine\ORM\Mapping\DefaultQuoteStrategy;
use Doctrine\ORM\Mapping\DefaultNamingStrategy;
use Doctrine\ORM\Mapping\Driver\AnnotationDriver as AnnotationDriverORM;
use Doctrine\ORM\EntityManager;
use Doctrine\ORM\Mapping\Driver\SimplifiedYamlDriver;
use Doctrine\ORM\Mapping\Driver\SimplifiedXmlDriver;
// ODM specific
use Doctrine\ODM\MongoDB\Mapping\Driver\AnnotationDriver as AnnotationDriverODM;
use Doctrine\ODM\MongoDB\DocumentManager;
use Doctrine\ODM\MongoDB\Mapping\Driver\YamlDriver;
use Doctrine\ODM\MongoDB\Mapping\Driver\XmlDriver;

/**
 * Functional tests.
 *
 * @author <NAME> <<EMAIL>>
 */
class BaseTestCase extends \PHPUnit_Framework_TestCase
{
    const DRIVER_NAMESPACE = 'DMR\Functional\Mock\Extension\Encoder';

    /**
     * @var EventManager
     */
    protected $evm;

    public function getMockRegistries()
    {
    	$registries = array();

    	$registry = $this->getMockBuilder('Doctrine\Common\Persistence\AbstractManagerRegistry')
    		->disableOriginalConstructor()
    		->setMethods(array('getManagerForClass'))
    		->getMockForAbstractClass();

        $ormChain = $this->getMockORMMappingDriver();
        $em = $this->getMockSqliteEntityManager($ormChain);

        $odmChain = $this->getMockMongoDBMappingDriver();
        $dm = $this->getMockMongoDBDocumentManager($odmChain);

    	$callback = function ($class) use ($em, $dm) {

    		if (strpos($class, 'ORM') > -1) {
    			return $em;
    		}

    		if (strpos($class, 'ODM') > -1) {
    			return $dm;
    		}
    	};
    	
    	$this->assertNull($callback(''));
    	$this->assertInstanceOf('Doctrine\ORM\EntityManager', $callback('ORM'));
    	$this->assertInstanceOf('Doctrine\ODM\MongoDB\DocumentManager', $callback('ODM'));

    	$registry->expects($this->any())
    		->method('getManagerForClass')
    		->will($this->returnCallback($callback));
    	
    	$registries[] = $registry;
    	
    	$registry = $this->getMockBuilder('Doctrine\Common\Persistence\AbstractManagerRegistry')
	    	->disableOriginalConstructor()
	    	->setMethods(array('getManagerForClass'))
{'fraction_non_alphanumeric': 0.13239326282804545, 'fraction_numerical': 0.0011750881316098707, 'mean_word_length': 4.319791666666666, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 51, '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': '6703907', 'n_tokens_mistral': 1635, 'n_tokens_neox': 1606, 'n_words': 235}