/**
  * test convertImage function (myFileConverter::convertImage)
  * the test is done by executing a number of different tests on different files and comparing result
  * to the produvtion servert results
  */
 public function testConvertImage()
 {
     $status = null;
     $tester = null;
     // test all source files and compare result to output reference file
     for ($i = 0; $i < count($this->sourceFiles); $i++) {
         $tester = new convertImageTester($this->sourceFiles[$i], $this->outputReferenceFiles[$i]);
         // extract convertion parameters from $outputReferenceFile and update $tester for those parameters
         $params = array();
         $tmp = array();
         $tmp = explode("/", $this->outputReferenceFiles[$i]);
         // get rid of source file name and extension of file
         for ($j = 0; $j < 8; $j++) {
             array_shift($tmp);
         }
         array_pop($tmp);
         $j = 0;
         while ($j < count($tmp)) {
             $params["{$tmp[$j]}"] = $tmp[$j + 1];
             $j += 2;
         }
         array_key_exists('width', $params) ? $tester->setWidth($params['width']) : $tester->setWidth();
         array_key_exists('height', $params) ? $tester->setHeight($params['height']) : $tester->setHeight();
         array_key_exists('type', $params) ? $tester->setCropType($params['type']) : $tester->setCropType();
         array_key_exists('bgcolor', $params) ? $tester->setBGColor($params['bgcolor']) : $tester->setBGColor();
         array_key_exists('quality', $params) ? $tester->setQuality($params['quality']) : $tester->setQuality();
         array_key_exists('src_x', $params) ? $tester->setSrcX($params['src_x']) : $tester->setSrcX();
         array_key_exists('src_y', $params) ? $tester->setSrcY($params['src_y']) : $tester->setSrcY();
         array_key_exists('src_w', $params) ? $tester->setSrcW($params['src_w']) : $tester->setSrcW();
         array_key_exists('src_h', $params) ? $tester->setSrcH($params['src_h']) : $tester->setSrcH();
         // excute test and assert
         $status = $tester->execute();
         if ($status === false) {
             echo 'unable to convert [' . $tester->getSourceFile() . '] with parameterrs: ' . print_r($tester->getParams()) . PHP_EOL;
         }
         //	assert(true === $status);
         // download from production the converted image (thumbnail) and
         // check if output is identical to reference output
         $tester->downloadUrlFile();
         $tester->setGraphicTol(0.33);
         $tester->setByteTol($tester->getByteTol() * 15);
         $status = $tester->compareTargetReference();
         $tester->deleteDownloadFile();
         if ($status === false) {
             echo 'images files: [' . $tester->getOutputReferenceFile() . '], [' . $tester->getTargetFile() . '] are not identical' . PHP_EOL;
         }
         //	assert(true === $status);
         echo 'convertImage test completed on file [' . $tester->getOutputReferenceFile() . ']' . PHP_EOL;
         unset($tester);
     }
 }
 /**
  * 
  * test convertImage function (myFileConverter::convertImage)
  * the test is done by executing a number of different tests on different files
  * @param string $sourceFile
  * @param string $outputReferenceFile
  * @dataProvider providerTestList
  */
 public function testConvertImage($sourceFile, $outputReferenceFile)
 {
     $status = null;
     $tester = null;
     $tester = new convertImageTester($sourceFile, $outputReferenceFile);
     // extract convertion parameters from $outputReferenceFile and update $tester for those parameters
     if ($outputReferenceFile) {
         $params = array();
         $tmp = array();
         $tmp = explode("_", basename($outputReferenceFile));
         // get rid of source file name and extension of file
         array_pop($tmp);
         array_shift($tmp);
         $j = 0;
         while ($j < count($tmp)) {
             $params["{$tmp[$j]}"] = $tmp[$j + 1];
             $j += 2;
         }
         array_key_exists('width', $params) ? $tester->setWidth($params['width']) : $tester->setWidth();
         array_key_exists('height', $params) ? $tester->setHeight($params['height']) : $tester->setHeight();
         array_key_exists('cropType', $params) ? $tester->setCropType($params['cropType']) : $tester->setCropType();
         array_key_exists('bGColor', $params) ? $tester->setBGColor(hexdec($params['bGColor'])) : $tester->setBGColor();
         array_key_exists('forceJpeg', $params) ? $tester->setForceJpeg($params['forceJpeg']) : $tester->setForceJpeg();
         array_key_exists('quality', $params) ? $tester->setQuality($params['quality']) : $tester->setQuality();
         array_key_exists('srcX', $params) ? $tester->setSrcX($params['srcX']) : $tester->setSrcX();
         array_key_exists('srcY', $params) ? $tester->setSrcY($params['srcY']) : $tester->setSrcY();
         array_key_exists('srcW', $params) ? $tester->setSrcW($params['srcW']) : $tester->setSrcW();
         array_key_exists('srcH', $params) ? $tester->setSrcH($params['srcH']) : $tester->setSrcH();
     }
     // excute test and assert
     if (($status = $tester->execute()) === false) {
         unset($tester);
     }
     $this->assertTrue($status, 'unable to convert [' . $tester->getSourceFile() . '] with parameterrs: ' . print_r($tester->getParams(), true));
     // check that file was not suposed to be produced (doc / notepad file, etc.)
     if ($tester->getTargetFile() === null && @getimagesize($tester->getSourceFile()) === false) {
         return;
     }
     // check if output is identical to reference output
     $this->assertFalse($tester->checkConvertionComplete(), 'reference file [' . $tester->getOutputReferenceFile() . '] was not produced' . PHP_EOL);
     $this->assertTrue($tester->checkExtensions(), 'files extension are not identical' . PHP_EOL);
     $this->assertTrue($tester->checkSize(), 'files sizes are not identical' . $tester->getTargetFile() . ': ' . @filesize($tester->getTargetFile()) . ' bytes' . PHP_EOL . $tester->getOutputReferenceFile() . ': ' . @filesize($tester->getOutputReferenceFile()) . ' bytes' . PHP_EOL);
     $this->assertTrue($tester->checkWidthHeigth(), 'files width / height are not identical');
     $status = $tester->checkGraphicSimilarity();
     $this->assertTrue($status < 1, 'unable to perform graphical comparison' . PHP_EOL);
     $this->assertTrue($tester->getGraphicTol() > $status, "graphical comparison returned with highly un-identical value [{$status}]" . PHP_EOL);
     unset($tester);
 }
 /**
  * 
  * test convertImage function (myFileConverter::convertImage)
  * the test is done by executing a number of different tests on different files and comparing result
  * to the produvtion servert results
  * @dataProvider providerTestList
  */
 public function testConvertImage($sourceFile, $outputReferenceFile)
 {
     $status = null;
     $tester = null;
     $tester = new convertImageTester($sourceFile, $outputReferenceFile);
     // extract convertion parameters from $outputReferenceFile and update $tester for those parameters
     $params = array();
     $tmp = array();
     $tmp = explode("/", $outputReferenceFile);
     // get rid of source file name and extension of file
     for ($j = 0; $j < 8; $j++) {
         array_shift($tmp);
     }
     array_pop($tmp);
     $j = 0;
     while ($j < count($tmp)) {
         $params["{$tmp[$j]}"] = $tmp[$j + 1];
         $j += 2;
     }
     array_key_exists('width', $params) ? $tester->setWidth($params['width']) : $tester->setWidth();
     array_key_exists('height', $params) ? $tester->setHeight($params['height']) : $tester->setHeight();
     array_key_exists('type', $params) ? $tester->setCropType($params['type']) : $tester->setCropType();
     array_key_exists('bGColor', $params) ? $tester->setBGColor(hexdec($params['bGColor'])) : $tester->setBGColor();
     array_key_exists('quality', $params) ? $tester->setQuality($params['quality']) : $tester->setQuality();
     array_key_exists('src_x', $params) ? $tester->setSrcX($params['src_x']) : $tester->setSrcX();
     array_key_exists('src_y', $params) ? $tester->setSrcY($params['src_y']) : $tester->setSrcY();
     array_key_exists('src_w', $params) ? $tester->setSrcW($params['src_w']) : $tester->setSrcW();
     array_key_exists('src_h', $params) ? $tester->setSrcH($params['src_h']) : $tester->setSrcH();
     // excute test and assert
     // excute test and assert
     if (($status = $tester->execute()) === false) {
         unset($tester);
     }
     $this->assertTrue($status, 'unable to convert [' . $tester->getSourceFile() . '] with parameterrs: ' . print_r($tester->getParams(), true));
     // download from production the converted image (thumbnail) and
     $tester->downloadUrlFile();
     $tester->setGraphicTol(0.25);
     $tester->setByteTol($tester->getByteTol() * 100);
     // check if output is identical to reference output
     $this->assertFalse($tester->checkConvertionComplete(), 'reference file [' . $tester->getOutputReferenceFile() . '] was not produced' . PHP_EOL);
     $this->assertTrue($tester->checkExtensions(), 'files extension are not identical' . PHP_EOL);
     $this->assertTrue($tester->checkSize(), 'files sizes are not identical');
     $this->assertTrue($tester->checkWidthHeigth(), 'files width / height are not identical');
     $status = $tester->checkGraphicSimilarity();
     $this->assertTrue($status < 1, 'unable to perform graphical comparison' . PHP_EOL);
     $this->assertTrue($tester->getGraphicTol() > $status, "graphical comparison returned with highly un-identical value [{$status}]" . PHP_EOL);
     //	$status = $tester->compareTargetReference();
     //	$tester->deleteDownloadFile();
     //	$this->assertTrue($status, 'images files: [' . $tester->getOutputReferenceFile() . '], [' .
     //		$tester->getTargetFile () . '] are not identical');
     unset($tester);
 }
 /**
  * test convertImage function (myFileConverter::convertImage)
  * the test is done by executing a number of different tests on different files
  */
 public function testConvertImage()
 {
     $status = null;
     $tester = null;
     // test all source files and compare result to output reference file
     for ($i = 0; $i < count($this->sourceFiles); $i++) {
         $tester = new convertImageTester($this->sourceFiles[$i], $this->outputReferenceFiles[$i]);
         // extract convertion parameters from $outputReferenceFile and update $tester for those parameters
         if ($this->outputReferenceFiles[$i]) {
             $params = array();
             $tmp = array();
             $tmp = explode("_", basename($this->outputReferenceFiles[$i]));
             // get rid of source file name and extension of file
             array_pop($tmp);
             array_shift($tmp);
             $j = 0;
             while ($j < count($tmp)) {
                 $params["{$tmp[$j]}"] = $tmp[$j + 1];
                 $j += 2;
             }
             array_key_exists('width', $params) ? $tester->setWidth($params['width']) : $tester->setWidth();
             array_key_exists('height', $params) ? $tester->setHeight($params['height']) : $tester->setHeight();
             array_key_exists('cropType', $params) ? $tester->setCropType($params['cropType']) : $tester->setCropType();
             array_key_exists('bGColor', $params) ? $tester->setBGColor(hexdec($params['bGColor'])) : $tester->setBGColor();
             array_key_exists('forceJpeg', $params) ? $tester->setForceJpeg($params['forceJpeg']) : $tester->setForceJpeg();
             array_key_exists('quality', $params) ? $tester->setQuality($params['quality']) : $tester->setQuality();
             array_key_exists('srcX', $params) ? $tester->setSrcX($params['srcX']) : $tester->setSrcX();
             array_key_exists('srcY', $params) ? $tester->setSrcY($params['srcY']) : $tester->setSrcY();
             array_key_exists('srcW', $params) ? $tester->setSrcW($params['srcW']) : $tester->setSrcW();
             array_key_exists('srcH', $params) ? $tester->setSrcH($params['srcH']) : $tester->setSrcH();
         }
         // excute test and assert
         $status = $tester->execute();
         if ($status === false) {
             echo 'unable to convert [' . $tester->getSourceFile() . '] with parameterrs: ' . print_r($tester->getParams());
         }
         assert(true === $status);
         // check if output is identical to reference output
         $status = $tester->compareTargetReference();
         if ($status === false) {
             echo 'images files: [' . $tester->getOutputReferenceFile() . '], [' . $tester->getTargetFile() . '] are not identical';
         }
         assert(true === $status);
         echo 'convertImage test was successfull on file [' . $tester->getSourceFile() . ']' . PHP_EOL;
         unset($tester);
     }
 }