<commit_before><?php
namespace Clickatell;

use \PHPUnit_Framework_TestCase;

class RestTest extends PHPUnit_Framework_TestCase
{
    public function testHandle()
    {
        $rest = new \Clickatell\Rest('');
        $reflection = new \ReflectionClass($rest);
        $method = $reflection->getMethod('handle');
        $method->setAccessible(true);

        // Test accepted scenario
        $curlResult = '{"messages":[{"apiMessageId":null,"accepted":false,"to":"27111111111","error":"Invalid destination address."}],"error":null}';
        $result = $method->invokeArgs($rest, [$curlResult, 202]);

        $message = current($result['messages']);
        $this->assertSame($message['error'], 'Invalid destination address.');
        $this->assertSame($message['apiMsgId'], null);
        $this->assertSame($message['accepted'], false);

        // Test error scenario
        $curlResult = '{"messages":[],"error":"Some error occured"}';
        $this->setExpectedException(\Clickatell\ClickatellException::class, 'Some error occured');
        $result = $method->invokeArgs($rest, [$curlResult, 404]);
    }

    public function testParseStatusCallback()
    {
        $testFile = '/tmp/cv2input';
        $assert = false;

        $values = [
            'apiKey'            => 1,
            'messageId'         => 2,
            'requestId'         => 3,
            'clientMessageId'   => 4,<commit_msg>Correct undefined index in test.<commit_after><?php
namespace Clickatell;

use \PHPUnit_Framework_TestCase;

class RestTest extends PHPUnit_Framework_TestCase
{
    public function testHandle()
    {
        $rest = new \Clickatell\Rest('');
        $reflection = new \ReflectionClass($rest);
        $method = $reflection->getMethod('handle');
        $method->setAccessible(true);

        // Test accepted scenario
        $curlResult = '{"messages":[{"apiMessageId":null,"accepted":false,"to":"27111111111","error":"Invalid destination address."}],"error":null}';
        $result = $method->invokeArgs($rest, [$curlResult, 202]);

        $message = current($result['messages']);
        $this->assertSame($message['error'], 'Invalid destination address.');
        $this->assertSame($message['apiMessageId'], null);
        $this->assertSame($message['accepted'], false);

        // Test error scenario
        $curlResult = '{"messages":[],"error":"Some error occured"}';
        $this->setExpectedException(\Clickatell\ClickatellException::class, 'Some error occured');
        $result = $method->invokeArgs($rest, [$curlResult, 404]);
    }

    public function testParseStatusCallback()
    {
        $testFile = '/tmp/cv2input';
        $assert = false;

        $values = [
            'apiKey'            => 1,
            'messageId'         => 2,
            'requestId'         => 3,
            'clientMessageId'   => 4,
{'fraction_non_alphanumeric': 0.16239915819010872, 'fraction_numerical': 0.015433181339880744, 'mean_word_length': 2.885558583106267, 'pattern_counts': {'":': 16, '<': 5, '<?xml version=': 0, '>': 27, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 2, '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': '2050009', 'n_tokens_mistral': 826, 'n_tokens_neox': 770, 'n_words': 149}