<commit_before><?php

use \Mockery as m;

class TwilioTest extends PHPUnit_Framework_TestCase {
    function tearDown() {
        m::close();
    }
    function testNeedsRefining() {
        $http = m::mock(new Services_Twilio_TinyHttp);
        $http->shouldReceive('get')->once()
            ->with('/2010-04-01/Accounts/AC123.json')
            ->andReturn(array(200, array('Content-Type' => 'application/json'),
                json_encode(array(
                    'sid' => 'AC123',
                    'friendly_name' => '<NAME>',
                ))
            ));
        $client = new Services_Twilio('AC123', '123', '2010-04-01', $http);
        $this->assertEquals('AC123', $client->account->sid);
        $this->assertEquals('<NAME>', $client->account->friendly_name);
    }

    function testAccessSidAvoidsNetworkCall() {
        $http = m::mock(new Services_Twilio_TinyHttp);
        $http->shouldReceive('get')->never();
        $client = new Services_Twilio('AC123', '123', '2010-04-01', $http);
        $client->account->sid;
    }

    function testObjectLoadsOnlyOnce() {
        $http = m::mock(new Services_Twilio_TinyHttp);
        $http->shouldReceive('get')->once()
            ->with('/2010-04-01/Accounts/AC123.json')
            ->andReturn(array(200, array('Content-Type' => 'application/json'),
                json_encode(array(
                    'sid' => 'AC123',
                    'friendly_name' => '<NAME>',
                    'status' => 'active',
                ))
            ));
        $client = new Services_Twilio('AC123', '123', '2010-04-01', $http);
        $client->account->friendly_name;
        $client->account->friendly_name;
        $client->account->status;
    }

    function testSubresourceLoad() {
        $http = m::mock(new Services_Twilio_TinyHttp);
        $http->shouldReceive('get')->once()
            ->with('/2010-04-01/Accounts/AC123/Calls/CA123.json')
            ->andReturn(array(200, array('Content-Type' => 'application/json'),
                json_encode(array('status' => 'Completed'))
            ));

        $client = new Services_Twilio('AC123', '123', '2010-04-01', $http);
        $this->assertEquals(
            'Completed',
            $client->account->calls->get('CA123')->status
        );
    }

    function testSubresourceSubresource() {
        $http = m::mock(new Services_Twilio_TinyHttp);
        $http->shouldReceive('get')->once()
            ->with('/2010-04-01/Accounts/AC123/Calls/CA123/Notifications/NO123.json')
            ->andReturn(array(200, array('Content-Type' => 'application/json'),
                json_encode(array('message_text' => 'Foo'))
            ));

        $client = new Services_Twilio('AC123', '123', '2010-04-01', $http);
        $notifs = $client->account->calls->get('CA123')->notifications;
        $this->assertEquals('Foo', $notifs->get('NO123')->message_text);
    }

    function testGetIteratorUsesFilters() {
        $http = m::mock(new Services_Twilio_TinyHttp);
        $qs = '?Page=0&PageSize=10&StartTime%3E=2009-07-06';
        $http->shouldReceive('get')->once()
            ->with('/2010-04-01/Accounts/AC123/Calls.json' . $qs)
            ->andReturn(array(200, array('Content-Type' => 'application/json'),
                json_encode(array(
                    'total' => 1,
                    'calls' => array(array('status' => 'Completed', 'sid' => 'CA123'))
                ))
            ));
        $client = new Services_Twilio('AC123', '123', '2010-04-01', $http);
        $iterator = $client->account->calls->getIterator(
            0, 10, array('StartTime>' => '2009-07-06'));
        foreach ($iterator as $call) {
            $this->assertEquals('Completed', $call->status);
            break;
        }
    }

    function testGetIteratorUsesFiltersMoreThanOnce() {
        $http = m::mock(new Services_Twilio_TinyHttp);
        $qs = '?Page=0&PageSize=1&StartTime%3E=2009-07-06';
        $http->shouldReceive('get')->twice()
            ->andReturn(array(200, array('Content-Type' => 'application/json'),
                json_encode(array(
                    'total' => 2,
                    'calls' => array(array('status' => 'Completed', 'sid' => 'CA123'))
                ))
            ));
        $client = new Services_Twilio('AC123', '123', '2010-04-01', $http);
        $iterator = $client->account->calls->getIterator(
            0, 1, array('StartTime>' => '2009-07-06'));
        foreach ($iterator as $call) {
            $this->assertEquals('Completed', $call->status);
        }
    }

