<?php
//
// WARNING: Do not edit by hand, this file was generated by Crank:
// https://github.com/gocardless/crank
//

namespace GoCardlessPro\Integration;

class ExportsIntegrationTest extends IntegrationTestBase
{
    public function testResourceModelExists()
    {
        $obj = new \GoCardlessPro\Resources\Export(array());
        $this->assertNotNull($obj);
    }
    
    public function testExportsGet()
    {
        $fixture = $this->loadJsonFixture('exports')->get;
        $this->stub_request($fixture);

        $service = $this->client->exports();
        $response = call_user_func_array(array($service, 'get'), (array)$fixture->url_params);

        $body = $fixture->body->exports;
    
        $this->assertInstanceOf('\GoCardlessPro\Resources\Export', $response);

        $this->assertEquals($body->created_at, $response->created_at);
        $this->assertEquals($body->currency, $response->currency);
        $this->assertEquals($body->download_url, $response->download_url);
        $this->assertEquals($body->export_type, $response->export_type);
        $this->assertEquals($body->id, $response->id);
    

        $expectedPathRegex = $this->extract_resource_fixture_path_regex($fixture);
        $dispatchedRequest = $this->history[0]['request'];
        $this->assertMatchesRegularExpression($expectedPathRegex, $dispatchedRequest->getUri()->getPath());
    }

    
    public function testExportsList()
    {
        $fixture = $this->loadJsonFixture('exports')->list;
        $this->stub_request($fixture);

        $service = $this->client->exports();
        $response = call_user_func_array(array($service, 'list'), (array)$fixture->url_params);

        $body = $fixture->body->exports;
    
        $records = $response->records;
        $this->assertInstanceOf('\GoCardlessPro\Core\ListResponse', $response);
        $this->assertInstanceOf('\GoCardlessPro\Resources\Export', $records[0]);
        if (!is_null($fixture->body) && property_exists($fixture->body, 'meta') && !is_null($fixture->body->meta)) {
            $this->assertEquals($fixture->body->meta->cursors->before, $response->before);
            $this->assertEquals($fixture->body->meta->cursors->after, $response->after);
        }
    

    
        foreach (range(0, count($body) - 1) as $num) {
            $record = $records[$num];
            
            if (isset($body[$num]->created_at)) {
                $this->assertEquals($body[$num]->created_at, $record->created_at);
            }
            
            if (isset($body[$num]->currency)) {
                $this->assertEquals($body[$num]->currency, $record->currency);
            }
            
            if (isset($body[$num]->download_url)) {
                $this->assertEquals($body[$num]->download_url, $record->download_url);
            }
            
            if (isset($body[$num]->export_type)) {
                $this->assertEquals($body[$num]->export_type, $record->export_type);
            }
            
            if (isset($body[$num]->id)) {
                $this->assertEquals($body[$num]->id, $record->id);
            }
            
        }

        $expectedPathRegex = $this->extract_resource_fixture_path_regex($fixture);
        $dispatchedRequest = $this->history[0]['request'];
        $this->assertMatchesRegularExpression($expectedPathRegex, $dispatchedRequest->getUri()->getPath());
    }

    
}
