private function fillVariables($variables, $overwrite = false) { foreach ($variables as $key => $val) { $this->variablesId++; $variable = new Variable(); $variable->setId($this->variablesId); $variable->setName($key); $variable->setValue($val); $tmpName = $variable->getTemplateName(); $ifName = $variable->getIfName(); $ifNotName = $variable->getIfNotName(); #fwrite(STDOUT, "settings: '".$key."' '".$tmpName."' '".$ifName."' => '".$val."'\n"); if ($overwrite || !$overwrite && !isset($this->variables[$tmpName])) { $this->variables[$tmpName] = $variable; $variableIf = clone $variable; if ($tmpName != $ifName) { #$variableIf->setReference($variable); $this->variablesId++; $variableIf->setId($this->variablesId); $variableIf->setValue((bool) $val); $this->variables[$ifName] = $variableIf; } $variableIfNot = clone $variableIf; #$variableIfNot->setReference($variableIf); $this->variablesId++; $variableIfNot->setId($this->variablesId); $variableIfNot->setValue(!$variableIfNot->getValue()); $this->variables[$ifNotName] = $variableIfNot; } } }
public function testSetId() { $variable = new Variable(); $variable->setId(1); $this->assertEquals(1, $variable->getId()); }