Example #1
0
 /**
  * @group DDC-1737
  */
 public function testClobNoAlterTable()
 {
     $tableOld = new Table("test");
     $tableOld->addColumn('id', 'integer');
     $tableOld->addColumn('description', 'string', array('length' => 65536));
     $tableNew = clone $tableOld;
     $tableNew->setPrimaryKey(array('id'));
     $diff = $this->comparator->diffTable($tableOld, $tableNew);
     $sql = $this->platform->getAlterTableSQL($diff);
     $this->assertEquals(array('ALTER TABLE test ADD PRIMARY KEY (id)'), $sql);
 }
Example #2
0
 function testEngineProvidesDebugInformation()
 {
     $engineSet = new EngineSet();
     $engineSet->register('test-a', new Engine\FakeEngine([['type' => 'wiki page', 'object' => 'Content A'], new Debug\SourceDocument('wiki page', 'Content Z')]));
     $comparator = new Comparator($engineSet);
     $input = new Input\UserInput('bob');
     $expect = new RecommendationSet('test-a');
     $expect->add(new Recommendation('wiki page', 'Content A'));
     $expect->addDebug(new Debug\SourceDocument('wiki page', 'Content Z'));
     $this->assertEquals([$expect], $comparator->generate($input));
 }
 public function testSwitchPrimaryKeyOrder()
 {
     $tableOld = new Table("test");
     $tableOld->addColumn('foo_id', 'integer');
     $tableOld->addColumn('bar_id', 'integer');
     $tableNew = clone $tableOld;
     $tableOld->setPrimaryKey(array('foo_id', 'bar_id'));
     $tableNew->setPrimaryKey(array('bar_id', 'foo_id'));
     $diff = $this->comparator->diffTable($tableOld, $tableNew);
     $sql = $this->platform->getAlterTableSQL($diff);
     $this->assertEquals(array('ALTER TABLE test DROP PRIMARY KEY', 'ALTER TABLE test ADD PRIMARY KEY (bar_id, foo_id)'), $sql);
 }
 public function executeExplore(sfWebRequest $request)
 {
     $comparator = new Comparator($request->getUri());
     $this->simple = $comparator->analyze_link('simple')->results();
     $ids = $comparator->getOnlyTrueFeatures();
     $this->true = $ids;
     $this->url = $request->getUri();
     $this->goods = Doctrine_Core::getTable('Feature')->GetByIds($ids);
     if (isset($data['secondary']['false'])) {
         $this->bads = Doctrine_Core::getTable('Feature')->GetByIds($data['secondary']['false']);
     }
     /* First view only */
     $this->apps = Doctrine_Core::getTable('Apartment')->createQuery('a')->limit(2)->execute();
 }
Example #5
0
 /**
  * For the current comparator object checks
  * if a given condition is convenient
  * Ex:
  * (new Comparator(10, 20))->expect('!='); returns true because 10 and 20 are different.
  * 
  * @param  Comparation Operator $expect
  * @return boolean
  */
 public function expect($expect)
 {
     $cmp = Comparator::compare($this->itemA, $this->itemB);
     switch ($expect) {
         case '=':
             return $cmp === 0;
             break;
         case '!=':
             return $cmp != 0;
             break;
         case '>=':
             return $cmp >= 0;
             break;
         case '<=':
             return $cmp <= 0;
             break;
         case '>':
             return $cmp > 0;
             break;
         case '<':
             return $cmp < 0;
             break;
         default:
             throw new Exception('Invalid comparator operation.');
     }
     return 0;
 }
Example #6
0
 public function linesEqual($textA, $textB)
 {
     $modifier = new Comparator();
     $modifier->setIgnoreWhitespaces(false);
     $modifier->modifyCompareValues($textA, $textB);
     $linesA = explode("\n", $textA);
     $linesB = explode("\n", $textB);
     $lines = max(count($linesA), count($linesB));
     $result = array();
     for ($i = 0; $i < $lines; $i++) {
         $lineA = isset($linesA[$i]) ? $linesA[$i] : null;
         $lineB = isset($linesB[$i]) ? $linesB[$i] : null;
         $result[] = $this->isEqual($lineA, $lineB);
     }
     return $result;
 }
