public function test_hasAddedTableManually_shouldReturnFalse_IfTableWasNotAddedManually() { $result = $this->tables->hasAddedTableManually('log_foo_bar_baz'); $this->assertFalse($result); $result = $this->tables->hasAddedTableManually('log_conversion_item'); $this->assertFalse($result); }
/** * This code is a bit tricky. We have to execute this right at the beginning before actually iterating over all the * tables and generating the join string as we may have to delete a table from the tables. If we did not delete * this table upfront, we would have maybe already added a joinString for that table, even though it will be later * removed by another table. This means if we wouldn't delete/unset that table upfront, we would need to alter * an already generated join string which would not be really nice code as well. * * Next problem is, because we are deleting a table, we have to remember the "joinOn" string for that table in a * property "nonVisitJoins". Otherwise we would not be able to generate the correct "joinOn" string when actually * iterating over all the tables to generate that string. * * @param $tableName * @param $tableNameToJoin * @param $index */ protected function generateNonVisitJoins($tableName, $tableNameToJoin, $index) { $logTable = $this->tables->getLogTable($tableName); $logTableToJoin = $this->tables->getLogTable($tableNameToJoin); $nonVisitJoin = sprintf("%s.%s = %s.%s", $logTableToJoin->getName(), $logTableToJoin->getColumnToJoinOnIdAction(), $tableName, $logTable->getColumnToJoinOnIdAction()); $altNonVisitJoin = sprintf("%s.%s = %s.%s", $tableName, $logTable->getColumnToJoinOnIdAction(), $logTableToJoin->getName(), $logTableToJoin->getColumnToJoinOnIdAction()); if ($index > 0 && $this->tables->hasAddedTableManually($tableName) && !$this->tables->hasJoinedTableManually($tableName, $nonVisitJoin) && !$this->tables->hasJoinedTableManually($tableName, $altNonVisitJoin)) { $tableIndex = $this->tables->findIndexOfManuallyAddedTable($tableName); $nonVisitJoin = '(' . $this->tables[$tableIndex]['joinOn'] . ' AND ' . $nonVisitJoin . ')'; unset($this->tables[$tableIndex]); } if (!isset($this->nonVisitJoins[$tableName])) { $this->nonVisitJoins[$tableName] = array(); } if (!isset($this->nonVisitJoins[$tableNameToJoin])) { $this->nonVisitJoins[$tableNameToJoin] = array(); } $this->nonVisitJoins[$tableName][$tableNameToJoin] = $nonVisitJoin; $this->nonVisitJoins[$tableNameToJoin][$tableName] = $nonVisitJoin; }