<?php

namespace Tests\Unit;

use Tests\TestCase;
use Illuminate\Support\Arr;
use Illuminate\Support\Collection;
use Illuminate\Pagination\LengthAwarePaginator;

use Tests\Unit\TagsTrait;

use App\Models\Tag;
use App\Models\User;
use App\Models\Role;
use App\Models\Inquiry;
use App\Models\LivestreamList;
use App\Models\Livestream;

class LivestreamListTest extends TestCase
{
    use TagsTrait;

    public function getClassname()
    {
        return 'livestream-list';
    }

    public function test_a_livestream_lists_tags_are_always_included()
    {
        $content_element = $this->createContentElement(LivestreamList::factory());
        $tag = Tag::factory()->create();
        $livestream_list = $content_element->content;

        $this->assertInstanceOf(LivestreamList::class, $livestream_list);

        $livestream_list->addTag($tag);
        $livestream_list->refresh();

        $this->assertEquals(1, $livestream_list->tags->count());
        $tag = $livestream_list->tags->first();

        $content_element->refresh();
        $livestream_array = $content_element->content->toArray();

        $this->assertNotNull(Arr::get($livestream_array, 'tags'));
        $this->assertEquals($tag->id, Arr::get($livestream_array, 'tags')[0]['id']);
    }

    /*
    public function a_livestream_list_has_a_livestreams_attribute()
    {
        $livestream = Livestream::factory()->create();
        $tag = Tag::factory()->create();

        $livestream->addTag($tag);

        $content_element = $this->createContentElement(LivestreamList::factory());
        $livestream_list = $content_element->content;

        $livestream_list->addTag($tag);
        $livestream_list->refresh();

        $this->assertNotNull($livestream_list->livestreams);
        $this->assertInstanceOf(LengthAwarePaginator::class, $livestream_list->livestreams);
        $this->assertEquals(1, count($livestream_list->livestreams->items()));
        $this->assertTrue(collect($livestream_list->livestreams->items())->contains('id', $livestream->id));
    }
     */
}
