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

namespace GoCardlessPro\Integration;

class CurrencyExchangeRatesIntegrationTest extends IntegrationTestBase
{
    public function testResourceModelExists()
    {
        $obj = new \GoCardlessPro\Resources\CurrencyExchangeRate(array());
        $this->assertNotNull($obj);
    }
    
    public function testCurrencyExchangeRatesList()
    {
        $fixture = $this->loadJsonFixture('currency_exchange_rates')->list;
        $this->stub_request($fixture);

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

        $body = $fixture->body->currency_exchange_rates;
    
        $records = $response->records;
        $this->assertInstanceOf('\GoCardlessPro\Core\ListResponse', $response);
        $this->assertInstanceOf('\GoCardlessPro\Resources\CurrencyExchangeRate', $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]->rate)) {
                $this->assertEquals($body[$num]->rate, $record->rate);
            }
            
            if (isset($body[$num]->source)) {
                $this->assertEquals($body[$num]->source, $record->source);
            }
            
            if (isset($body[$num]->target)) {
                $this->assertEquals($body[$num]->target, $record->target);
            }
            
            if (isset($body[$num]->time)) {
                $this->assertEquals($body[$num]->time, $record->time);
            }
            
        }

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

    
}
