<commit_before><?php

namespace BetterReflectionTest\Reflector;

use BetterReflection\Reflection\ReflectionClass;
use BetterReflection\Reflector\ClassReflector;
use BetterReflection\Reflector\Generic;
use BetterReflection\SourceLocator\Type\SingleFileSourceLocator;
use BetterReflection\SourceLocator\Type\StringSourceLocator;

/**
 * @covers \BetterReflection\Reflector\ClassReflector
 */
class ClassReflectorTest extends \PHPUnit_Framework_TestCase
{
    public function testGetClassesFromFile()
    {
        $classes = (new ClassReflector(
            new SingleFileSourceLocator(__DIR__ . '/../Fixture/ExampleClass.php')
        ))->getAllClasses();

        $this->assertContainsOnlyInstancesOf(ReflectionClass::class, $classes);
        $this->assertCount(8, $classes);
    }

    public function testReflectProxiesToGenericReflectMethod()
    {
        $reflector = new ClassReflector(new StringSourceLocator('<?php'));

        $reflectionMock = $this->getMockBuilder(ReflectionClass::class)
            ->disableOriginalConstructor()
            ->getMock();

        $genericReflectorMock = $this->getMockBuilder(Generic::class)
            ->setMethods(['reflect'])
            ->disableOriginalConstructor()
            ->getMock();

        $genericReflectorMock->expects($this->once())
            ->method('reflect')
            ->will($this->returnValue($reflectionMock));

        $reflectorReflection = new \ReflectionObject($reflector);
        $reflectorReflectorReflection = $reflectorReflection->getProperty('reflector');
        $reflectorReflectorReflection->setAccessible(true);
        $reflectorReflectorReflection->setValue($reflector, $genericReflectorMock);

        $reflector->reflect('MyClass');
    }
}<commit_msg>Added test for buildDefaultReflector function<commit_after><?php

namespace BetterReflectionTest\Reflector;

use BetterReflection\Reflection\ReflectionClass;
use BetterReflection\Reflector\ClassReflector;
use BetterReflection\Reflector\Generic;
use BetterReflection\SourceLocator\Type\AggregateSourceLocator;
use BetterReflection\SourceLocator\Type\SingleFileSourceLocator;
use BetterReflection\SourceLocator\Type\StringSourceLocator;

/**
 * @covers \BetterReflection\Reflector\ClassReflector
 */
class ClassReflectorTest extends \PHPUnit_Framework_TestCase
{
    public function testGetClassesFromFile()
    {
        $classes = (new ClassReflector(
            new SingleFileSourceLocator(__DIR__ . '/../Fixture/ExampleClass.php')
        ))->getAllClasses();

        $this->assertContainsOnlyInstancesOf(ReflectionClass::class, $classes);
        $this->assertCount(8, $classes);
    }

    public function testReflectProxiesToGenericReflectMethod()
    {
        $reflector = new ClassReflector(new StringSourceLocator('<?php'));

        $reflectionMock = $this->getMockBuilder(ReflectionClass::class)
            ->disableOriginalConstructor()
            ->getMock();

        $genericReflectorMock = $this->getMockBuilder(Generic::class)
            ->setMethods(['reflect'])
            ->disableOriginalConstructor()
            ->getMock();

        $genericReflectorMock->expects($this->once())
            ->method('reflect')
            ->will($this->returnValue($reflectionMock));

        $reflectorReflection = new \ReflectionObject($reflector);
        $reflectorReflectorReflection = $reflectorReflection->getProperty('reflector');
        $reflectorReflectorReflection->setAccessible(true);
        $reflectorReflectorReflection->setValue($reflector, $genericReflectorMock);

        $reflector->reflect('MyClass');
    }

    public function testBuildDefaultReflector()
    {
        $defaultReflector = ClassReflector::buildDefaultReflector();

        $genericReflector = $this->getObjectAttribute($defaultReflector, 'reflector');

        $sourceLocator = $this->getObjectAttribute($genericReflector, 'sourceLocator');
        $this->assertInstanceOf(AggregateSourceLocator::class, $sourceLocator);
    }
}
{'fraction_non_alphanumeric': 0.1163024365737252, 'fraction_numerical': 0.0005023863350916855, 'mean_word_length': 4.015113350125945, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 44, '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': '4362014', 'n_tokens_mistral': 1029, 'n_tokens_neox': 1054, 'n_words': 141}