<commit_before><?php

namespace MartiAdrogue\SqlBuilder\Test;

use Mockery;
use MartiAdrogue\SqlBuilder\FromBuilder;
use MartiAdrogue\SqlBuilder\JoinBuilder;

class JoinBuilderTest extends \PHPUnit_Framework_TestCase
{
    private $joinBuilder;

    public function setUp()
    {
        $formBuilder = Mockery::mock(FromBuilder::class);
        $formBuilder->shouldReceive('__toString')->times(1)->andReturn('SELECT row1, row2, row3, row4 FROM tableA');
        $this->joinBuilder = new JoinBuilder($formBuilder);
    }

    /**
     * @test
     */
    public function shouldReturnAFullSelectStatementAccordingWithSql92Standard()
    {
        $selectSyntax = '/.*\sJOIN\sON\s.*/';
        $sqlSelect = $this->joinBuilder->join('JOIN ON tableB id = tableA_id');

        $this->assertRegExp(
            $selectSyntax,
            $sqlSelect->__toString(),
            'An statement SQL Select must have the specified sintax from the SQL-92 standard.'
        );
    }

    /**
     * @test
     */
    public function shouldChangeStateOfFromAndReturnJoinStatementObject()
    {
        $sqlSelect = $this->joinBuilder->join('JOIN ON tableB id = tableA_id');
        $this->assertInstanceOf(
            JoinBuilder::class,
            $sqlSelect,
            'On change the JoinBuilder It must return an instance of same Builder, JoinBuilder, to add another join.'
        );
    }
<commit_msg>Test cases for with... methods<commit_after><?php

namespace MartiAdrogue\SqlBuilder\Test;

use Mockery;
use MartiAdrogue\SqlBuilder\FromBuilder;
use MartiAdrogue\SqlBuilder\JoinBuilder;
use MartiAdrogue\SqlBuilder\WhereBuilder;
use MartiAdrogue\SqlBuilder\LimitBuilder;
use MartiAdrogue\SqlBuilder\HavingBuilder;

class JoinBuilderTest extends \PHPUnit_Framework_TestCase
{
    private $joinBuilder;

    public function setUp()
    {
        $formBuilder = Mockery::mock(FromBuilder::class);
        $formBuilder->shouldReceive('__toString')->times(1)->andReturn('SELECT row1, row2, row3, row4 FROM tableA');
        $this->joinBuilder = new JoinBuilder($formBuilder);
    }

    /**
     * @test
     */
    public function shouldReturnAFullSelectStatementAccordingWithSql92Standard()
    {
        $selectSyntax = '/.*\sJOIN\sON\s.*/';
        $sqlSelect = $this->joinBuilder->join('JOIN ON tableB id = tableA_id');

        $this->assertRegExp(
            $selectSyntax,
            $sqlSelect->__toString(),
            'An statement SQL Select must have the specified sintax from the SQL-92 standard.'
        );
    }

    /**
     * @test
     */
    public function shouldChangeStateOfFromAndReturnJoinStatementObject()
    {
        $sqlSelect = $this->joinBuilder->join('JOIN ON tableB id = tableA_id');
        $this->assertInstanceOf(
            JoinBuilder::class,
            $sqlSelect,
            'On change the JoinBuilder It must return an instance of same Builder, JoinBuilder, to add another join.'
        );
    }

    /**
     * @test
     */
    public function shouldReturnInstanceOfWherebuilderCreatedWhithCurrentBuilder()
    {
        $sqlSelect = $this->joinBuilder->withWhere('title = \'lorem ipsum dolor sit amen\'');
        $this->assertInstanceOf(
            WhereBuilder::class,
            $sqlSelect,
            'JoinBuilder must return a instance of WhereBuilder to let continue '.
            'building the query with all statements.'
        );
    }

    /**
     * @test
     */
    public function shouldReturnInstanceOfHavingbuilderFromGroupbyCall()
    {
        $sqlSelect = $this->joinBuilder->withGroupBy(['row1', 'row2', 'row3']);
        $this->assertInstanceOf(
            HavingBuilder::class,
            $sqlSelect,
            'JoinBuilder must return a instance of HavingBuilder from a GroupByBuilder ' .
            'call of action, to let continue building the query with all statements.'
        );
    }

    /**
     * @test
     */
    public function shouldReturnInstanceOfLimitbuilderFromOrderbyCall()
    {
        $sqlSelect = $this->joinBuilder->withOrderBy(['row1', 'row2', 'row3']);
        $this->assertInstanceOf(
            LimitBuilder::class,
            $sqlSelect,
            'JoinBuilder must return a instance of LimitBuilder from a OrderByBuilder ' .
            'call of action, to let finish the query with a Limit statement or not.'
        );
    }

{'fraction_non_alphanumeric': 0.10808942152569717, 'fraction_numerical': 0.0055312283936390875, 'mean_word_length': 2.607647547797174, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 34, 'https://': 0, 'lorem ipsum': 1, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2068985', 'n_tokens_mistral': 1217, 'n_tokens_neox': 1193, 'n_words': 284}