<commit_before><?php

namespace Illuminated\Helpers\HelperFunctions\Tests\Db;

use Illuminated\Helpers\HelperFunctions\Tests\TestCase;
use Mockery;

class DbMysqlVariableTest extends TestCase
{
    /** @test */
    public function it_returns_false_for_unexisting_mysql_variable()
    {
        $mock = Mockery::mock('alias:Illuminate\Support\Facades\DB');
        $mock->shouldReceive('selectOne')
            ->withArgs(['show variables where variable_name = ?', ['fake']])
            ->once()
            ->andReturnNull();

        $this->assertFalse(db_mysql_variable('fake'));
    }

    /** @test */
    public function it_returns_value_for_existing_mysql_variable()
    {
        $mock = Mockery::mock('alias:Illuminate\Support\Facades\DB');
        $mock->shouldReceive('selectOne')
             ->withArgs(['show variables where variable_name = ?', ['hostname']])
             ->once()
             ->andReturnUsing(function () {
                 return (object) ['Variable_name' => 'hostname', 'Value' => 'localhost'];
             });

        $this->assertEquals('localhost', db_mysql_variable('hostname'));
    }
}<commit_msg>Mockery 1.0 features used.<commit_after><?php

namespace Illuminated\Helpers\HelperFunctions\Tests\Db;

use Illuminated\Helpers\HelperFunctions\Tests\TestCase;

class DbMysqlVariableTest extends TestCase
{
    /** @test */
    public function it_returns_false_for_unexisting_mysql_variable()
    {
        $mock = mock('alias:Illuminate\Support\Facades\DB');
        $mock->expects()->selectOne('show variables where variable_name = ?', ['fake'])->andReturnNull();

        $this->assertFalse(db_mysql_variable('fake'));
    }

    /** @test */
    public function it_returns_value_for_existing_mysql_variable()
    {
        $mock = mock('alias:Illuminate\Support\Facades\DB');
        $mock->expects()->selectOne('show variables where variable_name = ?', ['hostname'])
                        ->andReturn((object) ['Variable_name' => 'hostname', 'Value' => 'localhost']);

        $this->assertEquals('localhost', db_mysql_variable('hostname'));
    }
}
{'fraction_non_alphanumeric': 0.15178997613365156, 'fraction_numerical': 0.0009546539379474941, 'mean_word_length': 3.3216494845360827, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 25, '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': '2134104', 'n_tokens_mistral': 591, 'n_tokens_neox': 597, 'n_words': 90}