/** * test grabbing all tags **/ public function testGetAllValidTags() { //count the number of rows and save it for later $numRows = $this->getConnection()->getRowCount("tag"); //create a new Tag and insert it into mySQL $tag = new Tag(null, $this->VALID_TAGNAME); $tag->insert($this->getPDO()); //grab the data from mySQL and enforce the fields match our expectations $results = Tag::getAllTags($this->getPDO()); $this->assertEquals($numRows + 1, $this->getConnection()->getRowCount("tag")); $this->assertCount(1, $results); $this->assertContainsOnlyInstancesOf("Edu\\Cnm\\Jpegery\\Tag", $results); //grab the result from the array and validate it $pdoTag = $results[0]; $this->assertEquals($pdoTag->getTagId(), $tag->getTagId()); $this->assertEquals($pdoTag->getTagName(), $this->VALID_TAGNAME); }
// } // } 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); } //ensure all fields are present if (empty($requestObject->tagId) === true) { throw new InvalidArgumentException("Tag must have an ID", 405);