<?php
/**
 * @copyright (c) Kufer Software GmbH, Oderstraße 7, D-84453 Mühldorf
 */

/**
 * Generated by PHPUnit_SkeletonGenerator on 2017-03-27 at 16:09:46.
 */
class KursOperationsTest extends \PHPUnit\Framework\TestCase
{
  /**
   * @var \Kufer\Web\Classes\Addfunctions\KursOperations
   */
  protected $object;

  /**
   * @var \DateTimeZone
   */
  private $timezone;

  /**
   * 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 \Kufer\Web\Classes\Addfunctions\KursOperations();
  }

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

  /**
   * @covers KursOperationsTest::checkMindestensEinKursbeginnInMehrAlsXTagen
   * @test
   */
  public function checkMindestensEinKursbeginnInMehrAlsXTagen_emptyArray_returnsFalse()
  {
    $this->assertFalse($this->object->checkMindestensEinKursbeginnInMehrAlsXTagen(5, array()));
  }

  /**
   * @covers KursOperationsTest::checkMindestensEinKursbeginnInMehrAlsXTagen
   * @test
   */
  public function checkMindestensEinKursbeginnInMehrAlsXTagen_oneCourseArrayBeginSooner_returnsFalse()
  {
    $k = new \Kurs();
    $k->beginn_dat = '31.01.2023';
    $refDate = \DateObj::getNow();
    $refDate->setDate(2023, 1, 1);
    $this->assertFalse($this->object->checkMindestensEinKursbeginnInMehrAlsXTagen(5, array($k)));
  }

  /**
   * @covers KursOperationsTest::checkMindestensEinKursbeginnInMehrAlsXTagen
   * @test
   */
  public function checkMindestensEinKursbeginnInMehrAlsXTagen_oneCourseArrayBeginLater_returnsTrue()
  {
    $k = new \Kurs();
    $k->beginn_dat = '01.02.2023';
    $refDate = \DateObj::getNow();
    $refDate->setDate(2023, 1, 1);
    $this->assertTrue($this->object->checkMindestensEinKursbeginnInMehrAlsXTagen(5, array($k), $refDate));
  }

  /**
   * @covers KursOperationsTest::checkMindestensEinKursbeginnInMehrAlsXTagen
   * @test
   */
  public function checkMindestensEinKursbeginnInMehrAlsXTagen_twoCoursesArrayOneBeginLater_returnsTrue()
  {
    $k = new \Kurs();
    $k->beginn_dat = '20.01.2023';
    $k2 = new \Kurs();
    $k2->beginn_dat = '01.02.2023';

    $refDate = \DateObj::getNow();
    $refDate->setDate(2023, 1, 1);

    $span = 30;

    $this->assertTrue($this->object->checkMindestensEinKursbeginnInMehrAlsXTagen($span, array($k, $k2), $refDate));
  }

  /**
   * @covers KursOperationsTest::checkMindestensEinKursbeginnInMehrAlsXTagen
   * @test
   */
  public function checkMindestensEinKursbeginnInMehrAlsXTagen_noNowDateGiven_returnsFalse()
  {
    $k = new \Kurs();
    $k->beginn_dat = '20.01.2023';
    $k2 = new \Kurs();
    $k2->beginn_dat = '31.01.2023';

    //kein $now Parameter übergeben, da am 21.2.23 programmiert, ist sicher kein Kursbeginn in mehr als 30 Tagen

    $span = 30;

    $this->assertFalse($this->object->checkMindestensEinKursbeginnInMehrAlsXTagen($span, array($k, $k2)));
  }
}
