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

class KursTest extends \PHPUnit\Framework\TestCase
{
  /**
   * @var Kurs
   */
  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 = new Kurs();
  }

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

  /**
   * @covers Kurs::isAnmeldeEndeOk
   * @test
   */
  public function isAnmeldeEndeOk_anmeldeendeNichtGesetzt_ReturnTrue()
  {
    $this->assertTrue($this->object->isAnmeldeEndeOk(''));
    $this->assertTrue($this->object->isAnmeldeEndeOk('30.12.1899'));
    $this->assertTrue($this->object->isAnmeldeEndeOk('30.12.1899 00:00'));
    $this->assertTrue($this->object->isAnmeldeEndeOk('', '10.10.2010'));
  }

  /**
   * @covers Kurs::isAnmeldeEndeOk
   * @test
   */
  public function isAnmeldeEndeOk_anmeldeendeOhneUhrzeit_GiltBisZumTagesende()
  {
    $this->assertTrue($this->object->isAnmeldeEndeOk('10.10.2010', '09.10.2010'));
    $this->assertTrue($this->object->isAnmeldeEndeOk('10.10.2010', '09.10.2010 10:10'));
    $this->assertTrue($this->object->isAnmeldeEndeOk('10.10.2010', '10.10.2010'));
    $this->assertTrue($this->object->isAnmeldeEndeOk('10.10.2010', '10.10.2010 10:10'));

    $this->assertFalse($this->object->isAnmeldeEndeOk('10.10.2010', '11.10.2010'));
    $this->assertFalse($this->object->isAnmeldeEndeOk('10.10.2010', '11.10.2010 10:10'));
  }

  /**
   * @covers Kurs::isAnmeldeEndeOk
   * @test
   */
  public function isAnmeldeEndeOk_anmeldeendeMitUhrzeit_GiltBisZurUhrzeit()
  {
    $this->assertTrue($this->object->isAnmeldeEndeOk('10.10.2010 10:00', '09.10.2010'));
    $this->assertTrue($this->object->isAnmeldeEndeOk('10.10.2010 10:00', '09.10.2010 10:10'));

    $this->assertTrue($this->object->isAnmeldeEndeOk('10.10.2010 10:00', '10.10.2010'));
    $this->assertTrue($this->object->isAnmeldeEndeOk('10.10.2010 10:00', '10.10.2010 00:00'));
    $this->assertTrue($this->object->isAnmeldeEndeOk('10.10.2010 10:00', '10.10.2010 09:30'));
    $this->assertFalse($this->object->isAnmeldeEndeOk('10.10.2010 10:00', '10.10.2010 10:30'));
    $this->assertFalse($this->object->isAnmeldeEndeOk('10.10.2010 10:00', '11.10.2010'));
    $this->assertFalse($this->object->isAnmeldeEndeOk('10.10.2010 10:00', '11.10.2010 10:10'));
  }

  /**
   * @covers Kurs::isAnmeldeEndeOk
   * @test
   */
  public function isAnmeldeEndeOk_anmeldeendeIstGleichVergleichswert_ReturnTrue()
  {
    $this->assertTrue($this->object->isAnmeldeEndeOk('10.10.2010 10:00', '10.10.2010 10:00'));
    $this->assertTrue($this->object->isAnmeldeEndeOk('10.10.2010', '10.10.2010'));
    $this->assertTrue($this->object->isAnmeldeEndeOk('10.10.2010 23:59', '10.10.2010 23:59'));
  }

  /**
   * @covers Kurs::getAnmEnde
   * @test
   */
  public function getAnmEnde_withOffsetAndManuallyOverridden()
  {
    $offset = -5;
    $this->object->beginn_dat = '06.10.2018';
    $this->object->anm_ende_manu = true;
    $this->object->anm_ende = '26.09.2018';

    $actual = $this->object->getAnmEnde($offset, false);
    $this->assertEquals('26.09.2018', $actual);

    $offset = -5;
    $this->object->beginn_dat = '06.10.2018';
    $this->object->anm_ende_manu = true;
    $this->object->anm_ende = '26.09.2018 00:01';

    $actual = $this->object->getAnmEnde($offset, false);
    $this->assertEquals('26.09.2018 00:01', $actual);
  }

  /**
   * @covers Kurs::getAnmEnde
   * @test
   */
  public function getAnmEnde_withOffsetNotManuallyOverridden()
  {
    $offset = -5;
    $this->object->beginn_dat = '01.11.2018';
    $this->object->anm_ende_manu = false;
    $this->object->anm_ende = '27.10.2018 00:00';

    $actual = $this->object->getAnmEnde($offset, false);
    $this->assertEquals('27.10.2018 00:00', $actual);

    $offset = -5;
    $this->object->beginn_dat = '01.11.2018';
    $this->object->anm_ende_manu = false;
    $this->object->anm_ende = '27.10.2018 13:15';

    $actual = $this->object->getAnmEnde($offset, false);
    $this->assertEquals('27.10.2018 00:00', $actual);
  }

  /**
   * @covers Kurs::getAnmEnde
   * @test
   */
  public function getAnmEnde_withoutOffsetAndManuallyOverridden()
  {
    $offset = 0;
    $this->object->beginn_dat = '06.10.2018';
    $this->object->anm_ende_manu = false;
    $this->object->anm_ende = '26.09.2018 00:00';

    $actual = $this->object->getAnmEnde($offset, false);
    $this->assertEquals('26.09.2018 00:00', $actual);

    $offset = 0;
    $this->object->beginn_dat = '06.10.2018';
    $this->object->anm_ende_manu = false;
    $this->object->anm_ende = '26.09.2018 13:46';

    $actual = $this->object->getAnmEnde($offset, false);
    $this->assertEquals('26.09.2018 13:46', $actual);
  }

  /**
   * @covers Kurs::getAnmEnde
   * @test
   */
  public function getAnmEnde_withoutOffsetNotManuallyOverridden()
  {
    $offset = 0;
    $this->object->beginn_dat = '06.10.2018';
    $this->object->anm_ende_manu = false;
    $this->object->anm_ende = '';

    $actual = $this->object->getAnmEnde($offset, false);
    $this->assertEquals('', $actual);
  }

  /**
   * @covers Kurs::getAnmEnde
   * @test
   */
  public function getAnmEnde_withOffsetForceAutomatic()
  {
    $offset = -5;
    $this->object->beginn_dat = '19.10.2018';
    $this->object->anm_ende_manu = false;
    $this->object->anm_ende = '12.10.2018 00:00';

    $actual = $this->object->getAnmEnde($offset, false);
    $this->assertEquals('14.10.2018 00:00', $actual);

    $offset = -5;
    $this->object->beginn_dat = '19.10.2018';
    $this->object->anm_ende_manu = false;
    $this->object->anm_ende = '12.10.2018 11:00';

    $actual = $this->object->getAnmEnde($offset, false);
    $this->assertEquals('14.10.2018 00:00', $actual);

    $offset = 1;
    $this->object->beginn_dat = '19.10.2018';
    $this->object->ende_dat = '19.10.2018';
    $this->object->anm_ende_manu = false;
    $this->object->anm_ende = '12.10.2018 15:00';

    $actual = $this->object->getAnmEnde($offset, false);
    $this->assertEquals('19.10.2018 00:00', $actual);

    $offset = 1;
    $this->object->beginn_dat = '19.10.2018';
    $this->object->ende_dat = '23.10.2018';
    $this->object->anm_ende_manu = false;
    $this->object->anm_ende = '12.10.2018 15:00';

    $actual = $this->object->getAnmEnde($offset, false);
    $this->assertEquals('20.10.2018 00:00', $actual);
  }

  /**
   * @covers Kurs::getAnmEnde
   * @test
   */
  public function getAnmEnde_withoutOffsetAndManuallyOverridden_withTime()
  {
    $offset = 0;
    $this->object->beginn_dat = '06.10.2018';
    $this->object->anm_ende_manu = false;
    $this->object->anm_ende = '26.09.2018 11:00';

    $actual = $this->object->getAnmEnde($offset, false);
    $this->assertEquals('26.09.2018 11:00', $actual);
  }

  /**
   * @covers Kurs::getAnmEnde
   * @test
   */
  public function getAnmEnde_zustiegVorAnmende()
  {
    $offset = 0;
    $this->object->beginn_dat = '06.09.2018';
    $this->object->anm_ende_manu = false;
    $this->object->anm_ende = '26.09.2018 11:00';
    $this->object->kurse2->zustieg_datum = '24.09.2018 11:00';

    $actual = $this->object->getAnmEnde($offset, true);
    $this->assertEquals('26.09.2018 11:00', $actual);

    $offset = -5;
    $this->object->beginn_dat = '06.09.2018';
    $this->object->anm_ende_manu = false;
    $this->object->anm_ende = '26.09.2018 11:00';
    $this->object->kurse2->zustieg_datum = '24.09.2018 00:00';

    $actual = $this->object->getAnmEnde($offset, true);
    $this->assertEquals('24.09.2018 00:00', $actual);

    $offset = 7;
    $this->object->beginn_dat = '06.09.2018';
    $this->object->anm_ende_manu = false;
    $this->object->anm_ende = '';
    $this->object->kurse2->zustieg_datum = '24.09.2018 11:00';

    $actual = $this->object->getAnmEnde($offset, true);
    $this->assertEquals('24.09.2018 11:00', $actual);
  }

  /**
   * @covers Kurs::getAnmEnde
   * @test
   */
  public function getAnmEnde_zustiegNachAnmende()
  {
    $offset = 0;
    $this->object->beginn_dat = '06.09.2018';
    $this->object->anm_ende_manu = false;
    $this->object->anm_ende = '26.09.2018 11:00';
    $this->object->kurse2->zustieg_datum = '29.09.2018 11:00';

    $actual = $this->object->getAnmEnde($offset, true);
    $this->assertEquals('29.09.2018 11:00', $actual);

    $offset = 7;
    $this->object->beginn_dat = '06.09.2018';
    $this->object->anm_ende_manu = false;
    $this->object->anm_ende = '10.09.2018 20:15';
    $this->object->kurse2->zustieg_datum = '12.09.2018 11:00';

    $actual = $this->object->getAnmEnde($offset, true);
    $this->assertEquals('13.09.2018 00:00', $actual);

    $offset = 7;
    $this->object->beginn_dat = '06.09.2018';
    $this->object->anm_ende_manu = false;
    $this->object->anm_ende = '';
    $this->object->kurse2->zustieg_datum = '13.09.2018 11:00';

    $actual = $this->object->getAnmEnde($offset, true);
    $this->assertEquals('13.09.2018 11:00', $actual);
  }

  /**
   * @covers Kurs::isValueDifferent
   * @test
   */
  public function isValueDifferent_Date()
  {
    $this->object->beginn_dat = '20.04.2021';

    $this->assertFalse($this->object->isValueDifferent('beginn_dat', '20.04.2021'));
    $this->assertTrue($this->object->isValueDifferent('beginn_dat', '21.04.2021'));
    $this->assertTrue($this->object->isValueDifferent('beginn_dat', 'a'));

    $this->assertTrue($this->object->isValueDifferent('beginn_dat', '21.04.2021 00:00:00'));
    $this->assertFalse($this->object->isValueDifferent('beginn_dat', '20.04.2021 00:00:00'));
    $this->assertTrue($this->object->isValueDifferent('beginn_dat', '20.04.2021 00:00:01'));

    $this->assertTrue($this->object->isValueDifferent('beginn_dat', DEFAULTDATE));
    $this->assertTrue($this->object->isValueDifferent('beginn_dat', ''));

    $this->object->beginn_dat = DEFAULTDATE;
    $this->assertFalse($this->object->isValueDifferent('beginn_dat', ''));
    $this->assertFalse($this->object->isValueDifferent('beginn_dat', DEFAULTDATE));
    $this->assertTrue($this->object->isValueDifferent('beginn_dat', '01.01.2021'));

    $this->object->beginn_dat = '';
    $this->assertFalse($this->object->isValueDifferent('beginn_dat', ''));
    $this->assertFalse($this->object->isValueDifferent('beginn_dat', DEFAULTDATE));
    $this->assertTrue($this->object->isValueDifferent('beginn_dat', '01.01.2021'));
  }

  /**
   * @covers Kurs::isValueDifferent
   * @test
   */
  public function isValueDifferent_DateTime()
  {
    $this->object->anm_ende = '20.04.2021 00:00:00';
    $this->assertFalse($this->object->isValueDifferent('anm_ende', '20.04.2021'));
    $this->assertFalse($this->object->isValueDifferent('anm_ende', '20.04.2021 00:00:00'));
    $this->assertTrue($this->object->isValueDifferent('anm_ende', '21.04.2021'));
    $this->assertTrue($this->object->isValueDifferent('anm_ende', '20.04.2021 00:00:01'));
    $this->assertTrue($this->object->isValueDifferent('anm_ende', '21.04.2021 00:00:01'));

    $this->object->anm_ende = '20.04.2021';

    $this->assertFalse($this->object->isValueDifferent('anm_ende', '20.04.2021'));
    $this->assertTrue($this->object->isValueDifferent('anm_ende', '21.04.2021'));
    $this->assertFalse($this->object->isValueDifferent('anm_ende', '20.04.2021 00:00:00'));
    $this->assertTrue($this->object->isValueDifferent('anm_ende', '20.04.2021 00:00:01'));

    $this->assertTrue($this->object->isValueDifferent('anm_ende', DEFAULTDATE));

    $this->object->anm_ende = '';
    $this->assertFalse($this->object->isValueDifferent('anm_ende', DEFAULTDATE));
    $this->assertFalse($this->object->isValueDifferent('anm_ende', ''));

    $this->object->anm_ende = DEFAULTDATE;
    $this->assertFalse($this->object->isValueDifferent('anm_ende', ''));
    $this->assertFalse($this->object->isValueDifferent('anm_ende', DEFAULTDATE));
  }

  /**
   * @covers Kurs::isAnmEndeErreicht
   * @test
   */
  public function isAnmEndeErreicht_by_date()
  {
    // past
    $this->object->beginn_dat = '29.01.2020';
    $this->object->anm_ende = '22.01.2020';
    $current = DateTimeObj::createFromString('23.01.2020');
    $this->assertTrue($this->object->isAnmEndeErreicht($current, 0, false));

    // future
    $current = DateTimeObj::createFromString('21.01.2020');
    $this->assertFalse($this->object->isAnmEndeErreicht($current, 0, false));
  }

  /**
   * @covers Kurs::isAnmEndeErreicht
   * @test
   */
  public function isAnmEndeErreicht_by_minute()
  {
    // past
    $this->object->beginn_dat = '29.01.2020';
    $this->object->anm_ende = '22.01.2020 12:01';
    $current = DateTimeObj::createFromString('22.01.2020 12:00');
    $this->assertFalse($this->object->isAnmEndeErreicht($current, 0, false));

    // future
    $this->object->beginn_dat = '29.01.2020';
    $this->object->anm_ende = '22.01.2020 11:59';
    $current = DateTimeObj::createFromString('22.01.2020 12:00');
    $this->assertTrue($this->object->isAnmEndeErreicht($current, 0, false));
  }

  /**
   * @covers Kurs::isAnmEndeErreicht
   * @test
   */
  public function isAnmEndeErreicht_H_510547()
  {
    // past
    $this->object->beginn_dat = '29.01.2020';
    $this->object->anm_ende = '20.05.2020 13:40:00';
    $current = DateTimeObj::createFromString('20.05.2020 13:40:00');
    $this->assertFalse($this->object->isAnmEndeErreicht($current, 0, false));

    // future
    $this->object->beginn_dat = '29.01.2020';
    $this->object->anm_ende = '20.05.2020 13:40:00';
    $current = DateTimeObj::createFromString('20.05.2020 13:40:01');
    $anmAnmSchlussEnabled = true;
    $this->assertTrue($this->object->isAnmEndeErreicht($current, 0, false));
  }

  /**
   * @covers Kurs::isKursBeginnErreicht
   * @test
   */
  public function isKursBeginnErreicht()
  {
    // past
    $this->object->beginn_dat = '29.01.2020';
    $current = DateTimeObj::createFromString('28.01.2020');
    $this->assertFalse($this->object->isKursBeginnErreicht($current));

    // future
    $this->object->beginn_dat = '29.01.2020';
    $current = DateTimeObj::createFromString('30.01.2020');
    $this->assertTrue($this->object->isKursBeginnErreicht($current));
  }

  /**
   * @covers Kurs::isAnmBeginnErreicht
   * @test
   */
  public function isAnmBeginnErreicht()
  {
    // past
    $this->object->zusatztexte->anm_beginn = '29.01.2020';
    $current = DateTimeObj::createFromString('28.01.2020');
    $this->assertFalse($this->object->isAnmeldebeginnErreicht($current));

    // future
    $this->object->zusatztexte->anm_beginn = '29.01.2020';
    $current = DateTimeObj::createFromString('30.01.2020');
    $this->assertTrue($this->object->isAnmeldebeginnErreicht($current));
  }

  /**
   * @covers Kurs::isKinderkurs
   * @test
   */
  public function isKinderkurs_TypK_returnsTrue()
  {
    $this->object->typ = 'K';
    $this->assertTrue($this->object->isKinderkurs());
  }

  /**
   * @covers Kurs::isKinderkurs
   * @test
   */
  public function isKinderkurs_TypNotK_returnsFalse()
  {
    $this->object->typ = '';
    $this->assertFalse($this->object->isKinderkurs());
    $this->object->typ = 'L';
    $this->assertFalse($this->object->isKinderkurs());
  }

  /**
   * @covers Kurs::istPlatzFuer
   * @test
   */
  public function istPlatzFuer_ElternKindKurs50NurKombiniertesMax()
  {
    System::$enforceKuferSqlVersion = 500;
    $this->object->typ = 'L';
    $this->object->teil_max = 0;
    $this->object->kinder_max = 0;
    $this->object->kurse2->tnki_max = 5;
    $this->assertTrue($this->object->istPlatzFuer(1, 1));
    $this->assertTrue($this->object->istPlatzFuer(4, 1));
    $this->assertTrue($this->object->istPlatzFuer(1, 4));

    $this->assertFalse($this->object->istPlatzFuer(5, 1));
    $this->assertFalse($this->object->istPlatzFuer(1, 5));
    $this->assertFalse($this->object->istPlatzFuer(3, 3));
  }

  /**
   * @covers Kurs::istPlatzFuer
   * @test
   */
  public function istPlatzFuer_ElternKindKurs50NurTeilMax()
  {
    System::$enforceKuferSqlVersion = 500;
    $this->object->typ = 'L';
    $this->object->teil_max = 1;
    $this->object->kinder_max = 0;
    $this->object->kurse2->tnki_max = 0;
    $this->assertTrue($this->object->istPlatzFuer(1, 0));
    $this->assertTrue($this->object->istPlatzFuer(0, 0));
    $this->assertTrue($this->object->istPlatzFuer(0, 1));
    $this->assertTrue($this->object->istPlatzFuer(1, 5));

    $this->assertFalse($this->object->istPlatzFuer(2, 0));
    $this->assertFalse($this->object->istPlatzFuer(2, 1));

    $this->object->teil_max = 2;
    $this->object->teil_akt = 1;
    $this->assertTrue($this->object->istPlatzFuer(1, 0));
    $this->assertTrue($this->object->istPlatzFuer(0, 0));
    $this->assertTrue($this->object->istPlatzFuer(0, 1));
    $this->assertTrue($this->object->istPlatzFuer(1, 5));

    $this->assertFalse($this->object->istPlatzFuer(2, 0));
    $this->assertFalse($this->object->istPlatzFuer(2, 1));
  }

  /**
   * @covers Kurs::istPlatzFuer
   * @test
   */
  public function istPlatzFuer_ElternKindKurs50NurKinderMax()
  {
    System::$enforceKuferSqlVersion = 500;
    $this->object->typ = 'L';
    $this->object->teil_max = 0;
    $this->object->kinder_max = 1;
    $this->object->kurse2->tnki_max = 0;
    $this->assertTrue($this->object->istPlatzFuer(0, 1));
    $this->assertFalse($this->object->istPlatzFuer(0, 2));
    $this->assertTrue($this->object->istPlatzFuer(1, 0));
    $this->assertTrue($this->object->istPlatzFuer(0, 0));
    $this->assertFalse($this->object->istPlatzFuer(1, 5));
    $this->assertTrue($this->object->istPlatzFuer(2, 1));

    $this->object->kinder_max = 2;
    $this->object->kinderanzahl = 1;//ist im default -1
    $this->assertTrue($this->object->istPlatzFuer(0, 1));
    $this->assertFalse($this->object->istPlatzFuer(0, 2));
    $this->assertTrue($this->object->istPlatzFuer(1, 0));
    $this->assertTrue($this->object->istPlatzFuer(0, 0));
    $this->assertFalse($this->object->istPlatzFuer(1, 5));
    $this->assertTrue($this->object->istPlatzFuer(2, 1));
  }

  /**
   * @covers Kurs::istPlatzFuer
   * @test
   */
  public function istPlatzFuer_ElternKindKurs50AlleMax()
  {
    System::$enforceKuferSqlVersion = 500;
    $this->object->typ = 'L';
    $this->object->teil_max = 1;
    $this->object->kinder_max = 1;
    $this->object->kurse2->tnki_max = 2;
    $this->assertTrue($this->object->istPlatzFuer(0, 1));
    $this->assertFalse($this->object->istPlatzFuer(0, 2));
    $this->assertTrue($this->object->istPlatzFuer(1, 0));
    $this->assertFalse($this->object->istPlatzFuer(2, 0));
    $this->assertTrue($this->object->istPlatzFuer(1, 1));
    $this->assertTrue($this->object->istPlatzFuer(0, 0));
    $this->assertFalse($this->object->istPlatzFuer(2, 1));
    $this->assertFalse($this->object->istPlatzFuer(1, 2));

    $this->object->teil_max = 2;
    $this->object->kinder_max = 2;
    $this->object->kurse2->tnki_max = 3;
    $this->assertTrue($this->object->istPlatzFuer(0, 2));
    $this->assertFalse($this->object->istPlatzFuer(0, 3));
    $this->assertTrue($this->object->istPlatzFuer(2, 0));
    $this->assertFalse($this->object->istPlatzFuer(3, 0));
    $this->assertTrue($this->object->istPlatzFuer(1, 1));
    $this->assertTrue($this->object->istPlatzFuer(2, 1));
    $this->assertTrue($this->object->istPlatzFuer(1, 2));
    $this->assertFalse($this->object->istPlatzFuer(2, 2));
    $this->assertFalse($this->object->istPlatzFuer(3, 1));
    $this->assertFalse($this->object->istPlatzFuer(1, 3));

    //H575600 _2 4):
    $this->object->teil_max = 10;
    $this->object->kinder_max = 10;
    $this->object->kurse2->tnki_max = 20;
    $this->object->teil_akt = 8;
    $this->object->kinderanzahl = 9;
    $this->assertFalse($this->object->istPlatzFuer(1, 2));
  }

  /**
   * @covers Kurs::istPlatzFuer
   * @test
   */
  public function istPlatzFuer_ElternKindKurs50KeinMax()
  { //abgeklärt mit *HU 19.7.2021: kein Maximum gesetzt => beliebig viele TN anmeldbar
    System::$enforceKuferSqlVersion = 500;//spielt eigtl. keine Rolle
    $this->object->typ = 'L';
    $this->object->teil_max = 0;
    $this->object->kinder_max = 0;
    $this->object->kurse2->tnki_max = 0;
    $this->assertFalse($this->object->istPlatzFuer(500, 5000));
  }

  /**
   * @covers Kurs::istPlatzFuer
   * @test
   */
  public function istPlatzFuer_KinderKurs50NurTeilMax()
  {
    System::$enforceKuferSqlVersion = 500;
    $this->object->typ = 'K';
    $this->object->teil_max = 0;
    $this->object->kinder_max = 1;
    $this->object->kurse2->tnki_max = 0;
    $this->assertTrue($this->object->istPlatzFuer(1, 0));
    $this->assertTrue($this->object->istPlatzFuer(0, 0));
    $this->assertTrue($this->object->istPlatzFuer(0, 1));
    $this->assertTrue($this->object->istPlatzFuer(5, 1));

    $this->assertFalse($this->object->istPlatzFuer(0, 2));
    $this->assertFalse($this->object->istPlatzFuer(1, 2));

    $this->object->kinder_max = 2;
    $this->object->kinderanzahl = 1;
    $this->assertTrue($this->object->istPlatzFuer(1, 0));
    $this->assertTrue($this->object->istPlatzFuer(0, 0));
    $this->assertTrue($this->object->istPlatzFuer(0, 1));
    $this->assertTrue($this->object->istPlatzFuer(5, 1));

    $this->assertFalse($this->object->istPlatzFuer(0, 2));
    $this->assertFalse($this->object->istPlatzFuer(1, 2));
  }

  /**
   * @covers Kurs::istPlatzFuer
   * @test
   */
  public function istPlatzFuer_KinderKurs50()
  {
    System::$enforceKuferSqlVersion = 500;
    $this->object->typ = 'K';
    $this->object->teil_max = 7;
    $this->object->teil_akt = 6;
    $this->object->kinder_max = 1;
    $this->object->kurse2->tnki_max = 0;

    $tnZahlenDb = new TeilnehmerzahlenProviderFromKurs($this->object);
    $this->object->updateTeilnehmerzahlenFelder($tnZahlenDb);

    $this->assertTrue($this->object->istPlatzFuer(1, 0));
    $this->assertTrue($this->object->istPlatzFuer(0, 1));

    $this->assertTrue($this->object->istPlatzFuer(0, 0));
  }

  /**
   * @covers Kurs::istPlatzFuer
   * @test
   */
  public function istPlatzFuer_KinderKurs50_voll()
  {
    System::$enforceKuferSqlVersion = 500;
    $this->object->typ = 'K';
    $this->object->teil_max = 7;
    $this->object->teil_akt = 7;
    $this->object->kinder_max = 1;
    $this->object->kurse2->tnki_max = 0;

    $tnZahlenDb = new TeilnehmerzahlenProviderFromKurs($this->object);
    $this->object->updateTeilnehmerzahlenFelder($tnZahlenDb);

    $this->assertTrue($this->object->istPlatzFuer(1, 0));//bei Kinderkursen interessieren nur die Kinder
    $this->assertFalse($this->object->istPlatzFuer(0, 1));

    $this->assertTrue($this->object->istPlatzFuer(0, 0));
  }
}
