<?php

use classes\motorapi;

require_once WD . '/classes/motorapi.php';

it('only writes cached MotorAPI metadata when a response object exists', function (): void {
    motorapi::addCachedMetaIfPossible(null);

    $response = new class {
        public array $meta = [];

        public function add_meta(string $key, mixed $value): void
        {
            $this->meta[$key] = $value;
        }
    };

    motorapi::addCachedMetaIfPossible($response);

    expect($response->meta)->toBe(['cached' => true]);
});
