<commit_before><commit_msg>Add connection tests<commit_after><?php

namespace Tests\Database;

use PDO;
use Mockery;
use Tests\TestCase;
use Marquine\Etl\Database\Query;
use Marquine\Etl\Database\Statement;
use Marquine\Etl\Database\Connection;
use Marquine\Etl\Database\Transaction;
use Mockery\Adapter\Phpunit\MockeryPHPUnitIntegration;

class ConnectionTest extends TestCase
{
    use MockeryPHPUnitIntegration;

    protected $pdo;

    protected $connection;

    protected function setUp()
    {
        parent::setUp();

        $this->pdo = Mockery::mock(PDO::class);
        $this->connection = new Connection($this->pdo);
    }

    /** @test */
    function get_a_new_query_instance()
    {
        $this->assertInstanceOf(Query::class, $this->connection->query());
    }

    /** @test */
    function get_a_new_statement_instance()
    {
        $this->assertInstanceOf(Statement::class, $this->connection->statement());
    }

    /** @test */
    function get_a_new_transaction_instance()
    {
        $this->assertInstanceOf(Transaction::class, $this->connection->transaction(true));
    }

    /** @test */
    function dynamically_pass_method_calls_to_the_pdo_instance()
    {
        $this->pdo->shouldReceive('method')->once()->with('param');

        $this->connection->method('param');
    }
}
{'fraction_non_alphanumeric': 0.14361702127659576, 'fraction_numerical': 0.0, 'mean_word_length': 3.557093425605536, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 21, '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': '3498225', 'n_tokens_mistral': 411, 'n_tokens_neox': 401, 'n_words': 60}