<commit_before><?php

use Ladesk\Ladesk;

class CartTest extends PHPUnit_Framework_TestCase
{
    private function getApi()
    {
        $api_url = getenv('API_URL');
        $api_key = getenv('API_KEY');
        if(empty($api_key) || empty($api_url)) {
            throw new Exception('Set ENV variables for tests');
        }
        return new Ladesk($api_url, $api_key);
    }

    public function testOverview()
    {
        $ladesk = $this->getApi();
        $result = $ladesk->getChatsOverview();
        $this->assertArrayHasKey('visitors', $result[0]);

        $result = $ladesk->getCallsOverview();
        $this->assertArrayHasKey('running', $result[0]);
        $this->assertArrayHasKey('ringing', $result[0]);
        $this->assertArrayHasKey('inqueue', $result[0]);
    }

    public function testApplicationStatus()
    {
        $ladesk = $this->getApi();
        $result = $ladesk->getApplicationStatus();
        $this->assertArrayHasKey('liveagentversion', $result);
    }

    public function testTags()
    {
        $ladesk = $this->getApi();
        $result = $ladesk->getTags();
        $this->assertArrayHasKey('name', $result[0]);
    }

    public function testCompanies()
    {
        $ladesk = $this->getApi();
        $companies = $ladesk->getCompanies();
        $this->assertArrayHasKey('id', $companies[0]);
        $this->assertArrayHasKey('name', $companies[0]);
        $this->assertArrayHasKey('emails', $companies[0]);
        $this->assertArrayHasKey('datecreated', $companies[0]);

        $id = $companies[0]['id'];
        $company = $ladesk->getCompany($id);
        $this->assertInternalType('array', $company);
        $this->assertArrayHasKey('id', $company);
        $this->assertArrayHasKey('name', $company);
        $this->assertArrayHasKey('datecreated', $company);
        $this->assertArrayHasKey('language', $company);
        $this->assertArrayHasKey('emails', $company);
        $this->assertArrayHasKey('phones', $company);
    }

    public function testAgent()
    {
        $ladesk = $this->getApi();
        $result = $ladesk->getAgentOnlineStatus();
        $this->assertArrayHasKey('username', $result[0]);
    }

    public function testDepartments()
    {
        $ladesk = $this->getApi();
        $result = $ladesk->getDepartments();
        $this->assertArrayHasKey('departmentid', $result[0]);
    }

    public function testConversations()
    {
        $ladesk = $this->getApi();
        $result = $ladesk->getConversations();
        $this->assertArrayHasKey('conversationid', $result[0]);

        $id = $result[0]['conversationid'];
        $result = $ladesk->getConversation($id);
        $this->assertArrayHasKey('departmentid', $result);
        $this->assertArrayHasKey('code', $result);

        $result = $ladesk->getConversationMessages($id);
        $this->assertArrayHasKey('groups', $result);<commit_msg>Added getAgent method, Modified testAgentOnlineStatus<commit_after><?php

use Ladesk\Ladesk;

class CartTest extends PHPUnit_Framework_TestCase
{
    private function getApi()
    {
        $api_url = getenv('API_URL');
        $api_key = getenv('API_KEY');
        if(empty($api_key) || empty($api_url)) {
            throw new Exception('Set ENV variables for tests');
        }
        return new Ladesk($api_url, $api_key);
    }

    public function testOverview()
    {
        $ladesk = $this->getApi();
        $result = $ladesk->getChatsOverview();
        $this->assertArrayHasKey('visitors', $result[0]);

        $result = $ladesk->getCallsOverview();
        $this->assertArrayHasKey('running', $result[0]);
        $this->assertArrayHasKey('ringing', $result[0]);
        $this->assertArrayHasKey('inqueue', $result[0]);
    }

    public function testApplicationStatus()
    {
        $ladesk = $this->getApi();
        $result = $ladesk->getApplicationStatus();
        $this->assertArrayHasKey('liveagentversion', $result);
        $this->assertArrayHasKey('current_server_time', $result);
    }

    public function testTags()
    {
        $ladesk = $this->getApi();
        $result = $ladesk->getTags();
        $this->assertArrayHasKey('name', $result[0]);
    }

    public function testCompanies()
    {
        $ladesk = $this->getApi();
        $companies = $ladesk->getCompanies();
        $this->assertArrayHasKey('id', $companies[0]);
        $this->assertArrayHasKey('name', $companies[0]);
        $this->assertArrayHasKey('emails', $companies[0]);
        $this->assertArrayHasKey('datecreated', $companies[0]);

        $id = $companies[0]['id'];
        $company = $ladesk->getCompany($id);
        $this->assertArrayHasKey('id', $company);
        $this->assertArrayHasKey('name', $company);
        $this->assertArrayHasKey('datecreated', $company);
        $this->assertArrayHasKey('language', $company);
        $this->assertArrayHasKey('emails', $company);
        $this->assertArrayHasKey('phones', $company);
    }

    public function testAgentOnlineStatus()
    {
        $ladesk = $this->getApi();
        $onlineAgents = $ladesk->getAgentOnlineStatus();
        $this->assertArrayHasKey('id', $onlineAgents[0]);
        $this->assertArrayHasKey('contactid', $onlineAgents[0]);
        $this->assertArrayHasKey('username', $onlineAgents[0]);
        $this->assertArrayHasKey('firstname', $onlineAgents[0]);
        $this->assertArrayHasKey('lastname', $onlineAgents[0]);
        $this->assertArrayHasKey('avatar_url', $onlineAgents[0]);
        $this->assertArrayHasKey('onlineStatus', $onlineAgents[0]);

        $id = $onlineAgents[0]['id'];
        $agent = $ladesk->getAgent($id);
        $this->assertArrayHasKey('contactid', $agent);
        $this->assertArrayHasKey('userid', $agent);
        $this->assertArrayHasKey('email', $agent);
        $this->assertArrayHasKey('firstname', $agent);
        $this->assertArrayHasKey('lastname', $agent);
        $this->assertArrayHasKey('gender', $agent);
        $this->assertArrayHasKey('role', $agent);
        $this->assertArrayHasKey('authtoken', $agent);
    }

    public function testDepartments()
    {
        $ladesk = $this->getApi();
        $result = $ladesk->getDepartments();
        $this->assertArrayHasKey('departmentid', $result[0]);
    }

    public function testConversations()
    {
        $ladesk = $this->getApi();
        $result = $ladesk->getConversations();
        $this->assertArrayHasKey('conversationid', $result[0]);

        $id = $result[0]['conversationid'];
        $result = $ladesk->getConversation($id);
        $this->assertArrayHasKey('departmentid', $result);
        $this->assertArrayHasKey('code', $result);

        $result = $ladesk->getConversationMessages($id);
        $this->assertArrayHasKey('groups', $result);
{'fraction_non_alphanumeric': 0.17274074074074075, 'fraction_numerical': 0.005185185185185185, 'mean_word_length': 3.1750154607297465, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 100, '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': '5484138', 'n_tokens_mistral': 2131, 'n_tokens_neox': 2074, 'n_words': 303}