<commit_before><?php

namespace ActiveDoctrine\Tests\Functional;

use ActiveDoctrine\Tests\Fixtures\Entities\Bookshop\Book;

/**
 * SelectOneTest
 *
 * @author <NAME> <<EMAIL>>
 **/
class SelectOneTest extends FunctionalTestCase
{

    public function setup()
    {
        $this->loadSchema('bookshop');
    }

    public function testEmptyTable()
    {
        $this->assertNull(Book::selectOne($this->getConn())->execute());
    }

    public function testSingleId()
    {
        $this->loadData('bookshop');
        $book = Book::selectOne($this->getConn())
            ->where('id', '=', 3)
            ->execute();
        $this->assertInstanceOf('ActiveDoctrine\Tests\Fixtures\Entities\Bookshop\Book', $book);
        $this->assertSame('3', $book->id);
    }

    public function testOneFromManyResults()
    {
        $this->loadData('bookshop');
        $book = Book::selectOne($this->getConn())
            ->orderBy('id', 'DESC')
            ->limit(100)
            ->execute();
        $this->assertInstanceOf('ActiveDoctrine\Tests\Fixtures\Entities\Bookshop\Book', $book);
        $this->assertSame('50', $book->id);
    }

}<commit_msg>Asserting that selecting one entity works with both methods.<commit_after><?php

namespace ActiveDoctrine\Tests\Functional;

use ActiveDoctrine\Tests\Fixtures\Entities\Bookshop\Book;

/**
 * SelectOneTest
 *
 * @author <NAME> <<EMAIL>>
 **/
class SelectOneTest extends FunctionalTestCase
{

    public function setup()
    {
        $this->loadSchema('bookshop');
    }

    /**
     * Check that selecting one entity works with both methods.
     */
    public function selectorProvider()
    {
        return [
            [Book::selectOne($this->getConn())],
            [Book::select($this->getConn())->one()]
        ];
    }

    /**
     * @dataProvider selectorProvider()
     */
    public function testEmptyTable($selector)
    {
        $this->assertNull($selector->execute());
    }

    /**
     * @dataProvider selectorProvider()
     */
    public function testSingleId($selector)
    {
        $this->loadData('bookshop');
        $book = $selector->where('id', '=', 3)
            ->execute();
        $this->assertInstanceOf('ActiveDoctrine\Tests\Fixtures\Entities\Bookshop\Book', $book);
        $this->assertSame('3', $book->id);
    }

    /**
     * @dataProvider selectorProvider()
     */
    public function testOneFromManyResults($selector)
    {
        $this->loadData('bookshop');
        $book = $selector->orderBy('id', 'DESC')
            ->limit(100)
            ->execute();
        $this->assertInstanceOf('ActiveDoctrine\Tests\Fixtures\Entities\Bookshop\Book', $book);
        $this->assertSame('50', $book->id);
    }

}
{'fraction_non_alphanumeric': 0.16611295681063123, 'fraction_numerical': 0.00516795865633075, 'mean_word_length': 2.6375838926174495, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 47, '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': '3135827', 'n_tokens_mistral': 805, 'n_tokens_neox': 793, 'n_words': 123}