Example #7
0
 /**
  * Sort a collection by user preference
  * @param  string/callable $sortBy
  * @param  [string] $sorting
  * @return Collection
  */
 public function sort($sortBy = null, $sorting = 'ascending')
 {
     $tmp = $this->data;
     if (!is_callable($sortBy)) {
         $callback = function ($a, $b) use($sortBy) {
             if (is_array($a) && is_array($b)) {
                 $a = ArrayHelper::path($a, $sortBy);
                 $b = ArrayHelper::path($b, $sortBy);
             }
             return Comparator::compare($a, $b);
         };
     } else {
         $callback = $sortBy;
     }
     uasort($tmp, $callback);
     $newCollection = new Collection($tmp);
     if ($sorting == 'descending') {
         return $newCollection->reverse();
     }
     return $newCollection;
 }
Example #8
0
 if (($handleInput = fopen("comparison2.csv", "r")) !== FALSE) {
     $linesExp = [];
     $titles = fgetcsv($handleInput, 541, ";");
     //pop the first line (headers of columns)
     while (($data = fgetcsv($handleInput, 541, ";")) !== FALSE) {
         $t_val = $data[$target];
         $t_adel = $data[$target + 1];
         //strval($a->anomalyManager->evalAnomalies()),$a->ininterpretable,$human_interp);
         $problem = $data[0];
         $protocol = $data[1];
         $problemSerie = substr($problem, -2);
         $anomalCount = $data[26];
         $cpu_interp = $data[27];
         $h_interp = $data[28];
         $id = $data[29];
         $comp = new Comparator(["T1", "P1", "d"], $t_val, $t_adel, Logger::getLogger("main"));
         $successNumericValue = 0;
         if ($t_val == "can't compare") {
             continue;
             //we don't study these ones as the conventions are pretty hard to respect
         }
         $s = $comp->compareExpressions() == True;
         if ($s) {
             $success++;
             $successNumericValue = 1;
         } else {
             if ($count - $success < 100) {
                 fputcsv($handleOutput_errors, $data, ";");
             }
         }
         $line = [$protocol, $successNumericValue, $t_val, $t_adel, $h_interp, $cpu_interp, $anomalCount, $problem, $problemSerie];
Example #9
0
 $rKalesa = new ReaderKalesa(".");
 $rApex = new ReaderApex(".");
 //print(realpath($r->path));
 //print(getcwd());
 echo "DIR=";
 $pathtoimages = getcwd();
 print getcwd();
 echo "\n";
 $a1 = $rKalesa->readTrackArray();
 $a2 = $rApex->readTrackArray();
 if (!$a1 && !$a2) {
     chdir("..");
     continue;
 }
 //print_r($rApex->arrayTrack);
 $comp = new Comparator($rApex, $rKalesa, 5, $pathtoimages);
 if ($comp->Compare()) {
     ob_start();
     $comp->PrintApex1();
     $comp->PrintKalesa1();
     $comp->PrintFullArray1();
     //print ("yes");
     $reswrite1 = ob_get_clean();
     $fres1 = fopen("restest1.txt", "w");
     fputs($fres1, $reswrite1);
     fclose($fres1);
     ob_start();
     /*print ($rApex->trackCount[" 142460151 "]);
     		echo "\n";*/
     $comp->PrintFullArray2();
     $comp->PrintApex2();
 public static function mergeSortedLists($list1, $list2, Comparator $comparator, $compareValueGetter = null, $limit = null)
 {
     $list1Size = count($list1);
     $list2Size = count($list2);
     $i = $j = $k = 0;
     $newList = array();
     while ($i < $list1Size && $j < $list2Size) {
         if ($limit && $k == $limit) {
             return $newList;
         }
         if (!$compareValueGetter) {
             $compareResult = $comparator->compare($list1[$i], $list2[$j]);
         } else {
             $compareResult = $comparator->compare($list1[$i]->{$compareValueGetter}(), $list2[$j]->{$compareValueGetter}());
         }
         // list1 elt < list2 elt
         if ($compareResult < 0) {
             $newList[$k++] = $list2[$j++];
         } else {
             $newList[$k++] = $list1[$i++];
         }
     }
     while ($i < $list1Size) {
         if ($limit && $k == $limit) {
             return $newList;
         }
         $newList[$k++] = $list1[$i++];
     }
     while ($j < $list2Size) {
         if ($limit && $k == $limit) {
             return $newList;
         }
         $newList[$k++] = $list2[$j++];
     }
     return $newList;
 }