/**
  * setPathAndFilename Test
  *
  * @param string $code Given from input field (should be a string)
  * @param string $codeInSession (string or empty)
  * @param bool $expectedResult
  * @dataProvider validCodeReturnsBoolDataProvider
  * @test
  */
 public function validCodeReturnsBool($code, $codeInSession, $expectedResult)
 {
     $this->initializeTsfe();
     $field = new Field();
     $field->_setProperty('uid', 123);
     SessionUtility::setCaptchaSession($codeInSession, 123);
     $this->assertSame($expectedResult, $this->generalValidatorMock->_call('validCode', $code, $field, false));
 }
 /**
  * Check if given code is correct
  *
  * @param string $code String to compare
  * @param Field $field String to compare
  * @param bool $clearSession
  * @return boolean
  */
 public function validCode($code, $field, $clearSession = true)
 {
     if ((int) $code === SessionUtility::getCaptchaSession($field->getUid()) && !empty($code)) {
         if ($clearSession) {
             SessionUtility::setCaptchaSession('', $field->getUid());
         }
         return true;
     }
     return false;
 }