<commit_before><?php

use Tamayo\Stretchy\Connection;
use Tamayo\Stretchy\Index\Grammar;
use Tamayo\Stretchy\Index\Blueprint;


class IndexGrammarTest extends PHPUnit_Framework_TestCase
{

    public function testBasicCreateIndex()
    {
        $blueprint = new Blueprint('basic');
        $blueprint->create();

        $blueprint->shards(1);
        $blueprint->replicas(3);

        $json = $blueprint->toJson($this->getConnection(), $this->getGrammar());

        $this->assertEquals('{"index":"basic","body":{"settings":{"number_of_shards":1,"number_of_replicas":3}}}', $json);

    }

    public function testBasicCreateIndexWithPrefix()
    {
        $blueprint = new Blueprint('basic');
        $blueprint->create();

        $blueprint->shards(1);
        $blueprint->replicas(3);

        $grammar = $this->getGrammar();
        $grammar->setIndexPrefix('prefix_');

        $json = $blueprint->toJson($this->getConnection(), $grammar);

        $this->assertEquals('{"index":"prefix_basic","body":{"settings":{"number_of_shards":1,"number_of_replicas":3}}}', $json);

    }

    public function testCompileGetSettings()
    {
    	$grammar = $this->getGrammar();

    	$compiled = $grammar->compileGetSettings(['tamayo', 'stretchy']);

    	$this->assertEquals($compiled, ['index' => ['tamayo', 'stretchy']]);
    }

    public function getGrammar()
    {
        return new Grammar;
    }

    public function getConnection()
    {
        return Mockery::mock(Connection::class);
    }
}<commit_msg>updated for compatibility with php 5.4<commit_after><?php

use Tamayo\Stretchy\Connection;
use Tamayo\Stretchy\Index\Grammar;
use Tamayo\Stretchy\Index\Blueprint;


class IndexGrammarTest extends PHPUnit_Framework_TestCase
{

    public function testBasicCreateIndex()
    {
        $blueprint = new Blueprint('basic');
        $blueprint->create();

        $blueprint->shards(1);
        $blueprint->replicas(3);

        $json = $blueprint->toJson($this->getConnection(), $this->getGrammar());

        $this->assertEquals('{"index":"basic","body":{"settings":{"number_of_shards":1,"number_of_replicas":3}}}', $json);

    }

    public function testBasicCreateIndexWithPrefix()
    {
        $blueprint = new Blueprint('basic');
        $blueprint->create();

        $blueprint->shards(1);
        $blueprint->replicas(3);

        $grammar = $this->getGrammar();
        $grammar->setIndexPrefix('prefix_');

        $json = $blueprint->toJson($this->getConnection(), $grammar);

        $this->assertEquals('{"index":"prefix_basic","body":{"settings":{"number_of_shards":1,"number_of_replicas":3}}}', $json);

    }

    public function testCompileGetSettings()
    {
    	$grammar = $this->getGrammar();

    	$compiled = $grammar->compileGetSettings(['tamayo', 'stretchy']);

    	$this->assertEquals($compiled, ['index' => ['tamayo', 'stretchy']]);
    }

    public function getGrammar()
    {
        return new Grammar;
    }

    public function getConnection()
    {
        return Mockery::mock('Tamayo\Stretchy\Connection');
    }
}
{'fraction_non_alphanumeric': 0.17080339647289353, 'fraction_numerical': 0.005878510777269758, 'mean_word_length': 3.551263001485884, 'pattern_counts': {'":': 20, '<': 5, '<?xml version=': 0, '>': 41, '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': '6518561', 'n_tokens_mistral': 1012, 'n_tokens_neox': 955, 'n_words': 135}