示例#1
0
 public function testInserindoSiglaTempo()
 {
     $siglaTemplo = new SiglaTempo();
     $siglaTemplo->setSigla('c');
     $siglaTemplo->setDescricao('Chuva');
     $dataAccess = new PDODataAccess($this->pdo);
     $id = $dataAccess->insert($siglaTemplo);
     $this->assertEquals(1, $id);
     $singlaTempoInserida = $dataAccess->getById($id);
     $this->assertInstanceOf('PrevisaoTempo\\DataAccess\\Entity\\SiglaTempo', $singlaTempoInserida);
     $this->assertEquals($siglaTemplo->getSigla(), $singlaTempoInserida->getSigla());
     $this->assertEquals($siglaTemplo->getDescricao(), $singlaTempoInserida->getDEscricao());
 }
示例#2
0
 public function insert(SiglaTempo $siglaTempo)
 {
     $stm = $this->pdo->prepare('INSERT INTO siglatempo(
             sigla,
             descricao
         ) VALUES (
             :sigla,
             :descricao
         );');
     $stm->bindValue(':sigla', $siglaTempo->getSigla(), PDO::PARAM_STR);
     $stm->bindValue(':descricao', $siglaTempo->getDescricao(), PDO::PARAM_STR);
     if ($stm->execute()) {
         return (int) $this->pdo->lastInsertId();
     }
     throw new \RuntimeException('Falha ao inserir');
 }
示例#3
0
 public function testDefinindoADescricaoERetornaExatamenteValorODefinido()
 {
     $intancia = new SiglaTempo();
     $intancia->setDescricao("descricao");
     $this->assertEquals("descricao", $intancia->getDescricao());
 }