/**
  * 
  * 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
  */
 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);
     }
 }