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()); }
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'); }
public function testDefinindoADescricaoERetornaExatamenteValorODefinido() { $intancia = new SiglaTempo(); $intancia->setDescricao("descricao"); $this->assertEquals("descricao", $intancia->getDescricao()); }