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

class ValidierungWBTest extends \PHPUnit\Framework\TestCase
{
  /**
   * @var ValidierungWB
   */
  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
  {
    $this->object = ValidierungWB::getInstance();
  }

  /**
   * @covers ValidierungWB::isValidVar
   * @test
   */
  public function isValidVar_name()
  {
    $varname = 'name';
    //gültige Werte
    $name = 'Kufer';
    $this->assertTrue($this->object->isValidVar($varname, $name));
    $name = 'Ümläutö';
    $this->assertTrue($this->object->isValidVar($varname, $name));

    //Als ungültig validierte Werte: Rückgabewert ist der Name der Variable
    $name = 'https://www.isnogood.com';
    $this->assertEquals($varname, $this->object->isValidVar($varname, $name));
    $name = 'irgenwas https://www.isnogood.com anderes';
    $this->assertEquals($varname, $this->object->isValidVar($varname, $name));
    $name = 'irgenwas http://www.isnogood.com anderes';
    $this->assertEquals($varname, $this->object->isValidVar($varname, $name));
  }

  /**
   * @covers ValidierungWB::isValidVar
   * @test
   */
  public function isValidVar_vorname()
  {
    $varname = 'vorname';
    //gültige Werte
    $name = 'Marie';
    $this->assertTrue($this->object->isValidVar($varname, $name));
    $name = 'Sören';
    $this->assertTrue($this->object->isValidVar($varname, $name));

    //Als ungültig validierte Werte: Rückgabewert ist der Name der Variable
    $name = 'https://www.isnogood.com';
    $this->assertEquals($varname, $this->object->isValidVar($varname, $name));
    $name = 'irgenwas https://www.isnogood.com anderes';
    $this->assertEquals($varname, $this->object->isValidVar($varname, $name));
    $name = 'irgenwas http://www.isnogood.com anderes';
    $this->assertEquals($varname, $this->object->isValidVar($varname, $name));
  }
}
