Exemplo n.º 1
0
 function test_setName()
 {
     //Arrange
     $name = "Paddys";
     $location = "462 Over There Way";
     $link = "www.paddyspub.com";
     $test_pub = new Pub($name, $location, $link);
     $new_name = "The Bar";
     //Act
     $test_pub->setName($new_name);
     $result = $test_pub->getName();
     //Assert
     $this->assertEquals($new_name, $result);
 }
Exemplo n.º 2
0
 /**
  * Inserts a row inte the table pubs
  *
  * @param Pub $pub
  * @throws \DataBaseException
  * @throws \Exception
  */
 public function addPub(Pub $pub)
 {
     try {
         $stmt = $this->conn->prepare("INSERT INTO " . self::$table . " VALUES(?, ?, ?, ?)");
         if (!$stmt) {
             throw new \DataBaseException($this->conn->error);
         }
         $id = $pub->getId();
         $name = $pub->getName();
         $address = $pub->getAddress();
         $webpage = $pub->getWebpageURL();
         $stmt->bind_param("ssss", $id, $name, $address, $webpage);
         $stmt->execute();
     } catch (\DataBaseException $e) {
         if (\Settings::DEBUG_MODE) {
             throw $e;
         } else {
             error_log($e->getMessage() . "\n", 3, \Settings::ERROR_LOG);
             echo "Something went wrong when connecting to the database";
             die;
         }
     }
 }