<?php

declare(strict_types=1);

namespace KupShop\GraphQLBundle\Tests\ApiAdmin\Catalog;

use KupShop\GraphQLBundle\Tests\GraphQLTestCase;

class StoreTest extends GraphQLTestCase
{
    /** @dataProvider data_testGetStore */
    public function testGetStore(int $storeId, string $expected): void
    {
        $response = $this->doAdminRequest('
            query getStore($storeId: Int!) {
              store(id: $storeId) {
                id
                name
                type
                visible
              }
            }',
            ['storeId' => $storeId]);

        $this->assertEquals($expected, $response->getContent());
    }

    public function testStores(): void
    {
        $response = $this->doAdminRequest('
            query {
              stores {
                items {
                    id
                    name
                    type
                }
              }
            }');

        $this->assertEquals('{"data":{"stores":{"items":[{"id":1,"name":"Hlavn\u00ed sklad","type":"MAIN_STORE"},{"id":2,"name":"Test sklad","type":"STORE"}]}}}', $response->getContent());
    }

    public function data_testGetStore(): array
    {
        return [
            [1, '{"data":{"store":{"id":1,"name":"Hlavn\u00ed sklad","type":"MAIN_STORE","visible":true}}}'],
            [2, '{"data":{"store":{"id":2,"name":"Test sklad","type":"STORE","visible":true}}}'],
        ];
    }

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