<?php

namespace Tests\Unit\Framework;

use Openguru\OpenCartFramework\Http\Request;
use PHPUnit\Framework\TestCase;

class RequestTest extends TestCase
{
    public function testHasQueryParam(): void
    {
        $request = new Request(
            ['foo' => 'bar'],
            [],
            [],
            [],
            []
        );

        $this->assertTrue($request->has('foo'));
        $this->assertFalse($request->has('xyz'));
    }

    public function testHasJsonParam(): void
    {
        $request = new Request(
            [],
            [],
            [],
            [],
            [],
            [],
            '{"foo":"bar"}'
        );

        $this->assertTrue($request->has('foo'));
    }

    public function testHasAtLeastOne(): void
    {
        $request = new Request(
            ['foo' => 'bar'],
            [],
            [],
            [],
            [],
            [],
            '{"xyz":"bar"}'
        );

        $this->assertTrue($request->has([
            'foo',
            'xyz',
            'some_other'
        ]));

        $this->assertFalse($request->has([
            'abc',
            'some_other'
        ]));
    }
}
