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

/**
 * Generated by PHPUnit_SkeletonGenerator on 2017-03-03 at 10:00:22.
 */
class CleanOperationsTest extends \PHPUnit\Framework\TestCase
{
  /**
   * @var CleanOperations
   */
  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 CleanOperations();
  }

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

  /**
   * @covers CleanOperations::isInt
   * @test
   */
  public function isInt_PositiveInt_ReturnsTrue()
  {
    $this->assertTrue($this->object->isInt(3));
  }

  /**
   * @covers CleanOperations::isInt
   * @test
   */
  public function isInt_NegativeInt_ReturnsTrue()
  {
    $this->assertTrue($this->object->isInt(-3));
  }

  /**
   * @covers CleanOperations::isInt
   * @test
   */
  public function isInt_PositiveIntOfTypeString_ReturnsTrue()
  {
    $this->assertTrue($this->object->isInt('3'));
  }

  /**
   * @covers CleanOperations::isInt
   * @test
   */
  public function isInt_NegativIntOfTypeString_ReturnsTrue()
  {
    $this->assertTrue($this->object->isInt('-3'));
  }

  /**
   * @covers CleanOperations::isInt
   * @test
   */
  public function isInt_Text_ReturnsFalse()
  {
    $this->assertFalse($this->object->isInt('eins'));
    $this->assertFalse($this->object->isInt('1e10'));
    $this->assertFalse($this->object->isInt('3+3'));
    $this->assertFalse($this->object->isInt(''));
    $this->assertFalse($this->object->isInt('+3'));
  }

  /**
   * Die Eingaben werden derzeit automatisch in Strings umgewandelt. Daher entspricht
   * true = '1' und false = ''.
   *
   * @covers CleanOperations::isInt
   * @test
   */
  public function isInt_Boolean_ReturnsSameBoolean()
  {
    $this->assertTrue($this->object->isInt(true));
    $this->assertFalse($this->object->isInt(false));
  }

  /**
   * @covers CleanOperations::isFileNameWithAllowedChars
   * @test
   */
  public function isFileNameWithAllowedChars_Alphanumeric_ReturnsTrue()
  {
    $this->assertTrue($this->object->isFileNameWithAllowedChars('abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'));
  }

  /**
   * @covers CleanOperations::isFileNameWithAllowedChars
   * @test
   */
  public function isFileNameWithAllowedChars_AllowedSpecialChars_ReturnsTrue()
  {
    $this->assertTrue($this->object->isFileNameWithAllowedChars('-_.'));
  }

  /**
   * @covers CleanOperations::isFileNameWithAllowedChars
   * @test
   */
  public function isFileNameWithAllowedChars_UmlauteAndDisallowedSpecialChars_ReturnsFalse()
  {
    $this->assertFalse($this->object->isFileNameWithAllowedChars('ä'));
    $this->assertFalse($this->object->isFileNameWithAllowedChars('Ä'));
    $this->assertFalse($this->object->isFileNameWithAllowedChars('ö'));
    $this->assertFalse($this->object->isFileNameWithAllowedChars('ü'));
    $this->assertFalse($this->object->isFileNameWithAllowedChars('&'));
    $this->assertFalse($this->object->isFileNameWithAllowedChars('@'));
  }

  /**
   * @covers CleanOperations::isFileNameWithAllowedChars
   * @test
   */
  public function isFileNameWithAllowedChars_Space_ReturnsFalse()
  {
    $this->assertFalse($this->object->isFileNameWithAllowedChars(' '));
    $this->assertFalse($this->object->isFileNameWithAllowedChars(' a '));
    $this->assertFalse($this->object->isFileNameWithAllowedChars('ab cd'));
  }

  /**
   * @covers CleanOperations::isFileNameWithAllowedChars
   * @test
   */
  public function isFileNameWithAllowedChars_WithPath_ReturnsFalse()
  {
    $this->assertFalse($this->object->isFileNameWithAllowedChars('abc/def'));
    $this->assertFalse($this->object->isFileNameWithAllowedChars('abc\\def'));
  }

  /**
   * @covers CleanOperations::isFileNameWithAllowedChars
   * @test
   */
  public function isFileNameWithAllowedChars_Empty_ReturnsFalse()
  {
    $this->assertFalse($this->object->isFileNameWithAllowedChars(''));
  }

  /**
   * @covers CleanOperations::cleanStringForHtml
   * @test
   */
  public function cleanStringForHtml_Alphanumeric_ReturnUnchanged()
  {
    $this->assertEquals('a', $this->object->cleanStringForHtml('a'));
    $this->assertEquals('abcde', $this->object->cleanStringForHtml('abcde'));
    $this->assertEquals('10', $this->object->cleanStringForHtml('10'));
  }

  /**
   * @covers CleanOperations::cleanStringForHtml
   * @test
   */
  public function cleanStringForHtml_UmlauteUndSichereSonderzeichen_Maskiere()
  {
    $this->assertEquals('&auml;', $this->object->cleanStringForHtml('ä'));
    $this->assertEquals('&ouml;', $this->object->cleanStringForHtml('ö'));
    $this->assertEquals('&uuml;', $this->object->cleanStringForHtml('ü'));
    $this->assertEquals('&euro;', $this->object->cleanStringForHtml('€'));
  }

  /**
   * @covers CleanOperations::cleanStringForHtml
   * @test
   */
  public function cleanStringForHtml_UnsichereSonderzeichen_Maskiere()
  {
    $this->assertEquals('&lt;', $this->object->cleanStringForHtml('<'));
    $this->assertEquals('&gt;', $this->object->cleanStringForHtml('>'));
    $this->assertEquals('&amp;', $this->object->cleanStringForHtml('&'));
    $this->assertEquals('&quot;', $this->object->cleanStringForHtml('"'));
    $this->assertEquals('&#039;', $this->object->cleanStringForHtml("'"));
  }

  /**
   * Diese Funktionsweise ist gewünscht, da z. B. anschließend die Funktion
   * nl2br ausgeführt wird. Allerdings ist darauf zu achten, dass HTML-Attribute immer
   * mit Anführungszeichen eingeschlossen werden, sonst könnte der Zeichenumbruch zu XSS führen.
   *
   * @covers CleanOperations::cleanStringForHtml
   * @test
   */
  public function cleanStringForHtml_Linebreaks_ReturnUnchanged()
  {
    $linebreak = '
';
    $this->assertEquals($linebreak, $this->object->cleanStringForHtml($linebreak));
    $this->assertEquals($linebreak, $this->object->cleanStringForHtml("\r\n"));
    $this->assertEquals("\r\n", $this->object->cleanStringForHtml("\r\n"));
    $this->assertEquals("\n\r", $this->object->cleanStringForHtml("\n\r"));
  }

  /**
   * @covers CleanOperations::cleanStringForHtml
   * @test
   */
  public function cleanStringForHtml_BereitsEncoded_NichtDoppeltEncoden()
  {
    $this->assertEquals('&lt;', $this->object->cleanStringForHtml('&lt;'));
    $this->assertEquals('&#039;', $this->object->cleanStringForHtml('&#039;'));
    $this->assertEquals('&lt;&lt;', $this->object->cleanStringForHtml('<&lt;'));
    $this->assertEquals('&amp;', $this->object->cleanStringForHtml('&amp;'));
    $this->assertEquals('&amp;amp;', $this->object->cleanStringForHtml('&amp;amp;'));
  }

  /**
   * @covers CleanOperations::cleanStringForHtml
   * @test
   */
  public function cleanStringForHtml_Boolean_InStringUmwandeln()
  {
    $this->assertEquals('1', $this->object->cleanStringForHtml(true));
    $this->assertEquals('', $this->object->cleanStringForHtml(false));
  }

  /**
   * @covers CleanOperations::cleanStringForHtml
   * @test
   */
  public function cleanStringForHtml_Numeric_InStringUmwandeln()
  {
    $this->assertEquals('1', $this->object->cleanStringForHtml(1));
    $this->assertEquals('2', $this->object->cleanStringForHtml(2));
    $this->assertEquals('2.2', $this->object->cleanStringForHtml(2.2));
    $this->assertEquals('-0.5', $this->object->cleanStringForHtml(-0.5));
  }

  /**
   * @covers CleanOperations::cleanStringContainingHtml
   * @test
   */
  public function cleanStringContainingHtml_OhneHtml_Unveraendert()
  {
    $this->assertEquals('a', $this->object->cleanStringContainingHtml('a'));
    $this->assertEquals('b', $this->object->cleanStringContainingHtml('b'));
    $this->assertEquals('0', $this->object->cleanStringContainingHtml('0'));
    $this->assertEquals('abcDEF', $this->object->cleanStringContainingHtml('abcDEF'));
    $this->assertEquals('!', $this->object->cleanStringContainingHtml('!'));
    $this->assertEquals('€', $this->object->cleanStringContainingHtml('€'));
    $this->assertEquals('äüöß', $this->object->cleanStringContainingHtml('äüöß'));
    $this->assertEquals('/', $this->object->cleanStringContainingHtml('/'));
    $this->assertEquals('\\', $this->object->cleanStringContainingHtml('\\'));
    $this->assertEquals('"', $this->object->cleanStringContainingHtml('"'));
    $this->assertEquals('\'', $this->object->cleanStringContainingHtml('\''));
  }

  /**
   * @covers CleanOperations::cleanStringContainingHtml
   * @test
   */
  public function cleanStringContainingHtml_EinzelnesKleinerzeichen_Leer()
  {
    $this->assertEquals('', $this->object->cleanStringContainingHtml('<'));
  }

  /**
   * @covers CleanOperations::cleanStringContainingHtml
   * @test
   */
  public function cleanStringContainingHtml_KleinerzeichenMitContext_HtmlEncode()
  {
    $this->assertEquals('5 &lt; 10', $this->object->cleanStringContainingHtml('5 < 10'));
  }

  /**
   * @covers CleanOperations::cleanStringContainingHtml
   * @test
   */
  public function cleanStringContainingHtml_EinzelneHtmlZeichen_HtmlEncode()
  {
    $this->assertEquals('&gt;', $this->object->cleanStringContainingHtml('>'));
    $this->assertEquals('&amp;', $this->object->cleanStringContainingHtml('&'));
  }

  /**
   * @covers CleanOperations::cleanStringContainingHtml
   * @test
   */
  public function cleanStringContainingHtml_ErlaubtesHtml_WeitgehendUnveraendert()
  {
    $this->assertEquals('<b>Fett</b>', $this->object->cleanStringContainingHtml('<b>Fett</b>'));
    $this->assertEquals('<span style="font-weight:bold;">Fett</span>', $this->object->cleanStringContainingHtml('<span style="font-weight: bold;">Fett</span>'));
    $this->assertEquals('<i>Kursiv</i>', $this->object->cleanStringContainingHtml('<i>Kursiv</i>'));
    $this->assertEquals('<div class="test"><span title="äöü">Kursiv</span></div>', $this->object->cleanStringContainingHtml('<div class="test"><span title="äöü">Kursiv</span></div>'));
    // Id und target sind standardmäßig nicht zugelassen. Wir haben htmlPurifier so konfiguriert dass sie erlaubt sind.
    // Mit der aktuellen Version von HtmlPurifier wird automatisch bei Links mit target rel="noreferrer noopener" hinzugefügt.
    $this->assertEquals('<a href="index.php?a=a&amp;b=b&amp;%C3%A4=%C3%A4" target="_blank" rel="noreferrer noopener">Link</a>', $this->object->cleanStringContainingHtml('<a href="index.php?a=a&b=b&ä=ä" target="_blank">Link</a>'));
    $this->assertEquals('<div id="a">div</div>', $this->object->cleanStringContainingHtml('<div id="a">div</div>'));
    $this->assertEquals('<a href="http://www.google.de">a</a>', $this->object->cleanStringContainingHtml('<a href="http://www.google.de">a</a>'));
    $this->assertEquals('<a href="index.php?a=b&amp;c=d">a</a>', $this->object->cleanStringContainingHtml('<a href="index.php?a=b&c=d">a</a>'));
  }

  /**
   * @covers CleanOperations::cleanStringContainingHtml
   * @test
   */
  public function cleanStringContainingHtml_VerbotenesHtml_VerbotenenTeilEntfernen()
  {
    $this->assertEquals('Fett', $this->object->cleanStringContainingHtml('<d>Fett</d>'));
    $this->assertEquals('', $this->object->cleanStringContainingHtml('<style>style</style>'));
    $this->assertEquals('', $this->object->cleanStringContainingHtml('<script>script</script>'));
    $this->assertEquals('<div>div</div>', $this->object->cleanStringContainingHtml('<div onClick="alert(1)">div</div>'));
    $this->assertEquals('<div style="font-weight:bold;">div</div>', $this->object->cleanStringContainingHtml('<div style="font-weight:bold;position:absolute">div</div>'));
  }

  /**
   * @covers CleanOperations::cleanStringContainingHtml
   * @test
   */
  public function cleanStringContainingHtml_FehlerhaftesHtml_KorrigiertesHtml()
  {
    $this->assertEquals('<b>Fett</b>', $this->object->cleanStringContainingHtml('<b>Fett'));
    $this->assertEquals('Fett', $this->object->cleanStringContainingHtml('Fett</b>'));
    $this->assertEquals('<b><i>FettKursiv</i></b>', $this->object->cleanStringContainingHtml('<b><i>FettKursiv</b></i>'));
    $this->assertEquals('<div title="Titel"></div>', $this->object->cleanStringContainingHtml('<div title=Titel ohne Anführungszeichen></div>'));
  }

  /**
   * @covers CleanOperations::cleanStringForJs
   * @test
   */
  public function cleanStringForJs_Alphanumeric_ReturnUnchanged()
  {
    $this->assertEquals('a', $this->object->cleanStringForJs('a'));
    $this->assertEquals('abcde', $this->object->cleanStringForJs('abcde'));
    $this->assertEquals('10', $this->object->cleanStringForJs('10'));
  }

  /**
   * @covers CleanOperations::cleanStringForJs
   * @test
   */
  public function cleanStringForJs_UmlauteUndSichereSonderzeichen_ReturnUniCode()
  {
    $this->assertEquals('\\u00E4', $this->object->cleanStringForJs('ä'));
    $this->assertEquals('\\u00F6', $this->object->cleanStringForJs('ö'));
    $this->assertEquals('\\u00FC', $this->object->cleanStringForJs('ü'));
    $this->assertEquals('\\u00C4', $this->object->cleanStringForJs('Ä'));
    $this->assertEquals('\\u00D6', $this->object->cleanStringForJs('Ö'));
    $this->assertEquals('\\u00DC', $this->object->cleanStringForJs('Ü'));
    $this->assertEquals('\\u00DF', $this->object->cleanStringForJs('ß'));
    $this->assertEquals('\\u00C9\\u00C6\\u00E6\\u00D8\\u00F8\\u00C5\\u00E5', $this->object->cleanStringForJs('ÉÆæØøÅå'));
    $this->assertEquals('\\u00AE\\u00A9\\u2122', $this->object->cleanStringForJs('®©™'));
    $this->assertEquals(
      '\\u0021\\u00A7\\u0024\\u0025\\u0040\\u007B\\u007D\\u005B\\u005D\\u0028\\u0029\\u002B\\u002D\\u002A\\u002F\\u0023\\u007E\\u007C\\u00B4\\u0060\\u00B2\\u00B3\\u005C\\u005E\\u00B0',
      $this->object->cleanStringForJs('!§$%@{}[]()+-*/#~|´`²³\\^°')
    );
  }

  /**
   * @covers CleanOperations::cleanStringForJs
   * @test
   */
  public function cleanStringForJs_MancheSonderzeichen_ReturnUnchanged()
  {
    $this->assertEquals('.', $this->object->cleanStringForJs('.'));
    $this->assertEquals(',', $this->object->cleanStringForJs(','));
    $this->assertEquals('_', $this->object->cleanStringForJs('_'));
  }

  /**
   * @covers CleanOperations::cleanStringForJs
   * @test
   */
  public function cleanStringForJs_Euro_ReturnUniCode()
  {
    $this->assertEquals('\\u20AC', $this->object->cleanStringForJs('€'));
  }

  /**
   * @covers CleanOperations::cleanStringForJs
   * @test
   */
  public function cleanStringForJs_UnsichereSonderzeichen_ReturnUniCode()
  {
    $this->assertEquals('\\u003C', $this->object->cleanStringForJs('<'));
    $this->assertEquals('\\u003E', $this->object->cleanStringForJs('>'));
    $this->assertEquals('\\u0026', $this->object->cleanStringForJs('&'));
    $this->assertEquals('\\u0022', $this->object->cleanStringForJs('"'));
    $this->assertEquals('\\u0027', $this->object->cleanStringForJs("'"));
  }

  /**
   * @covers CleanOperations::cleanStringForJs
   * @test
   */
  public function cleanStringForJs_LineBreaks_BackslashN()
  {
    $linebreak = '
';
    $this->assertEquals('\\u000D\\u000A', $this->object->cleanStringForJs($linebreak));
    $this->assertEquals('\\u000A', $this->object->cleanStringForJs("\n"));
    $this->assertEquals('\\u000D', $this->object->cleanStringForJs("\r"));
    $this->assertEquals('\\u000D\\u000A\\u000D\\u000A\\u000A\\u000D\\u000D', $this->object->cleanStringForJs("\r\n\r\n\n\r\r"));
  }

  /**
   * @covers CleanOperations::cleanTimeString
   * @test
   */
  public function cleanTimeString_ValidTime_ReturnUnchanged()
  {
    $this->assertEquals('00:00', $this->object->cleanTimeString('00:00'));
    $this->assertEquals('12:15', $this->object->cleanTimeString('12:15'));
    $this->assertEquals('15:06', $this->object->cleanTimeString('15:06'));
    $this->assertEquals('23:59', $this->object->cleanTimeString('23:59'));
  }

  /**
   * @covers CleanOperations::cleanTimeString
   * @test
   */
  public function cleanTimeString_singleDigitHour_ReturnWithExpandedHour()
  {
    $this->assertEquals('00:00', $this->object->cleanTimeString('0:00'));
    $this->assertEquals('02:15', $this->object->cleanTimeString('2:15'));
    $this->assertEquals('09:59', $this->object->cleanTimeString('9:59'));
  }

  /**
   * @covers CleanOperations::cleanTimeString
   * @test
   */
  public function cleanTimeString_singleDigitMinute_ReturnWithExpandedMinute()
  {
    $this->assertEquals('00:00', $this->object->cleanTimeString('00:00'));
    $this->assertEquals('12:05', $this->object->cleanTimeString('12:5'));
    $this->assertEquals('19:09', $this->object->cleanTimeString('19:9'));
  }

  /**
   * @covers CleanOperations::cleanTimeString
   * @test
   */
  public function cleanTimeString_singleDigitMinuteSingleDigitHour_ReturnWithBothExpanded()
  {
    $this->assertEquals('00:00', $this->object->cleanTimeString('0:0'));
    $this->assertEquals('01:05', $this->object->cleanTimeString('1:5'));
    $this->assertEquals('09:09', $this->object->cleanTimeString('9:9'));
  }

  /**
   * @covers CleanOperations::cleanTimeString
   * @test
   */
  public function cleanTimeString_InvalidInput1_ThrowsException()
  {
    $this->assertEquals('00:00', $this->object->cleanTimeString('00:010'));
    $this->assertEquals('default', $this->object->cleanTimeString('00:010', 'default'));
  }

  /**
   * @covers CleanOperations::cleanTimeString
   * @test
   */
  public function cleanTimeString_InvalidInput2_ThrowsException()
  {
    $this->assertEquals('00:00', $this->object->cleanTimeString(':'));
    $this->assertEquals('default', $this->object->cleanTimeString(':', 'default'));
  }

  /**
   * @covers CleanOperations::cleanTimeString
   * @test
   */
  public function cleanTimeString_InvalidInput3_ThrowsException()
  {
    $this->assertEquals('00:00', $this->object->cleanTimeString('hallo'));
    $this->assertEquals('default', $this->object->cleanTimeString('hallo', 'default'));
  }

  /**
   * @covers CleanOperations::cleanTimeString
   * @test
   */
  public function cleanTimeString_EmptyInput()
  {
    $this->assertEquals('00:00', $this->object->cleanTimeString(''));
    $this->assertEquals('', $this->object->cleanTimeString('', ''));
  }

  /**
   * @covers CleanOperations::cleanDateString
   * @test
   */
  public function cleanDateString_VollstaendigesDatum_Unveraendert()
  {
    $this->assertEquals('01.01.2000', $this->object->cleanDateString('01.01.2000'));
    $this->assertEquals('31.12.2000', $this->object->cleanDateString('31.12.2000'));
    $this->assertEquals('05.03.2017', $this->object->cleanDateString('05.03.2017'));
    $this->assertEquals('30.12.1899', $this->object->cleanDateString('30.12.1899'));
    $this->assertEquals('01.01.2099', $this->object->cleanDateString('01.01.2099'));
  }

  /**
   * @covers CleanOperations::cleanDateString
   * @test
   */
  public function cleanDateString_KurzesDatum_VollstaendigesDatum()
  {
    $this->assertEquals('01.01.2001', $this->object->cleanDateString('1.1.01'));
    $this->assertEquals('13.02.2010', $this->object->cleanDateString('13.2.2010'));
    $this->assertEquals('05.03.2017', $this->object->cleanDateString('5.3.17'));
    $this->assertEquals('05.03.2017', $this->object->cleanDateString('5.3.2017'));
  }

  /**
   * @covers CleanOperations::cleanDateString
   * @test
   */
  public function cleanDateString_DatumMitLeerzeichen_EntferneLeerzeichen()
  {
    $this->assertEquals('01.01.2099', $this->object->cleanDateString('  01.01.2099  '));
    $this->assertEquals('01.01.2001', $this->object->cleanDateString('  1.1.01   '));
  }

  /**
   * @covers CleanOperations::cleanDateString
   * @test
   */
  public function cleanDateString_UngueltigesDatum_Default()
  {
    $this->assertEquals('30.12.1899', $this->object->cleanDateString('00.01.2000'));
    $this->assertEquals('default', $this->object->cleanDateString('00.01.2000', 'default'));
    $this->assertEquals('default', $this->object->cleanDateString('32.01.2000', 'default'));
    $this->assertEquals('default', $this->object->cleanDateString('01.00.2000', 'default'));
    $this->assertEquals('default', $this->object->cleanDateString('01.13.2000', 'default'));
    $this->assertEquals('default', $this->object->cleanDateString('01.13.', 'default'));
    $this->assertEquals('default', $this->object->cleanDateString('01.01.2001 12:10', 'default'));
    $this->assertEquals('default', $this->object->cleanDateString('', 'default'));
    $this->assertEquals('default', $this->object->cleanDateString(null, 'default'));
    $this->assertEquals('default', $this->object->cleanDateString('asdf', 'default'));
  }

  /**
   * @covers CleanOperations::cleanDateString
   * @test
   */
  public function cleanDateString_DatumAmSchalttag_ErkenntObSchaltjahr()
  {
    $this->assertEquals('29.02.2000', $this->object->cleanDateString('29.02.2000', 'default'));
    $this->assertEquals('default', $this->object->cleanDateString('29.02.2001', 'default'));
    $this->assertEquals('default', $this->object->cleanDateString('29.02.2002', 'default'));
    $this->assertEquals('default', $this->object->cleanDateString('29.02.2003', 'default'));
    $this->assertEquals('29.02.2004', $this->object->cleanDateString('29.02.2004', 'default'));
    $this->assertEquals('default', $this->object->cleanDateString('29.02.2005', 'default'));
  }

  /**
   * @covers CleanOperations::cleanInt
   * @test
   */
  public function cleanInt_intGiven_ReturnInput()
  {
    $this->assertEquals('3', $this->object->cleanInt(3));
  }

  /**
   * @covers CleanOperations::cleanInt
   * @test
   */
  public function cleanInt_stringGiven_ReturnInput()
  {
    $this->assertEquals(3, $this->object->cleanInt('3'));
  }

  /**
   * @covers CleanOperations::cleanInt
   * @test
   */
  public function cleanInt_emptyStringGiven_ReturnInput()
  {
    $this->assertEquals(0, $this->object->cleanInt(''));
  }

  /**
   * @covers CleanOperations::cleanInt
   * @test
   */
  public function cleanInt_nonNumericStringGiven_ReturnDefault()
  {
    $this->assertEquals(null, $this->object->cleanInt('blabla'));
    $this->assertEquals('default', $this->object->cleanInt('blabla', 'default'));
    $this->assertEquals(5, $this->object->cleanInt('blabla', 5));
  }

  /**
   * @covers CleanOperations::isInWhitelist
   * @test
   */
  public function isInWhitelist_NoWhitelistGiven_throwsException()
  {
    $this->expectException(InvalidArgumentException::class);
    $this->object->isInWhitelist(5, '');
  }

  /**
   * @covers CleanOperations::isInWhitelist
   * @test
   */
  public function isInWhitelist_EmptyWhitelistGiven_ReturnsFalse()
  {
    $this->assertFalse($this->object->isInWhitelist('', array()));
    $this->assertFalse($this->object->isInWhitelist('5', array()));
  }

  /**
   * @covers CleanOperations::isInWhitelist
   * @test
   */
  public function isInWhitelist_ElementWithSameType_ReturnsTrue()
  {
    $this->assertTrue($this->object->isInWhitelist('', array('')));
    $this->assertTrue($this->object->isInWhitelist('1', array('1')));
    $this->assertTrue($this->object->isInWhitelist(true, array(true)));
    $this->assertTrue($this->object->isInWhitelist('123456789', array('123456789')));
    $this->assertTrue($this->object->isInWhitelist(123456789, array(123456789)));
  }

  /**
   * @covers CleanOperations::isInWhitelist
   * @test
   */
  public function isInWhitelist_ElementWithDifferentType_ReturnsFalse()
  {
    $this->assertFalse($this->object->isInWhitelist(1, array('1')));
    $this->assertFalse($this->object->isInWhitelist('1', array(1)));
    $this->assertFalse($this->object->isInWhitelist(true, array('1')));
    $this->assertFalse($this->object->isInWhitelist(true, array(1)));
    $this->assertFalse($this->object->isInWhitelist(1e0, array('1')));
    $this->assertFalse($this->object->isInWhitelist('1e0', array('1')));
    $this->assertFalse($this->object->isInWhitelist('1E0', array('1')));
    $this->assertFalse($this->object->isInWhitelist(123456789, array('123456789')));
  }

  /**
   * @covers CleanOperations::isInWhitelist
   * @test
   */
  public function isInWhitelist_ElementNotInWhiteList_ReturnsFalse()
  {
    $this->assertFalse($this->object->isInWhitelist('', array('1')));
  }
}
