<?php

namespace Tests\Unit;

use Tests\BaseTestCase;
use Elasticsearch\Client;

class ProvidersTest extends BaseTestCase
{
    /**
     * Assert that service provider creates the correct object type
     */
    public function testElasticSearchIsClientBuilder()
    {
        $this->assertInstanceOf(Client::class, app('ElasticSearchClient'));
    }

    /**
     * Verify that config loads and check default values
     */
    public function testConfigWorks()
    {
        $this->assertEquals(['localhost:9200'], config('logme.hosts'));
        $this->assertEquals(1, config('logme.retries'));
        $this->assertEquals('logme', config('logme.default_index'));
        $this->assertEquals(false, config('logme.log.enabled'));
        $this->assertEquals('elasticsearch.log', config('logme.log.filename'));
    }

    protected function getPackageProviders($app)
    {
        return [
            // Provides configuration (reads config/logme.php and exposes it via config() function
            'Buckhill\LogMe\Provider\LogMeProvider',

            //
            'Buckhill\LogMe\Provider\ElasticSearchBuilder',

            // Provides ElasticSearch client (official php package)
            'Buckhill\LogMe\Provider\ElasticSearchClient',
        ];
    }
}