<commit_before><?php
class ReaderTest extends \PHPUnit_Framework_TestCase
{
    /**
     * @var \PHPExif\Reader\Reader
     */
    protected $reader;

    /**
     * Setup function before the tests
     */
    public function setUp()
    {
        $adapter = $this->getMock('\PHPExif\Adapter\AdapterInterface');
        $this->reader = new \PHPExif\Reader\Reader($adapter);
    }

    /**
     * @group reader
     * @covers \PHPExif\Reader\Reader::__construct
     */
    public function testConstructorWithAdapter()
    {
        $mock = $this->getMock('\PHPExif\Adapter\AdapterInterface');
        $reflProperty = new \ReflectionProperty('\PHPExif\Reader\Reader', 'adapter');
        $reflProperty->setAccessible(true);

        $reader = new \PHPExif\Reader\Reader($mock);

        $this->assertSame($mock, $reflProperty->getValue($reader));
    }

    /**
     * @group reader
     * @covers \PHPExif\Reader\Reader::getAdapter
     */
    public function testGetAdapterFromProperty()
    {
        $mock = $this->getMock('\PHPExif\Adapter\AdapterInterface');

        $reflProperty = new \ReflectionProperty('\PHPExif\Reader\Reader', 'adapter');
        $reflProperty->setAccessible(true);
        $reflProperty->setValue($this->reader, $mock);

        $this->assertSame($mock, $this->reader->getAdapter());
    }

    /**
     * @group reader
     * @covers \PHPExif\Reader\Reader::read
     */
    public function testGetExifPassedToAdapter()
    {
        $adapter = $this->getMock('\PHPExif\Adapter\AdapterInterface');
        $adapter->expects($this->once())->method('getExifFromFile');

        $reflProperty = new \ReflectionProperty('\PHPExif\Reader\Reader', 'adapter');
        $reflProperty->setAccessible(true);
        $reflProperty->setValue($this->reader, $adapter);

        $this->reader->read('/tmp/foo.bar');
    }

    /**
     * @group reader
     * @covers \PHPExif\Reader\Reader::factory
     * @expectedException InvalidArgumentException
     */
    public function testFactoryThrowsException()
    {
        \PHPExif\Reader\Reader::factory('foo');
    }

    /**
     * @group reader
     * @covers \PHPExif\Reader\Reader::factory
     */
    public function testFactoryReturnsCorrectType()
    {
        $reader = \PHPExif\Reader\Reader::factory(\PHPExif\Reader\Reader::TYPE_NATIVE);

        $this->assertInstanceOf('\PHPExif\Reader\Reader', $reader);
    }

    /**
     * @group reader
     * @covers \PHPExif\Reader\Reader::factory
     */
    public function testFactoryAdapterTypeNative()
    {
        $reader = \PHPExif\Reader\Reader::factory(\PHPExif\Reader\Reader::TYPE_NATIVE);
        $reflProperty = new \ReflectionProperty('\PHPExif\Reader\Reader', 'adapter');
        $reflProperty->setAccessible(true);

        $adapter = $reflProperty->getValue($reader);

        $this->assertInstanceOf('\PHPExif\Adapter\Native', $adapter);
    }

    /**
     * @group reader
     * @covers \PHPExif\Reader\Reader::factory
     */
    public function testFactoryAdapterTypeExiftool()
    {
        $reader = \PHPExif\Reader\Reader::factory(\PHPExif\Reader\Reader::TYPE_EXIFTOOL);
        $reflProperty = new \ReflectionProperty('\PHPExif\Reader\Reader', 'adapter');
        $reflProperty->setAccessible(true);

        $adapter = $reflProperty->getValue($reader);

        $this->assertInstanceOf('\PHPExif\Adapter\Exiftool', $adapter);
    }

}
<commit_msg>Add extra unit tests for Reader class<commit_after><?php
class ReaderTest extends \PHPUnit_Framework_TestCase
{
    /**
     * @var \PHPExif\Reader\Reader
     */
    protected $reader;

    /**
     * Setup function before the tests
     */
    public function setUp()
    {
        $adapter = $this->getMock('\PHPExif\Adapter\AdapterInterface');
        $this->reader = new \PHPExif\Reader\Reader($adapter);
    }

    /**
     * @group reader
     * @covers \PHPExif\Reader\Reader::__construct
     */
    public function testConstructorWithAdapter()
    {
        $mock = $this->getMock('\PHPExif\Adapter\AdapterInterface');
        $reflProperty = new \ReflectionProperty('\PHPExif\Reader\Reader', 'adapter');
        $reflProperty->setAccessible(true);

        $reader = new \PHPExif\Reader\Reader($mock);

        $this->assertSame($mock, $reflProperty->getValue($reader));
    }

