function testUpdateBoardStatus() { for ($i = 0; $i < 10; $i++) { /* as we use random data lets perform this test a few times */ $expected = $this->randomCircuitBoardStatus(); $this->db->updateBoardStatus(6789, $expected); $result = $this->db->queryBoardStatus(6789); $this->assertIdentical($expected->getSwitchOne(), $result->getSwitchOne()); $this->assertIdentical($expected->getSwitchTwo(), $result->getSwitchTwo()); $this->assertIdentical($expected->getSwitchThree(), $result->getSwitchThree()); $this->assertIdentical($expected->getSwitchFour(), $result->getSwitchFour()); $this->assertIdentical($expected->getFan(), $result->getFan()); $this->assertIdentical($expected->getTemperature(), $result->getTemperature()); $this->assertIdentical($expected->getKeypad(), $result->getKeypad()); } }
/** * Fetches the statuses of the circuit boards from the database. * @throws Exception If a query fails to execute. */ public function fetchStatuses() { $database = new DatabaseWrapper(); $database->connect(DB_NAME); $boards = $database->queryAllBoardInformation(); foreach ($boards as $board) { $msisdn = $board->getMSISDN(); $status = null; try { $status = $database->queryBoardStatus($msisdn); } catch (Exception $e) { /* failed to find its status */ } $this->model->addBoard(new CircuitBoard($board, $status)); } }