function test_generic_component()
 {
     $bodyStyle = new StyleCollection("body", "hey", "Body Style", "Global style settings.");
     $bodyStyle->addSP(new BackgroundColorSP("#FFFCF0"));
     $bodyStyle->addSP(new ColorSP("#2E2B33"));
     $bodyStyle->addSP(new FontSP("Verdana", "10pt"));
     $mainBoxStyle = new StyleCollection("*.mainBoxStyle", "mainBoxStyle", "Main Box Style", "Style for the main box.");
     $mainBoxStyle->addSP(new BackgroundColorSP("#FFF3C2"));
     $mainBoxStyle->addSP(new BorderSP("1px", "solid", "#2E2B33"));
     $mainBoxStyle->addSP(new WidthSP("750px"));
     $mainBoxStyle->addSP(new MarginSP("5px"));
     $mainBoxStyle->addSP(new PaddingSP("5px"));
     $comp1 = new Component(null, BLANK, 3);
     $style = $comp1->addStyle($bodyStyle);
     $this->assertReference($style, $bodyStyle);
     $comp1->addStyle($mainBoxStyle);
     $this->assertReference($comp1->_styleCollections["body"], $bodyStyle);
     $this->assertReference($comp1->_styleCollections["*.mainBoxStyle"], $mainBoxStyle);
     $this->assertIdentical($comp1->getType(), BLANK);
     $this->assertReference($comp1->getStyle("body"), $bodyStyle);
     $comp2 = new Component(null, BLANK, 3, $bodyStyle, $mainBoxStyle);
     $this->assertIdentical($comp2->_styleCollections["body"], $bodyStyle);
     $this->assertIdentical($comp2->_styleCollections["*.mainBoxStyle"], $mainBoxStyle);
     $this->assertIdentical($comp1->getType(), BLANK);
     $this->assertIdentical($comp2->getIndex(), 3);
     $this->assertIdentical($comp1, $comp2);
     $style = $comp1->removeStyle("body");
     $this->assertReference($style, $bodyStyle);
     $this->assertTrue(!isset($comp1->_styleCollections["body"]));
 }
 /**
  * 
  * @param Component $component
  * @return int id of the Component inserted in base. False if it didn't work.
  */
 public static function flush($component)
 {
     $componentId = $component->getId();
     $mark = $component->getMark();
     $date = $component->getDate();
     $isResit = $component->getIsResit();
     $user = $component->getUser()->getId();
     $componentLinked = $component->getComponent()->getId();
     $module = $component->getModule()->getId();
     $type = $component->getType()->getId();
     if ($componentId > 0) {
         $sql = 'UPDATE component c SET ' . 'c.mark = ?, ' . 'c.date = ?, ' . 'c.is_resit = ?, ' . 'c.USER_id_user = ?, ' . 'c.COMPONENT_id_component = ?, ' . 'c.MODULE_id_module = ?, ' . 'c.TYPE_id_type= ? ' . 'WHERE c.id_component = ?';
         $params = array('dsiiiiii', &$mark, &$date, &$isResit, &$user, &$componentLinked, &$module, &$type, &$componentId);
     } else {
         $sql = 'INSERT INTO component ' . '(mark, date, is_resit, ' . 'USER_id_user, COMPONENT_id_component, MODULE_id_module, TYPE_id_type ) ' . 'VALUES(?, ?, ?, ?, ?, ?, ?) ';
         $params = array('dsiiiii', &$mark, &$date, &$isResit, &$user, &$componentLinked, &$module, &$type);
     }
     $idInsert = BaseSingleton::insertOrEdit($sql, $params);
     if ($idInsert !== false && $componentId > 0) {
         $idInsert = $componentId;
     }
     return $idInsert;
 }