<?php

namespace KupShop\UserBundle\Test;

use KupShop\KupShopBundle\Util\Compat\ServiceContainer;
use KupShop\UserBundle\Util\UserExporter;
use KupShop\UserBundle\Util\UserImporter;

class UserExportTest extends \DatabaseTestCase
{
    public function getDataSet()
    {
        return $this->getJsonDataSetFromFile();
    }

    /**
     * @var UserExporter
     */
    protected $userExporter;

    /**
     * @var UserImporter
     */
    protected $userImporter;

    protected function setEnvironment()
    {
        $this->userExporter = ServiceContainer::getService(UserExporter::class);
        $this->userImporter = ServiceContainer::getService(UserImporter::class);
    }

    public function testExportUsers()
    {
        $this->setEnvironment();

        // IMPORT USERS
        $importXML = file_get_contents(__DIR__.'/UserExportTest.xml');

        // USERS ID FOR EXPORT
        $IDs = [12, 13];

        // EXPORT USERS
        $exportXML = $this->userExporter->exportUsers($IDs);

        // COMPARING
        $this->assertXmlStringEqualsXmlString($importXML, $exportXML);
    }
}
