<?php
/**
 * @copyright (c) Kufer Software GmbH, Loisachstrasse 4, D-84453 Mühldorf
 */

use Kufer\Web\Classes\Export\ExportCalculation;

/**
 * Generated by PHPUnit_SkeletonGenerator on 2017-03-03 at 10:00:22.
 */
class ExportCalcCategoryTest extends \PHPUnit\Framework\TestCase
{
  /**
   * @var ExportCalculation\ExportCalcCategory
   */
  protected $object;

  /**
   * Sets up the fixture, for example, opens a network connection.
   * This method is called before a test is executed.
   */
  protected function setUp(): void
  {
    $expCalc = new \ExportCalculation();
    $this->object = new ExportCalculation\ExportCalcCategory($expCalc);
  }

  /**
   * Tears down the fixture, for example, closes a network connection.
   * This method is called after a test is executed.
   */
  protected function tearDown(): void
  {
  }

  /**
   * @covers ExportCalcCategory::resolveVar()
   * @test
   */
  public function getVarValue4Category_kateg_link()
  {
    $dm = new \Category();
    $dm->id = 3;
    $dm->owner = 2;
    $dm->text = 'Titel der Kategorie / Kategorietitel';
    $withSeo = '';
    if (SEARCHENGINE_FUNCTIONS) {
      $withSeo = 'katname%3ATitel+der+Kategorie+Kategorietitel%3B';
    }
    $_GET['orderby'] = 'blubb';
    $_GET['orderbyasc'] = '1';
    $_REQUEST['urlparameter'] = 'orderby:blubb;orderbyasc:1;';
    $orderbypart = 'orderby%3Ablubb%3Borderbyasc%3A1%3B';

    $dm->kategorieTyp = 1;
    $expected = 'index.php?urlparameter=kathaupt%3A1%3Bkatid%3A3%3Bkatvaterid%3A2%3B' . $withSeo . $orderbypart;
    $this->assertEquals($expected, $this->object->resolveVar('link', $dm));

    $dm->kategorieTyp = 2;
    $expected = 'index.php?urlparameter=kathaupt%3A2%3Bkatid%3A3%3Bkatvaterid%3A2%3B' . $withSeo . $orderbypart;
    $this->assertEquals($expected, $this->object->resolveVar('link', $dm));

    $dm->kategorieTyp = 3;//Artikel
    $expected = 'index.php?urlparameter=kathaupt%3A600%3Bkatid%3A3%3Bkatvaterid%3A2%3B' . $withSeo . $orderbypart;
    $this->assertEquals($expected, $this->object->resolveVar('link', $dm));
  }

  /**
   * @covers ExportCalcCategory::resolveVar()
   * @test
   */
  public function getVarValue4Category_kateg_link_ohne_sort()
  {
    $dm = new \Category();
    $dm->id = 3;
    $dm->owner = 2;
    $dm->text = 'Titel der Kategorie / Kategorietitel';
    $withSeo = '';
    if (SEARCHENGINE_FUNCTIONS) {
      $withSeo = 'katname%3ATitel+der+Kategorie+Kategorietitel%3B';
    }
    $_GET['orderby'] = 'blubb';
    $_GET['orderbyasc'] = '1';

    $dm->kategorieTyp = 1;
    $expected = 'index.php?urlparameter=kathaupt%3A1%3Bkatid%3A3%3Bkatvaterid%3A2%3B' . $withSeo;
    $this->assertEquals($expected, $this->object->resolveVar('link_ohne_sort', $dm));

    $dm->kategorieTyp = 2;
    $expected = 'index.php?urlparameter=kathaupt%3A2%3Bkatid%3A3%3Bkatvaterid%3A2%3B' . $withSeo;
    $this->assertEquals($expected, $this->object->resolveVar('link_ohne_sort', $dm));

    $dm->kategorieTyp = 3;//Artikel
    $expected = 'index.php?urlparameter=kathaupt%3A600%3Bkatid%3A3%3Bkatvaterid%3A2%3B' . $withSeo;
    $this->assertEquals($expected, $this->object->resolveVar('link_ohne_sort', $dm));
  }
}
