public function warnWrongTableStructure(Trace $trace, $tableName, array $expectedDefinition, array $definition) { Preconditions::checkIsString($tableName); if ($expectedDefinition != $definition) { $message = array('type' => 'unexpectedTableStructure', 'tableName' => $tableName); $this->addWarning($message); $child = $trace->addChild("Differences in data table " . $tableName); list($del, $both, $ins) = FajrUtils::compareArrays($expectedDefinition, $definition); $child->tlogVariable('deleted', $del); $child->tlogVariable('unchanged', $both); $child->tlogVariable('inserted', $ins); $child->tlogVariable('expectedDefinition', $expectedDefinition); $child->tlogVariable('definition', $definition); } }
public function testCompareArrays() { $old = array(); $new = array('jedna'); list($del, $both, $ins) = FajrUtils::compareArrays($old, $new); $this->assertEquals(array(), $del); $this->assertEquals(array(), $both); $this->assertEquals(array('jedna'), $ins); $old = array('jedna'); $new = array(); list($del, $both, $ins) = FajrUtils::compareArrays($old, $new); $this->assertEquals(array('jedna'), $del); $this->assertEquals(array(), $both); $this->assertEquals(array(), $ins); $old = array('jedna'); $new = array('jedna'); list($del, $both, $ins) = FajrUtils::compareArrays($old, $new); $this->assertEquals(array(), $del); $this->assertEquals(array('jedna'), $both); $this->assertEquals(array(), $ins); $old = array('jedna', 'dva', 'styri'); $new = array('jedna', 'tri', 'styri'); list($del, $both, $ins) = FajrUtils::compareArrays($old, $new); $this->assertEquals(array('dva'), $del); $this->assertEquals(array('jedna', 'styri'), $both); $this->assertEquals(array('tri'), $ins); }