<commit_before><?php

use Mdd\QueryBuilder\Queries\Parts;

class SelectPartBuilderTest extends PHPUnit_Framework_TestCase
{
    /**
     * @dataProvider providerTestSelectViaConstructor
     */
    public function testSelectViaConstructor($expected, $columns)
    {
        $select = new Parts\Select($columns);

        $this->assertSame($expected, $select->toString());
    }

    /**
     * @dataProvider providerTestSelectViaConstructor
     */
    public function testSelectViaSetter($expected, $columns)
    {
        $select = new Parts\Select();
        $select->select($columns);

        $this->assertSame($expected, $select->toString());
    }

    public function providerTestSelectViaConstructor()
    {
        return array(
            'single column'      => array('SELECT name', 'name'),
            'multiple column'    => array('SELECT name, color, age', array('name', 'color', 'age')),
            'duplicated columns' => array('SELECT name, color, age', array('name', 'color', 'age', 'name')),
            'all columns'        => array('SELECT *', '*'),
        );
    }

    public function testAddColumnsOnTheFly()
    {
        $select = new Parts\Select('id');
        $select
            ->select('name')
            ->select(array('color', 'taste'));

        $this->assertSame('SELECT id, name, color, taste', $select->toString());
    }
}<commit_msg>Add select part test for invalid column name<commit_after><?php

use Mdd\QueryBuilder\Queries\Parts;

class SelectPartBuilderTest extends PHPUnit_Framework_TestCase
{
    /**
     * @dataProvider providerTestSelectViaConstructor
     */
    public function testSelectViaConstructor($expected, $columns)
    {
        $select = new Parts\Select($columns);

        $this->assertSame($expected, $select->toString());
    }

    /**
     * @dataProvider providerTestSelectViaConstructor
     */
    public function testSelectViaSetter($expected, $columns)
    {
        $select = new Parts\Select();
        $select->select($columns);

        $this->assertSame($expected, $select->toString());
    }

    public function providerTestSelectViaConstructor()
    {
        return array(
            'single column'      => array('SELECT name', 'name'),
            'multiple column'    => array('SELECT name, color, age', array('name', 'color', 'age')),
            'duplicated columns' => array('SELECT name, color, age', array('name', 'color', 'age', 'name')),
            'all columns'        => array('SELECT *', '*'),
        );
    }

    public function testAddColumnsOnTheFly()
    {
        $select = new Parts\Select('id');
        $select
            ->select('name')
            ->select(array('color', 'taste'));

        $this->assertSame('SELECT id, name, color, taste', $select->toString());
    }

    /**
     * @expectedException \InvalidArgumentException
     */
    public function testInvalidColumnName()
    {
        $select = new Parts\Select(array('poney', new stdClass()));

        $select->toString();
    }
}
{'fraction_non_alphanumeric': 0.15172642762284197, 'fraction_numerical': 0.0, 'mean_word_length': 2.674390243902439, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 30, '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': '5822323', 'n_tokens_mistral': 832, 'n_tokens_neox': 806, 'n_words': 174}