<?php

namespace KupShop\OrderingBundle\Tests;

use KupShop\DevelopmentBundle\Util\Tests\CartTestTrait;
use KupShop\OrderingBundle\Util\VIES\DICValidator;

class DICValidatorTest extends \DatabaseTestCase
{
    use CartTestTrait;

    public function testDICValidator()
    {
        $this->set(DICValidator::class, new DICValidatorTestClass());

        $this->createCart();
        $this->insertProduct(1, 16, 1);
        $this->cart->updateAddresses([
            'email' => 'test@wpj.cz',
            'name' => 'Wpj',
            'surname' => 'Wpj',
            'street' => 'Wpj 123',
            'city' => 'Vrchlabi',
            'zip' => 12345,
            'country' => 'CZ',
            'phone' => '123456789',
            'dic' => 'CZ123456789',
        ], null);

        $this->setDeliveryType(1);
        $this->cart->max_step_submitted = 3;
        $this->cart->createFromDB();
        $this->cart->actualStep = 'user';

        $this->expectException('KupShop\OrderingBundle\Exception\DICException');
        $this->cart->getDeliveryType()->check($this->cart);
    }
}

class DICValidatorTestClass
{
    public function checkVat($DIC)
    {
        return false;
    }
}
