/** * test grabbing a tag by Name **/ public function testGetTagByName() { //count the number of rows and save them for later $numRows = $this->getConnection()->getRowCount("tag"); //create new tag and insert it into the database $tag = new Tag(null, $this->VALID_TAGNAME); $tag->insert($this->getPDO()); $results = Tag::getTagByName($this->getPDO(), $tag->getTagName()); $this->assertEquals($numRows + 1, $this->getConnection()->getRowCount("tag")); // $this->assertCount(1, $results); $this->assertContainsOnlyInstancesOf("Edu\\Cnm\\Jpegery\\Tag", $results); //grabs results from array and validates them $pdoTag = $results[0]; $this->assertEquals($pdoTag->getTagId(), $tag->getTagId()); $this->assertEquals($pdoTag->getTagName(), $this->VALID_TAGNAME); }
// $tag = Tag::getTagByName($pdo, $id); // if($tag !== null && $tag->getTagName() === $_SESSION["tag"]->getTagName()) { // $reply->data = $tag; // } // } else if(empty($allTags) === false) { // $tag = Tag::getAllTags($pdo, $id); // if($tag !== null && $tag->getAllTags() === $_SESSION["tag"]->getAllTags()) { // $reply->data = $tag; // } // // } if (empty($id) === false) { $reply->data = Tag::getTagById($pdo, $tagId); } else { if (empty($city) === false) { $reply->data = Tag::getTagByName($pdo, $tagName)->toArray(); } else { if (empty($name) === false) { $reply->data = Tag::getAllTags($pdo, $tags)->toArray(); } } } } //handle REST calls for PUT methods //If the user is logged in, allow to POST their own tag. if (empty($_SESSION["profile"]) !== false) { if ($method === "POST") { verifyXsrf(); $requestContent = file_get_contents("php://input"); $requestObject = json_decode($requestContent); }