    function testListResource() {
        $http = m::mock(new Services_Twilio_TinyHttp);
        $http->shouldReceive('get')->once()
            ->with('/2010-04-01/Accounts/AC123/Calls.json?Page=0&PageSize=10')
            ->andReturn(array(200, array('Content-Type' => 'application/json'),
                json_encode(array(
                    'total' => 1,
                    'calls' => array(array('status' => 'Completed', 'sid' => 'CA123'))
                ))
            ));
        $client = new Services_Twilio('AC123', '123', '2010-04-01', $http);
        $page = $client->account->calls->getPage(0, 10);<commit_msg>Remove incorrect test<commit_after><?php

use \Mockery as m;

class TwilioTest extends PHPUnit_Framework_TestCase {
    function tearDown() {
        m::close();
    }
    function testNeedsRefining() {
        $http = m::mock(new Services_Twilio_TinyHttp);
        $http->shouldReceive('get')->once()
            ->with('/2010-04-01/Accounts/AC123.json')
            ->andReturn(array(200, array('Content-Type' => 'application/json'),
                json_encode(array(
                    'sid' => 'AC123',
                    'friendly_name' => '<NAME>',
                ))
            ));
        $client = new Services_Twilio('AC123', '123', '2010-04-01', $http);
        $this->assertEquals('AC123', $client->account->sid);
        $this->assertEquals('<NAME>', $client->account->friendly_name);
    }

    function testAccessSidAvoidsNetworkCall() {
        $http = m::mock(new Services_Twilio_TinyHttp);
        $http->shouldReceive('get')->never();
        $client = new Services_Twilio('AC123', '123', '2010-04-01', $http);
        $client->account->sid;
    }

    function testObjectLoadsOnlyOnce() {
        $http = m::mock(new Services_Twilio_TinyHttp);
        $http->shouldReceive('get')->once()
            ->with('/2010-04-01/Accounts/AC123.json')
            ->andReturn(array(200, array('Content-Type' => 'application/json'),
                json_encode(array(
                    'sid' => 'AC123',
                    'friendly_name' => '<NAME>',
                    'status' => 'active',
                ))
            ));
        $client = new Services_Twilio('AC123', '123', '2010-04-01', $http);
        $client->account->friendly_name;
        $client->account->friendly_name;
        $client->account->status;
    }

    function testSubresourceLoad() {
        $http = m::mock(new Services_Twilio_TinyHttp);
        $http->shouldReceive('get')->once()
            ->with('/2010-04-01/Accounts/AC123/Calls/CA123.json')
            ->andReturn(array(200, array('Content-Type' => 'application/json'),
                json_encode(array('status' => 'Completed'))
            ));

        $client = new Services_Twilio('AC123', '123', '2010-04-01', $http);
        $this->assertEquals(
            'Completed',
            $client->account->calls->get('CA123')->status
        );
    }

    function testSubresourceSubresource() {
        $http = m::mock(new Services_Twilio_TinyHttp);
        $http->shouldReceive('get')->once()
            ->with('/2010-04-01/Accounts/AC123/Calls/CA123/Notifications/NO123.json')
            ->andReturn(array(200, array('Content-Type' => 'application/json'),
                json_encode(array('message_text' => 'Foo'))
            ));

        $client = new Services_Twilio('AC123', '123', '2010-04-01', $http);
        $notifs = $client->account->calls->get('CA123')->notifications;
        $this->assertEquals('Foo', $notifs->get('NO123')->message_text);
    }

    function testGetIteratorUsesFilters() {
        $http = m::mock(new Services_Twilio_TinyHttp);
        $qs = '?Page=0&PageSize=10&StartTime%3E=2009-07-06';
        $http->shouldReceive('get')->once()
            ->with('/2010-04-01/Accounts/AC123/Calls.json' . $qs)
            ->andReturn(array(200, array('Content-Type' => 'application/json'),
                json_encode(array(
                    'total' => 1,
                    'calls' => array(array('status' => 'Completed', 'sid' => 'CA123'))
                ))
            ));
        $client = new Services_Twilio('AC123', '123', '2010-04-01', $http);
        $iterator = $client->account->calls->getIterator(
            0, 10, array('StartTime>' => '2009-07-06'));
        foreach ($iterator as $call) {
            $this->assertEquals('Completed', $call->status);
            break;
        }
    }

    function testListResource() {
        $http = m::mock(new Services_Twilio_TinyHttp);
        $http->shouldReceive('get')->once()
            ->with('/2010-04-01/Accounts/AC123/Calls.json?Page=0&PageSize=10')
            ->andReturn(array(200, array('Content-Type' => 'application/json'),
                json_encode(array(
                    'total' => 1,
                    'calls' => array(array('status' => 'Completed', 'sid' => 'CA123'))
                ))
            ));
        $client = new Services_Twilio('AC123', '123', '2010-04-01', $http);
        $page = $client->account->calls->getPage(0, 10);
{'fraction_non_alphanumeric': 0.18139195665763702, 'fraction_numerical': 0.05563659095644926, 'mean_word_length': 2.1964701964701963, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 190, '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': '6160685', 'n_tokens_mistral': 3243, 'n_tokens_neox': 2852, 'n_words': 410}