<?php

declare(strict_types=1);

namespace Sabberworm\CSS\Tests\Unit\Property;

use PHPUnit\Framework\TestCase;
use Sabberworm\CSS\CSSList\CSSListItem;
use Sabberworm\CSS\Property\Import;
use Sabberworm\CSS\Value\CSSString;
use Sabberworm\CSS\Value\URL;

/**
 * @covers \Sabberworm\CSS\Property\Import
 */
final class ImportTest extends TestCase
{
    /**
     * @var Import
     */
    private $subject;

    protected function setUp(): void
    {
        $this->subject = new Import(new URL(new CSSString('https://example.org/')), null);
    }

    /**
     * @test
     */
    public function implementsCSSListItem(): void
    {
        self::assertInstanceOf(CSSListItem::class, $this->subject);
    }

    /**
     * @test
     */
    public function getArrayRepresentationIncludesClassName(): void
    {
        $subject = new Import(new URL(new CSSString('https://example.org/')), null);

        $result = $subject->getArrayRepresentation();

        self::assertSame('Import', $result['class']);
    }

    /**
     * @test
     */
    public function getArrayRepresentationIncludesUri(): void
    {
        $uri = 'https://example.com';
        $url = new URL(new CSSString($uri));

        $subject = new Import($url, null);

        $result = $subject->getArrayRepresentation();

        self::assertSame(
            [
                'class' => 'URL',
                'uri' => [
                    'class' => 'CSSString',
                    'contents' => $uri,
                ],
            ],
            $result['uri']
        );
    }
}
