<?php
/**
 * Unit tests for Horde_ActiveSync_Folder_Imap
 *
 * @author Michael J. Rubinsky <mrubinsk@horde.org>
 * @category Horde
 * @package ActiveSync
 */
class Horde_ActiveSync_ImapAdapterTest extends Horde_Test_Case
{
    public function testBug13711()
    {
        $this->markTestIncomplete("Useless test without all the fixtures.");
        $factory = new Horde_ActiveSync_Factory_TestServer();
        $imap_client = $this->getMockSkipConstructor('Horde_Imap_Client_Socket');
        $imap_client->expects($this->any())
            ->method('fetch')
            ->will($this->_getFixturesFor13711());

        $imap_factory = new Horde_ActiveSync_Stub_ImapFactory();
        $imap_factory->fixture = $imap_client;
        $adapter = new Horde_ActiveSync_Imap_Adapter(array('factory' => $imap_factory));

        $adapter->getMessages(
            'INBOX',
            array(462),
            array(
                'protocolversion' => 14.1,
                'bodyprefs' => array(
                    'wanted' => Horde_ActiveSync::BODYPREF_TYPE_MIME,
                     Horde_ActiveSync::BODYPREF_TYPE_MIME => array(
                           'type' => Horde_ActiveSync::BODYPREF_TYPE_MIME,
                           'truncationsize' => 200000)
                ),
                'mimesupport' => Horde_ActiveSync::MIME_SUPPORT_ALL,
            )
        );
    }

    protected function _getFixturesFor13711()
    {
        $first = "TzozMToiSG9yZGVfSW1hcF9DbGllbnRfRmV0Y2hfUmVzdWx0cyI6Mzp7czo4OiIAKgBfZGF0YSI7YToxOntpOjQ2MjtPOjI4OiJIb3JkZV9JbWFwX0NsaWVudF9EYXRhX0ZldGNoIjoxOntzOjg6IgAqAF9kYXRhIjthOjY6e2k6MTQ7aToxNDtpOjEzO2k6NDYyO2k6MTA7YTowOnt9aToxO0M6MTU6IkhvcmRlX01pbWVfUGFydCI6MzA5OnthOjIwOntpOjA7aToxO2k6MTtzOjQ6InRleHQiO2k6MjtzOjg6ImNhbGVuZGFyIjtpOjM7czo0OiI4Yml0IjtpOjQ7YToxOntpOjA7czoyOiJkZSI7fWk6NTtzOjA6IiI7aTo2O3M6MDoiIjtpOjc7YToxOntzOjQ6InNpemUiO3M6NDoiM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VRyYW5zZmVyLUVuY29kaW5nOiA4Yml0DQpYLU1haWxlcjogTWljcm9zb2Z0IE91dGxvb2sgMTUuMA0KVGhyZWFkLUluZGV4OiBBYy82aDRLMDhSa0Q3UndYUnUyMkprczA1ZHNuTlFBQUFBUFENCkNvbnRlbnQtTGFuZ3VhZ2U6IGRlDQpVc2VyLUFnZW50OiBIb3JkZSBBcHBsaWNhdGlvbiBGcmFtZXdvcmsgNQ0KDQoiO319fX1zOjExOiIAKgBfa2V5VHlwZSI7aToyO3M6MTE6IgAqAF9vYkNsYXNzIjtzOjI4OiJIb3JkZV9JbWFwX0NsaWVudF9EYXRhX0ZldGNoIjt9";
        //$first_obj = unserialize(base64_decode($first));

        $second = "TzozMToiSG9yZGVfSW1hcF9DbGllbnRfRmV0Y2hfUmVzdWx0cyI6Mzp7czo4OiIAKgBfZGF0YSI7YToxOntpOjQ2MjtPOjI4OiJIb3JkZV9JbWFwX0NsaWVudF9EYXRhX0ZldGNoIjoxOntzOjg6IgAqAF9kYXRhIjthOjI6e2k6MTQ7aToxNDtpOjEzO2k6NDYyO319fXM6MTE6IgAqAF9rZXlUeXBlIjtpOjI7czoxMToiACoAX29iQ2xhc3MiO3M6Mjg6IkhvcmRlX0ltYXBfQ2xpZW50X0RhdGFfRmV0Y2giO30=";
        $second_obj = unserialize(base64_decode($second));

        // $third = "[encoded data, 12416 characters]";
        // $third_obj = unserialize(base64_decode($third));

        $fourth = "TzozMToiSG9yZGVfSW1hcF9DbGllbnRfRmV0Y2hfUmVzdWx0cyI6Mzp7czo4OiIAKgBfZGF0YSI7YToxOntpOjQ2MjtPOjI4OiJIb3JkZV9JbWFwX0NsaWVudF9EYXRhX0ZldGNoIjoxOntzOjg6IgAqAF9kYXRhIjthOjM6e2k6MTQ7aToxNDtpOjEzO2k6NDYyO2k6NjthOjE6e2k6MTthOjI6e3M6MToiZCI7czo0OiI4Yml0IjtzOjE6InQiO3M6MTUyMzoiQkVHSU46VkNBTEVOREFSDQpQUk9ESU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fQ==";
        $fourth_obj = unserialize(base64_decode($fourth));
        //return $this->onConsecutiveCalls($first_obj, $second_obj, $fourth_obj);
        return $this->onConsecutiveCalls($second_obj, $fourth_obj);
    }

}
