<?php
namespace ccxt;

// ----------------------------------------------------------------------------

// PLEASE DO NOT EDIT THIS FILE, IT IS GENERATED AND WILL BE OVERWRITTEN:
// https://github.com/ccxt/ccxt/blob/master/CONTRIBUTING.md#how-to-contribute-code

// -----------------------------------------------------------------------------


function test_extend() {
    $exchange = new \ccxt\Exchange(array(
        'id' => 'regirock',
    ));
    $obj1 = array(
        'a' => 1,
        'b' => [1, 2],
        'c' => [array(
    'test1' => 1,
    'test2' => 1,
)],
        'd' => null,
        'e' => 'not_undefined',
        'sub' => array(
            'a' => 1,
            'b' => [1, 2],
            'c' => [array(
    'test1' => 1,
    'test2' => 2,
)],
            'd' => null,
            'e' => 'not_undefined',
            'other1' => 'x',
        ),
        'other1' => 'x',
    );
    $obj2 = array(
        'a' => 2,
        'b' => [3, 4],
        'c' => [array(
    'test1' => 2,
    'test3' => 3,
)],
        'd' => 'not_undefined',
        'e' => null,
        'sub' => array(
            'a' => 2,
            'b' => [3, 4],
            'c' => [array(
    'test1' => 2,
    'test3' => 3,
)],
            'd' => 'not_undefined',
            'e' => null,
            'other2' => 'y',
        ),
        'other2' => 'y',
    );
    // extend
    $extended = $exchange->extend($obj1, $obj2);
    tbfe_check_extended($extended, true);
}


function tbfe_check_extended($extended, $has_sub) {
    assert($extended['a'] === 2);
    assert($extended['b'][0] === 3);
    assert($extended['b'][1] === 4);
    assert($extended['c'][0]['test1'] === 2);
    assert(!(is_array($extended['c'][0]) && array_key_exists('test2', $extended['c'][0])));
    assert($extended['c'][0]['test3'] === 3);
    assert($extended['d'] === 'not_undefined');
    assert($extended['e'] === null);
    assert($extended['other1'] === 'x');
    assert($extended['other2'] === 'y');
    if ($has_sub) {
        assert(is_array($extended) && array_key_exists('sub', $extended));
    }
}
