<?php

namespace KupShop\GraphQLBundle\Tests\ApiAdmin\Catalog;

use KupShop\GraphQLBundle\Tests\GraphQLTestCase;
use PHPUnit\DbUnit\DataSet\IDataSet;

class SectionTest extends GraphQLTestCase
{
    public function testSectionCreateOrUpdate(): void
    {
        $response = $this->doAdminRequest('
            mutation sectionCreateOrUpdate($input: SectionInput!) {
              sectionCreateOrUpdate(input: $input) {
                result
                section {
                   name,
                   parent{
                    id
                   }
                   visible
                   visibility
                   behaviour
                   url
            }}}',
            [
                'input' => [
                    'name' => 'nova sekce',
                    'nameShort' => 'nova',
                    'parentId' => 1,
                    'visibility' => 'HIDDEN_IN_MENU',
                    'behaviour' => 'SHOW_PRODUCTS_FROM_SUBSECTIONS',
                    'showInSearch' => true,
                    'seo' => ['title' => 'seo titutek', 'description' => 'seo_popis', 'keywords' => 'klic'],
                    'url' => 'url-sekce',
                ],
            ]);

        $this->assertEquals(
            '{"data":{"sectionCreateOrUpdate":{"result":true,"section":{"name":"nova sekce","parent":{"id":1},"visible":false,"visibility":"HIDDEN_IN_MENU","behaviour":"SHOW_PRODUCTS_FROM_SUBSECTIONS","url":"https:\/\/www.kupshop.local\/url-sekce\/"}}}}',
            $response->getContent());
    }

    protected function getDataSet(): IDataSet
    {
        return $this->getJsonDataSetFromFile();
    }
}