    /**
     * @group reader
     * @covers \PHPExif\Reader\Reader::getAdapter
     */
    public function testGetAdapterFromProperty()
    {
        $mock = $this->getMock('\PHPExif\Adapter\AdapterInterface');

        $reflProperty = new \ReflectionProperty('\PHPExif\Reader\Reader', 'adapter');
        $reflProperty->setAccessible(true);
        $reflProperty->setValue($this->reader, $mock);

        $this->assertSame($mock, $this->reader->getAdapter());
    }

    /**
     * @group reader
     * @covers \PHPExif\Reader\Reader::getAdapter
     * @expectedException \PHPExif\Adapter\NoAdapterException
     */
    public function testGetAdapterThrowsExceptionWhenNoAdapterIsSet()
    {
        $reflProperty = new \ReflectionProperty('\PHPExif\Reader\Reader', 'adapter');
        $reflProperty->setAccessible(true);
        $reflProperty->setValue($this->reader, null);

        $this->reader->getAdapter();
    }

    /**
     * @group reader
     * @covers \PHPExif\Reader\Reader::read
     */
    public function testGetExifPassedToAdapter()
    {
        $adapter = $this->getMock('\PHPExif\Adapter\AdapterInterface');
        $adapter->expects($this->once())->method('getExifFromFile');

        $reflProperty = new \ReflectionProperty('\PHPExif\Reader\Reader', 'adapter');
        $reflProperty->setAccessible(true);
        $reflProperty->setValue($this->reader, $adapter);

        $this->reader->read('/tmp/foo.bar');
    }

    /**
     * @group reader
     * @covers \PHPExif\Reader\Reader::factory
     * @expectedException InvalidArgumentException
     */
    public function testFactoryThrowsException()
    {
        \PHPExif\Reader\Reader::factory('foo');
    }

    /**
     * @group reader
     * @covers \PHPExif\Reader\Reader::factory
     */
    public function testFactoryReturnsCorrectType()
    {
        $reader = \PHPExif\Reader\Reader::factory(\PHPExif\Reader\Reader::TYPE_NATIVE);

        $this->assertInstanceOf('\PHPExif\Reader\Reader', $reader);
    }

    /**
     * @group reader
     * @covers \PHPExif\Reader\Reader::factory
     */
    public function testFactoryAdapterTypeNative()
    {
        $reader = \PHPExif\Reader\Reader::factory(\PHPExif\Reader\Reader::TYPE_NATIVE);
        $reflProperty = new \ReflectionProperty('\PHPExif\Reader\Reader', 'adapter');
        $reflProperty->setAccessible(true);

        $adapter = $reflProperty->getValue($reader);

        $this->assertInstanceOf('\PHPExif\Adapter\Native', $adapter);
    }

    /**
     * @group reader
     * @covers \PHPExif\Reader\Reader::factory
     */
    public function testFactoryAdapterTypeExiftool()
    {
        $reader = \PHPExif\Reader\Reader::factory(\PHPExif\Reader\Reader::TYPE_EXIFTOOL);
        $reflProperty = new \ReflectionProperty('\PHPExif\Reader\Reader', 'adapter');
        $reflProperty->setAccessible(true);

        $adapter = $reflProperty->getValue($reader);

        $this->assertInstanceOf('\PHPExif\Adapter\Exiftool', $adapter);
    }

    /**
     * @group reader
     * @covers \PHPExif\Reader\Reader::getExifFromFile
     */
    public function testGetExifFromFileCallsReadMethod()
    {
        $mock = $this->getMock(
            '\\PHPExif\\Reader\\Reader',
            array('read'),
            array(),
            '',
            false
        );

        $expected = '/foo/bar/baz';
        $expectedResult = 'test';

        $mock->expects($this->once())
            ->method('read')
            ->with($this->equalTo($expected))
            ->will($this->returnValue($expectedResult));

        $result = $mock->getExifFromFile($expected);
        $this->assertEquals($expectedResult, $result);
    }
}


{'fraction_non_alphanumeric': 0.15372025682991314, 'fraction_numerical': 0.0, 'mean_word_length': 2.7348377997179125, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 76, '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': '4805752', 'n_tokens_mistral': 2372, 'n_tokens_neox': 2345, 'n_words': 316}