<commit_before><?php

namespace Doctrine\Tests\ORM\Functional\Ticket;

require_once __DIR__ . '/../../../TestInit.php';

use Doctrine\Tests\Models\Generic\DateTimeModel;

/**
 * @group DDC-657
 */
class DDC657Test extends \Doctrine\Tests\OrmFunctionalTestCase
{
    const NS = 'Doctrine\Tests\Models\Generic';

    protected function setUp()
    {
        $this->useModelSet('generic');
        parent::setUp();

        $this->loadFixtures();
    }

    public function testEntitySingleResult()
    {
        $query      = $this->_em->createQuery('SELECT d FROM ' . self::NS . '\DateTimeModel d');
        $datetime   = $query->setMaxResults(1)->getSingleResult();

        $this->assertInstanceOf('Doctrine\Tests\Models\Generic\DateTimeModel', $datetime);

        $this->assertInstanceOf('DateTime', $datetime->datetime);
        $this->assertInstanceOf('DateTime', $datetime->time);
        $this->assertInstanceOf('DateTime', $datetime->date);
    }

    public function testScalarResult()
    {
        $query      = $this->_em->createQuery('SELECT d.id, d.time, d.date, d.datetime FROM ' . self::NS . '\DateTimeModel d ORDER BY d.date ASC');
        $result     = $query->getScalarResult();

        $this->assertCount(2,$result);

        $this->assertEquals('11:11:11', $result[0]['time']);
        $this->assertEquals('2010-01-01', $result[0]['date']);
        $this->assertEquals('2010-01-01 11:11:11', $result[0]['datetime']);

        $this->assertEquals('12:12:12', $result[1]['time']);
        $this->assertEquals('2010-02-02', $result[1]['date']);
        $this->assertEquals('2010-02-02 12:12:12', $result[1]['datetime']);
    }

    public function testaTicketEntityArrayResult()
    {
        $query      = $this->_em->createQuery('SELECT d FROM ' . self::NS . '\DateTimeModel d ORDER BY d.date ASC');
        $result     = $query->getArrayResult();

        $this->assertCount(2,$result);

        $this->assertInstanceOf('DateTime', $result[0]['datetime']);
        $this->assertInstanceOf('DateTime', $result[0]['time']);
        $this->assertInstanceOf('DateTime', $result[0]['date']);

        $this->assertInstanceOf('DateTime', $result[1]['datetime']);
        $this->assertInstanceOf('DateTime', $result[1]['time']);<commit_msg>Fix test for non-mysql like datetimes.<commit_after><?php

namespace Doctrine\Tests\ORM\Functional\Ticket;

require_once __DIR__ . '/../../../TestInit.php';

use Doctrine\Tests\Models\Generic\DateTimeModel;

/**
 * @group DDC-657
 */
class DDC657Test extends \Doctrine\Tests\OrmFunctionalTestCase
{
    const NS = 'Doctrine\Tests\Models\Generic';

    protected function setUp()
    {
        $this->useModelSet('generic');
        parent::setUp();

        $this->loadFixtures();
    }

    public function testEntitySingleResult()
    {
        $query      = $this->_em->createQuery('SELECT d FROM ' . self::NS . '\DateTimeModel d');
        $datetime   = $query->setMaxResults(1)->getSingleResult();

        $this->assertInstanceOf('Doctrine\Tests\Models\Generic\DateTimeModel', $datetime);

        $this->assertInstanceOf('DateTime', $datetime->datetime);
        $this->assertInstanceOf('DateTime', $datetime->time);
        $this->assertInstanceOf('DateTime', $datetime->date);
    }

    public function testScalarResult()
    {
        $query      = $this->_em->createQuery('SELECT d.id, d.time, d.date, d.datetime FROM ' . self::NS . '\DateTimeModel d ORDER BY d.date ASC');
        $result     = $query->getScalarResult();

        $this->assertCount(2,$result);

        $this->assertContains('11:11:11', $result[0]['time']);
        $this->assertContains('2010-01-01', $result[0]['date']);
        $this->assertContains('2010-01-01 11:11:11', $result[0]['datetime']);

        $this->assertContains('12:12:12', $result[1]['time']);
        $this->assertContains('2010-02-02', $result[1]['date']);
        $this->assertContains('2010-02-02 12:12:12', $result[1]['datetime']);
    }

    public function testaTicketEntityArrayResult()
    {
        $query      = $this->_em->createQuery('SELECT d FROM ' . self::NS . '\DateTimeModel d ORDER BY d.date ASC');
        $result     = $query->getArrayResult();

        $this->assertCount(2,$result);

        $this->assertInstanceOf('DateTime', $result[0]['datetime']);
        $this->assertInstanceOf('DateTime', $result[0]['time']);
        $this->assertInstanceOf('DateTime', $result[0]['date']);

        $this->assertInstanceOf('DateTime', $result[1]['datetime']);
        $this->assertInstanceOf('DateTime', $result[1]['time']);
{'fraction_non_alphanumeric': 0.1917747965691665, 'fraction_numerical': 0.033428634264350124, 'mean_word_length': 3.3479923518164436, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 67, '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': '7246966', 'n_tokens_mistral': 1446, 'n_tokens_neox': 1336, 'n_words': 212}